- #1
srecko97
- 82
- 13
Homework Statement
I have a problem with my physics task, but you do not need to understand physics to be able to help me, because my main problem is bad programming skill. I am dealing with a problem of throwing a ball in the air at an angle between 0 an 45 degrees. I need to consider not only the gravity, but also the force of air resistance and Coriolis force. I am treating the movement in x (distance) and in z(height) directions separately using Newton's laws without any problems. So I got 4 arrays with 20000 elements of position in both directions and velocity in both directions: velocity_x, velocity_z, position_x, position_z and an array with angles of velocity, called angles. These arrays are 100% correct. Also all the parameters S, mass, rho, omega, zero are OK. Now I need to deal with the y direction (perpendicular to x and z). Coriolis force moves the ball in the direction of y. Size of Coriolis force depends on the angle between the vector of velocity and angular velocity of Earth and the size of it. The main problem is integrating my movement equation using previously formed arrays. I want to get two new arrays: position_y and velocity_y.
Homework Equations
INTEGRATION ODEINT in PYTHON
The Attempt at a Solution
Python:
# Ty = [y,v_y]
# Ty' = [y',v_y'] y'=v_y
#v_y' = a = -2 * omega *velocity* m.sin(-angle+0.785398163)-v_y/abs(v_y)*0.5*rho*S*v_y**2/mass
#velocity=(velocity_x[n]**2 + velocity_z[n]**2+Ty[1]**2)**0.5
#v_y'=-2 * omega *(velocity_x[n]**2 + velocity_z[n]**2+Ty[1]**2)**0.5 * m.sin(-angles[n]+0.785398163)-Ty[1]/abs(Ty[1])*0.5*rho*S*Ty[1]**2/mass
def dTy_dt (Ty,t):
return[Ty[1],-2 * omega *(velocity_x[n]**2 + velocity_z[n]**2+Ty[1]**2)**0.5 * m.sin(-angles[n]+0.785398163)-Ty[1]/abs(Ty[1])*0.5*rho*S*Ty[1]**2/mass]
Ty0=[0,0]
time=np.linspace(0, zero, 20000)
Tys=integrate.odeint(dTy_dt, Ty0, time)
position_y = Tys[:,0]
velocity_y = Tys[:,1]
Last edited by a moderator: