My Problem:
A positively charged particle (mass = 2 * 10-27 kg) is moving along the x-axis. It is travelling in a homogenous magnetic field such that the field axis in z-direction. The energy of the particle is 2 MeV and B = 4 T. Use a ODE solver to plot the motion of the particle for 1 microseconds.
My attempt of solving the problem
Note that I have used question marks where I am unsure.
import numpy as np
from scipy.integrate import solve_ivp
initialZ = [?, ?, ?, ?, ?, ?] # = [positionX, positionY, positionZ, velocityX, velocityY, velocityZ]
t0 = 0
tf = 1*(10**-6) # 1 microsecond = 1*10^6 seconds
times = (t0, tf)
def ivf(t, Z):
x, y, z = Z[0], Z[1], Z[2]
u, v, w = Z[3], Z[4], Z[5]
return np.array([u, v, w, ?, ?, ?])
s = solve_ivp(ivf, times, initialZ)
ivf. Also, maybe converting your problem to nondimensional form might prove useful. $\endgroup$