Question: [Python in Jupyter] The goal is to look at a problem and solve it using ordinary differential equations. The problem is the motion of a
[Python in Jupyter]
The goal is to look at a problem and solve it using ordinary differential equations. The problem is the motion of a charged particle through a set of helmholtz coils.
The function is *supposed* to return the time derivative of the state of the system, which it doesn't. I'm not sure I'm using the right equations either. My thought was to use the magnetic field on an axis through loops of wire and the magnetic force. It's not doing anything close to what it should and I'm not sure how to fix it.
![[Python in Jupyter] The goal is to look at a problem and](https://dsd5zvtm8ll6.cloudfront.net/si.experts.images/questions/2024/09/66f5259305fe3_97066f525929b1d8.jpg)
Motion of charged particle through a set of Helmholtz Coils def func(s, t): vx, vy, vz, x, y, z = s #initialize variables q = 1.602e-19 #C mue_const = le-7 I = 10 #Amps n = 100 #turns of wire in each coil R = .1 v = s[0:3] z = S(3:6] dBdt = mue_const * (2*pi*R**2*I)/(2**2 + R**2) ** (3/2) dFdt = q*(np.cross(v, dBdt)) #print(dBdt) #print(dFdt) return concatenate ([dFdt, dBdt]) S0 = np.array ([1, 1,1,0,0,.1 ]) ts = linspace(0,500,300) ans = odeint(func, so, ts) plot(ans[:,3], ans[:,4]) print(ans) [[1.00000000e+00 1.00000000e+00 1.00000000e+00 0.000000002+00 0.00000000e+00 1.00000000-01] [1.00000000e+00 1.00000000e+00 1.00000000e+00 1.05069882e-04 1.05069882e-04 1.00037138e-01] [1.00000000e+00 1.00000000e+00 1.00000000e+00 2.10139423e-04 2. 10139423e-04 1.00074254e-01] [1.00000000e+00 1.00000000e+00 1.00000000e+00 2.98573927e-02 2.98573927e-02 1.10210268e-01] [1.00000000e+00 1.00000000e+00 1.00000000e+00 2.99497952e-02 2.99497952e-02 1.10242141e-01] [1.00000000e+00 1.00000000e+00 1.00000000e+00 3.00421274e-02 3.00421274e-02 1.10273999e-01]] Motion of charged particle through a set of Helmholtz Coils def func(s, t): vx, vy, vz, x, y, z = s #initialize variables q = 1.602e-19 #C mue_const = le-7 I = 10 #Amps n = 100 #turns of wire in each coil R = .1 v = s[0:3] z = S(3:6] dBdt = mue_const * (2*pi*R**2*I)/(2**2 + R**2) ** (3/2) dFdt = q*(np.cross(v, dBdt)) #print(dBdt) #print(dFdt) return concatenate ([dFdt, dBdt]) S0 = np.array ([1, 1,1,0,0,.1 ]) ts = linspace(0,500,300) ans = odeint(func, so, ts) plot(ans[:,3], ans[:,4]) print(ans) [[1.00000000e+00 1.00000000e+00 1.00000000e+00 0.000000002+00 0.00000000e+00 1.00000000-01] [1.00000000e+00 1.00000000e+00 1.00000000e+00 1.05069882e-04 1.05069882e-04 1.00037138e-01] [1.00000000e+00 1.00000000e+00 1.00000000e+00 2.10139423e-04 2. 10139423e-04 1.00074254e-01] [1.00000000e+00 1.00000000e+00 1.00000000e+00 2.98573927e-02 2.98573927e-02 1.10210268e-01] [1.00000000e+00 1.00000000e+00 1.00000000e+00 2.99497952e-02 2.99497952e-02 1.10242141e-01] [1.00000000e+00 1.00000000e+00 1.00000000e+00 3.00421274e-02 3.00421274e-02 1.10273999e-01]]
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
