Spyder wont run code - Python -


im new programming , have been using python simulate physical systems, in spyder on osx 10.9.2. dont think problem code because runs fine once after when hit run, command line (python interpreter think called?) displays runfile('/users/paddy/....name of file) , cant run code again after that. other simple small programs wont run. '>>>' in command line has disappeared.

i have searched web solution honest, im not sure im looking or type of error is, whether bug in spyder or otherwise. should code have sort of 'termination'?

ive included full body of code im working on incase there error in there. say, im new , cnt tell whether issue spyder or code. appreciated, have deadline looming! thanks

# velocity verlet integrator  def verlet(x, v, dt, a):      x_new = x + v*dt + (a(x,v,r)*dt**2)/2     v_new = v + (a(x,v,r) + (2/(2-dt))*((((48/x_new**13)-(24/x_new**7)) - v + (0.5)*a(x,v,r)*dt + 2**(0.5) * r)) )/2 * dt     return (x_new, v_new)   # start main program  # import required libraries import numpy np numpy import array, zeros import random     mu, sigma = 0, 0.1 # mean , variance s = np.random.normal(mu, sigma, 1000) # random numbers generated gaussian    # function    def a(x,v,r):      acc = (((48/x**13)-(24/x**7)) - v + 2**(0.5) * r)      return acc  # set starting values position , velocity x = array([5]) v = array([0])     n = 1000 # integration time steps m = 10  # save position every m timestep dt = 1.0 / (n) # calculate timestep length in seconds  # lists storing position , velocity xlist = zeros([1,n/m]) #define vector dimensions vlist = zeros([1,n/m]) # put initial values lists xlist[:,0] = x vlist[:,0] = v  # run simulation  print "total number of steps:", n print "saving location every %d steps." % (m) print "start." in range(n/m):     # run m steps before saving values     j in range(m):           # update position , velocity based on current ones           # , acceleration function            r = random.choice(s) # selects random number s            x, v = verlet(x, v, dt, a)      # save values lists     xlist[:, i] = x     vlist[:, i] = v print ("stop.")  print (xlist) print (vlist)    l = zeros([1,n/m])  k=0 while k < 101:     l = k+1     l[:,l]  print (l)    # plot results   matplotlib import pyplot plt #plt.plot(l, xlist)  # set equal axis plt.axis('equal') # draw x , y axis lines plt.axhline(color="black") plt.axvline(color="black")  #plt.show() 

it's infinite loop in while k < 101 loop because never increment k. try example:

k=0 while k < 100:     l[:,k]     k += 1 

also note python 0 based. need k go 0 99 100 length vector, not 1 100.


Comments

Popular posts from this blog

user interface - How to replace the Python logo in a Tkinter-based Python GUI app? -

objective c - Greedy NSProgressIndicator Allocation -

how to set an OCR language in Google Drive -