Question: [Python] Write code that describes the motion of charged particles moving through a set of 2 helmholtz coils. This must be done using ordinary differential

[Python]

Write code that describes the motion of charged particles moving through a set of 2 helmholtz coils. This must be done using ordinary differential equations and contain an 2D animation that shows this movement. the code must be well commented and organized. This question is open ended, so these are the only instructions given.

Here is what I have so far, but I don't think it's working properly:

[Python] Write code that describes the motion of charged particles moving through

In [7]: %pylab inline from matplotlib import animation from scipy.integrate import odeint from numpy.linalg import norm from IPython.display import HTML import math Populating the interactive namespace from numpy and matplotlib In [35]: def f(s, t): #initialize variables q = 1.602e-19 #C mue = 4*3.14e-7 #Tm/A I = 2 #A n = 100 #turns of wire v = s[2:2] R = s[2:4] #equations B_coil = (4/5)** (3/2) * (mue*n*I)/R F = q*(v*B_coil) return concatenate([F, B_coil]) so = np.array([1.0,4.0,3.0, 2.0]) ts = linspace(0,10,300) ans = odeint(f, so, ts) In [7]: %pylab inline from matplotlib import animation from scipy.integrate import odeint from numpy.linalg import norm from IPython.display import HTML import math Populating the interactive namespace from numpy and matplotlib In [35]: def f(s, t): #initialize variables q = 1.602e-19 #C mue = 4*3.14e-7 #Tm/A I = 2 #A n = 100 #turns of wire v = s[2:2] R = s[2:4] #equations B_coil = (4/5)** (3/2) * (mue*n*I)/R F = q*(v*B_coil) return concatenate([F, B_coil]) so = np.array([1.0,4.0,3.0, 2.0]) ts = linspace(0,10,300) ans = odeint(f, so, ts)

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!