0
$\begingroup$

I'm trying to obtain the graph of x(y) from the following system :

enter image description here

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.1, The results should look like this, but y values shouldn't exceed 30-40m, and x 2-5m

dt = 0.02

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 !

$\endgroup$
2
  • 2
    $\begingroup$ part of your problem is that as written, this isn't a differential equation. your first step should be to write it as y'=f(y,t) $\endgroup$ Commented Feb 19 at 15:10
  • $\begingroup$ Your figures are actually the same, but the second has 5x the number of iterations. As Oscar mentioned, this is not a differential equation as written. If this is how the equations are supposed to be, then you are doing things correctly. If they are supposed to be differential equations, then you should be multiplying some stuff one the RHS by $dt$ $\endgroup$
    – whpowell96
    Commented Feb 19 at 17:51

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.