I'm trying to obtain the graph of x(y) from the following system :
Therefore I tried to solve this system using an Euler Method :
def euler_method(v0, j0, phi0, dt):
v_values = [v0]
j_values = [j0]
phi_values = [phi0]
vx_values = np.multiply(v_values, np.sin(phi_values)).tolist()
vy_values = np.multiply(v_values, np.cos(phi_values)).tolist()
x_values = [0]
y_values = [0]
while v_values[-1] > 0.01:
slope_v = -µ * g * dt * (v_values[-1]**(-1/2))
v_new = v_values[-1] + dt * slope_v
j_new = j_values[-1] + v_new * dt * K
phi_new = M * (j_new)
vx_new = v_new*np.sin(phi_new)
vy_new = v_new*np.cos(phi_new)
x_new = x_values[-1]+vx_new*dt
y_new = y_values[-1]+vy_new*dt
v_values.append(v_new)
j_values.append(j_new)
phi_values.append(phi_new)
vx_values.append(vx_new)
vy_values.append(vy_new)
x_values.append(x_new)
y_values.append(y_new)
return v_values, phi_values, vx_values, vy_values, x_values, y_values
But this method doesn't seem to work, because when I tried with two different sets of dt interval, I have very different results :
dt = 0.1, The results should look like this, but y values shouldn't exceed 30-40m, and x 2-5m
dt = 0.02
I used the initial conditions : euler_method(2.2, 0, 0, dt)
I don't understand because a change in the interval dt shouldn't have such an impact.
I wonder if solving this system as I did is really the way to do, I'd be interested to know what is wrong here,
Thanks !