Advertisement
Guest User

Untitled

a guest
Nov 13th, 2019
150
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.12 KB | None | 0 0
  1. import numpy as np
  2. def dist( angle,m_prop ):
  3.  
  4. t=np.linspace(0,10,1001)
  5. vx=np.zeros((1001,))
  6. vy=np.zeros((1001,))
  7. x=np.zeros((1001,))
  8. y=np.zeros((1001,))
  9. m=90
  10. radians=np.radians(angle)
  11. A=0.8
  12. g=-9.8
  13. mass=65
  14. rho=1.225
  15. C=1.4
  16. initial_height=5
  17. initial_velocity=1500*(m_prop/mass)**0.45
  18.  
  19. y[0]=initial_height
  20. vx[0]=initial_velocity*np.cos(radians)
  21. vy[0]=initial_velocity*np.sin(radians)
  22. for j in range(1,1001):
  23. if y[j-1] <= 0:
  24. vx[j] = 0
  25. vy[j] = 0
  26. y[j] = 0
  27. x[j] = x[j-1]
  28. else:
  29. v = np.sqrt( vx[ j-1 ]**2 + vy[ j-1 ]**2 )
  30. ax = -( 0.5*rho*C*A/mass ) * v**2 * ( vx[ j-1 ] / v )
  31. ay = g-( 0.5*rho*C*A/mass ) * v**2 * ( vy[ j-1 ] / v )
  32. vx[j]=vx[j-1]+ax*(t[j]-t[j-1])
  33. vy[j]=vy[j-1]+ay*(t[j]-t[j-1])
  34. x[j]=x[j-1]+vx[j]*(t[j]-t[j-1])
  35. y[j]=y[j-1]+vy[j]*(t[j]-t[j-1])
  36. if y[j]<=0:
  37. vx[j]=0
  38. vy[j]=0
  39. y[j]=0
  40. x[j]=x[j-1]
  41. return x[-1]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement