Guest User

Untitled

a guest
Feb 17th, 2018
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.43 KB | None | 0 0
  1. import numpy as np
  2. import matplotlib.pyplot as plt
  3.  
  4. g = 9.80 #the Constant acceleration of an object close to the surface of the earth.
  5. v0 = 700 #Initial velocity in meters per second.
  6. x=[0]
  7. y=[0]#the string keeping track of the position along the y axis starting with 0.
  8. t=[0] # the string keeping track of the times measured in each time step starting with 0.
  9. a=[g] #the string containing the different velocities in each step,velocity in the situation stays the same.
  10.  
  11. dt = 0.10 #the change in time between each value in the above strings
  12.  
  13. for i in range(0,5,5):
  14. angle=((i)+30)*(np.pi/180)
  15. vx=[v0*np.cos(angle)]
  16. vy=[v0*np.sin(angle)] #the string keeping track of the velocity.
  17.  
  18. #the following loops statement appends values to all of the
  19. #following strings using the Euler method while the current y position is greater than or equal to 0.
  20. while y[-1] >= 0:
  21. x.append(x[-1]+vx[-1]*dt)
  22. vx.append(vx[-1])
  23. y.append(y[-1]+vy[-1]*dt)
  24. vy.append(vy[-1]-g*dt)
  25. t.append(t[-1]+dt)
  26. a.append(g)
  27.  
  28. while i <= 25:
  29. plt.plot(x,y)
  30. x=[0]
  31. y=[0]#the string keeping track of the position along the y axis starting with 0.
  32. t=[0] # the string keeping track of the times measured in each time step starting with 0.
  33. a=[g] #the string containing the different velocities in each step,velocity in the situation stays the same.
  34.  
  35.  
  36. plt.show()
Advertisement
Add Comment
Please, Sign In to add comment