Advertisement
Guest User

Untitled

a guest
Mar 29th, 2017
50
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.54 KB | None | 0 0
  1. L = 100
  2. X0 = np.array([L,0])
  3. t = 48
  4. h = 0.01
  5.  
  6. def euler(X0,h,t):
  7. x0 = X0[0]
  8. y0 = X0[1]
  9. w_list_x = np.zeros(t)
  10. w_list_y = np.zeros(t)
  11. w_list_x[0] = x0
  12. w_list_y[0] = y0
  13. T = 24
  14. for i in range(1,t):
  15. R = np.sqrt(w_list_x[i-1]**2+w_list_y[i-1]**2)
  16. w_list_x[i] = w_list_x[i-1] + h*(2*np.pi*R/T)*(-w_list_y[i-1]/R)
  17. w_list_y[i] = w_list_y[i-1] + h*(2*np.pi*R/T)*(w_list_x[i-1]/R)
  18. print("hallo")
  19.  
  20. return w_list_x,w_list_y
  21.  
  22.  
  23. wx,wy = euler(X0,h,t)
  24.  
  25. plt.plot(wx,wy)
  26. plt.show()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement