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, Z, Z u, v, w = Z, Z, Z return np.array([u, v, w, ?, ?, ?]) s = solve_ivp(ivf, times, initialZ)