About
Developed by E. Behringer
This set of exercises guides the students to compute and analyze the behavior of a charged particle in a spatial region with mutually perpendicular electric and magnetic fields. It requires the student to determine the Cartesian components of hte forces acting on the particle and to obtain the corresponding equations of motion. The solutions to these equations are obtained through numerical integation, and the capstone exercise is the simulation of the (Wien) filter.
| Subject Area | Electricity & Magnetism |
|---|---|
| Levels | First Year and Beyond the First Year |
| Available Implementation | Python |
| Learning Objectives |
Students who complete this set of exercises will be able to:
|
| Time to Complete | 120 min |
EXERCISE 4: THE (WIEN) FILTER, PART 2
As an extension of Exercise 3, now assume that the particles entering the field region at the origin have a normal distribution of velocities directed purely along the -axis. The center of the distribution is and its width is .
(a) Allow particles from this distribution to enter the field region at the origin. What is the resulting histogram of the scaled velocities of the particles transmitted through a circular aperture of radius mm centered on the -axis? How does it compare to the histogram of the initial velocities?
(b) Repeat part (a) for an aperture of radius mm.
It is worth noting that an actual source of ions will not only be characterized by a distribution of velocities, but also distribution of directions (no ion beam is strictly mono-directional, just like a laser beam is not strictly mono-directional). This is an additional fact that would have to be considered to accurately simulate the performance of a real Wien filter.
#
# ExB_Filter_Exercise_4.py
#
# This file is used to numerically integrate
# the second order linear differential equations
# that describe the trajectory of a charged particle through
# an E x B velocity filter.
#
# Here, it is assumed that the axis of the filter
# is aligned with the z-axis, that the magnetic field
# is along the +x-direction, and that the electric field
# is along the -y-direction.
#
# The numerical integration is done using the built-in
# routine odeint.
#
# Many particles selected from a normal distribution of
# z-velocities are sent through the filter and histograms
# of the z-velocities of the incident and transmitted particles
# are produced.
#
# By:
# Ernest R. Behringer
# Department of Physics and Astronomy
# Eastern Michigan University
# Ypsilanti, MI 48197
# (734) 487-8799 (Office)
# This email address is being protected from spambots. You need JavaScript enabled to view it.
#
# Last updated:
#
# 20160624 ERB
#
from pylab import figure,xlim,xlabel,ylim,ylabel,grid,title,hist,show,text
from numpy import sqrt,array,arange,random,absolute,zeros,linspace
from scipy.integrate import odeint
#
# Initialize parameter values
#
q = 1.60e-19 # particle charge [C]
m = 7.0*1.67e-27 # particle mass [kg]
KE_eV = 100.0 # particle kinetic energy [eV]
Ex = 0.0 # Ex = electric field in the +x direction [N/C]
Ey = -105.0 # Ey = electric field in the +y direction [N/C]
Ez = 0.0 # Ez = electric field in the +z direction [N/C]
Bx = 0.002 # Bx = magnetic field in the +x direction [T]
By = 0.0 # By = magnetic field in the +x direction [T]
Bz = 0.0 # Bz = magnetic field in the +x direction [T]
R_mm = 0.5 # R = radius of the exit aperture [mm]
L = 0.25 # L = length of the crossed field region [mm]
Ntraj = 40000 # number of trajectories
transmitted_v = zeros(Ntraj) # array to save velocities of transmitted particles
n_transmitted = 0 # counter for the number of transmitted particles
# Derived quantities
qoverm = q/m # charge to mass ratio [C/kg]
KE = KE_eV*1.602e-19 # particle kinetic energy [J]
vmag = sqrt(2.0*KE/m) # particle velocity magnitude [m/s]
R = 0.001*R_mm # aperture radius [m]
vzpass = -Ey/Bx # z-velocity for zero deflection [m/s]
# Set up the distribution of incident velocities
mean = vzpass # the mean of the velocity distribution is vzpass
sigma = 0.1*vzpass # the width of the velocity distribution is 0.1*vzpass
vz = mean + sigma*random.randn(Ntraj) # the set of initial velocity magnitudes
scaled_vz = vz/vzpass # the set of scaled initial velocity magnitudes
# Set up the bins for the histograms
scaled_vz_min = 0.6
scaled_vz_max = 1.4
Nbins = 64
scaled_vz_bins = linspace(scaled_vz_min,scaled_vz_max,Nbins+1)
vz_bins = vzpass*scaled_vz_bins
#
# Over what time interval do we integrate?
#
tmax = L/vzpass;
#
# Specify the time steps at which to report the numerical solution
#
t1 = 0.0 # initial time
t2 = tmax # final scaled time
N = 1000 # number of time steps
h = (t2-t1)/N # time step size
# The array of time values at which to store the solution
tpoints = arange(t1,t2,h)
# Specify initial conditions that don't change
x0 = 0.0 # initial x-coordinate of the charged particle [m]
dxdt0 = 0.0 # initial x-velocity of the charged particle [m/s]
y0 = 0.0 # initial y-coordinate of the charged particle [m]
dydt0 = 0.0 # initial y-velocity of the charged particle [m/s]
z0 = 0.0 # initial z-coordinate of the charged particle [m]
#
# Here are the derivatives of position and velocity
def derivs(r,t):
# derivatives of position components
xp = r[1]
yp = r[3]
zp = r[5]
dx = xp
dy = yp
dz = zp
# derivatives of velocity components
ddx = qoverm*(Ex + yp*Bz - zp*By)
ddy = qoverm*(Ey + zp*Bx - xp*Bz)
ddz = qoverm*(Ez + xp*By - yp*Bx)
return array([dx,ddx,dy,ddy,dz,ddz],float)
# Start the loop over the initial velocities
for i in range (0,Ntraj-1):
# Specify initial conditions
dzdt0 = vz[i] # initial z-velocity of the charged particle [m/s]
r0 = array([x0,dxdt0,y0,dydt0,z0,dzdt0],float)
# Calculate the numerical solution using odeint
r = odeint(derivs,r0,tpoints)
# Extract the 1D matrices of position values
position_x = r[:,0]
position_y = r[:,2]
position_z = r[:,4]
# Extract the 1D matrices of velocity values and final velocity
v_x = r[:,1]
v_y = r[:,3]
v_z = r[:,5]
vxf = v_x[N-1]
vyf = v_y[N-1]
vzf = v_z[N-1]
vf = sqrt(vxf*vxf + vyf*vyf + vzf*vzf)
# If the particle made it through the aperture, save the velocity
if absolute(position_x[N-1]) < R:
if absolute(position_y[N-1]) < sqrt(R*R - position_x[N-1]*position_x[N-1]):
transmitted_v[n_transmitted] = vf
n_transmitted = n_transmitted + 1
# Only save the non-zero values for the histogram
transmitted_v_f = transmitted_v[0:n_transmitted]
scaled_transmitted_v_f = transmitted_v_f/vzpass
# Let the user know how many particles were transmitted
print("The number of incident particles is %d"%Ntraj) #Frem: Added Brackets
print("The number of transmitted particles is %d"%n_transmitted) #Frem: Added Brackets
# start a new figure
figure()
# plot the histogram of scaled initial velocities
n, bins, patches = hist(scaled_vz, scaled_vz_bins, normed=0, facecolor='orange', alpha=0.75)
xlabel('\(v_z/v_{z,pass}\) [m/s]',size = 16)
ylabel('\(N\)',size = 16)
title('Histogram of initial \(v_z/v_{z,pass}\) values')
xlim(scaled_vz_min,scaled_vz_max)
ylim(0,0.075*Ntraj)
grid(True)
show()
# start a new figure
figure()
# plot the histogram of scaled final velocities (transmitted particles)
n, bins, patches = hist(scaled_transmitted_v_f, scaled_vz_bins, normed=0, facecolor='purple', alpha=0.75)
xlabel('\(v_z/v_{z,pass}\)',size = 16)
ylabel('\(N\)',size = 16)
title('Histogram of \(v_z/v_{z,pass}\) values for transmitted particles')
xlim(scaled_vz_min,scaled_vz_max)
ylim(0,0.075*Ntraj)
grid(True)
text(0.65,2750,"R = %.2f mm"%R_mm,size=16)
show()
Translations
| Code | Language | Translator | Run | |
|---|---|---|---|---|
![]() |
||||
Credits

Fremont Teng; Loo Kang Wee
Sample Learning Goals
[text]
For Teachers
[text]
Research
[text]
Video
[text]
Version:
- https://www.compadre.org/PICUP/exercises/Exercise.cfm?A=ExB_Filter&S=6
- http://weelookang.blogspot.com/2018/06/wien-e-x-b-filter-exercise-123-and-4.html
Other Resources
[text]
end faq
{accordionfaq faqid=accordion4 faqclass="lightnessfaq defaulticon headerbackground headerborder contentbackground contentborder round5"}
Study Guide: Wien Filter Simulation
Key Concepts
- Wien Filter (E x B Filter): A device that uses perpendicular electric (\(\vec{E}\)) and magnetic (\(\vec{B}\)) fields to select charged particles based on their velocity.
- Forces on a Charged Particle in Electromagnetic Fields: A charged particle moving in electric and magnetic fields experiences a Lorentz force, given by \(\vec{F} = q(\vec{E} + \vec{v} \times \vec{B})\), where \(q\) is the charge and \(\vec{v}\) is the velocity of the particle.
- Equations of Motion: Newton's second law (\(\vec{F} = m\vec{a}\)) applied to a charged particle in electromagnetic fields leads to differential equations describing its motion. These equations relate the particle's acceleration to the forces acting on it.
- Velocity Selector: In a Wien filter, for a specific velocity, the electric and magnetic forces are equal and opposite, resulting in zero net force and allowing particles with this velocity to pass through undeflected. This occurs when \(qE = qvB\), or \(v = E/B\).
- Numerical Integration: A method used to approximate the solution of differential equations when analytical solutions are not feasible. The odeint routine in Python is an example of a numerical integration technique.
- Cartesian Components: The \(x\), \(y\), and \(z\) components of vectors, such as force, velocity, and position. Analyzing the forces and motion in terms of their Cartesian components simplifies the problem.
- Particle Trajectory: The path followed by a charged particle as it moves through space under the influence of forces. In a Wien filter, the trajectory depends on the initial velocity of the particle and the strengths and directions of the electric and magnetic fields.
- Normal Distribution of Velocities: A common probability distribution where values are clustered around the mean, with fewer values occurring further away from the mean. This is characterized by a mean (\(\mu\)) and a standard deviation (\(\sigma\)).
- Histogram: A graphical representation of the distribution of numerical data, where the data is grouped into bins, and the height of each bar corresponds to the frequency of data within that bin.
- Aperture: An opening that restricts the passage of particles. In the Wien filter simulation, a circular aperture at the exit determines which particles are transmitted.
Quiz
- Describe the orientation of the electric and magnetic fields in the Wien filter simulation model based on the provided Python code comments. What is the consequence of this configuration on a positively charged particle moving along the z-axis?
- Explain the condition required for a charged particle to pass through the Wien filter undeflected. How is this condition mathematically expressed in terms of the electric field (Ey) and magnetic field (Bx) in the given simulation?
- What is the purpose of numerically integrating the equations of motion for the charged particles in this simulation? Why is a numerical method like odeint necessary here?
- According to Exercise 4, what is the initial condition for the velocities of the particles entering the Wien filter? How are these velocities characterized in the simulation?
- Explain the role of the parameters mean and sigma in setting up the distribution of incident velocities in the Python code. How do these parameters affect the range of initial velocities?
- What physical quantity does the code variable vzpass represent? How is it calculated from the electric and magnetic field parameters?
- Describe the criteria used in the Python code to determine whether a particle is transmitted through the Wien filter. What conditions must be met at the end of the simulation time?
- What is the purpose of generating histograms of the scaled velocities in Exercise 4? What two sets of velocities are compared using these histograms?
- How does changing the radius of the exit aperture affect the number and range of particle velocities that are transmitted through the Wien filter, as explored in parts (a) and (b) of Exercise 4?
- What additional factor, beyond the distribution of velocities, could affect the performance of a real Wien filter, as mentioned in the text?
Quiz Answer Key
- The magnetic field is along the +x-direction (Bx > 0), and the electric field is along the -y-direction (Ey < 0). For a positively charged particle moving along the +z-axis, the electric force will be in the -y direction, and the magnetic force (\(\vec{v} \times \vec{B}\)) will be in the +y direction.
- For a charged particle to pass undeflected, the net force in the x and y directions must be zero. In this configuration, this primarily means the electric force and the magnetic force in the y-direction must cancel out. Mathematically, this occurs when \(vzpass = -Ey/Bx\).
- Numerical integration is necessary to find the trajectories of the charged particles because the equations of motion, which involve both electric and magnetic forces dependent on velocity, can be complex to solve analytically, especially for a distribution of initial velocities. odeint provides an algorithm to approximate the particle's position and velocity over time by taking small time steps.
- The particles entering the field region at the origin have a normal distribution of velocities directed purely along the z-axis. This distribution is characterized by a mean velocity (\(v_{z,pass}\)) and a width (related to the standard deviation, 0.1 * \(v_{z,pass}\)).
- The mean parameter sets the average value of the z-velocity distribution, which is equal to vzpass (the velocity for zero deflection). The sigma parameter defines the standard deviation of the distribution, which determines the spread or width of the velocities around the mean.
- The code variable vzpass represents the z-velocity at which a charged particle experiences zero net deflection in the Wien filter due to the balanced electric and magnetic forces. It is calculated as vzpass = -Ey/Bx.
- A particle is considered transmitted if, at the final time step (when it should have exited the field region), its x-coordinate and y-coordinate are both within the bounds of the circular aperture of radius R centered on the z-axis. The conditions are absolute(position_x[N-1]) < R and absolute(position_y[N-1]) < sqrt(R*R - position_x[N-1]*position_x[N-1]).
- The histograms of the scaled velocities (\(v_z/v_{z,pass}\)) are generated to visualize the distribution of initial z-velocities of all the particles and to compare it with the distribution of z-velocities of only those particles that successfully passed through the filter. This helps determine the filter's velocity selection properties.
- A smaller aperture radius (R = 0.5 mm compared to R = 1.0 mm) will likely result in fewer particles being transmitted, as the spatial constraint at the exit is tighter. It might also lead to a narrower range of transmitted velocities, as only particles with trajectories closer to the z-axis will be able to pass through the smaller opening.
- An actual source of ions will also have a distribution of directions, meaning the initial velocities will not be perfectly aligned along the z-axis. This angular spread of the ion beam would need to be considered for a more accurate simulation of a real Wien filter's performance.
Essay Format Questions
- Discuss the fundamental principles behind the operation of a Wien filter as a velocity selector for charged particles. Explain how the perpendicular electric and magnetic fields interact with moving charges and under what conditions a specific velocity is selected.
- Explain the process of setting up and executing a simulation to model the behavior of charged particles in a Wien filter. Describe the key steps involved, including defining the fields, setting initial conditions for a distribution of particles, and numerically integrating the equations of motion.
- Analyze the factors that influence the velocity resolution of a Wien filter. How do the strengths of the electric and magnetic fields, the geometry of the filter (length, aperture size), and the initial velocity distribution of the particles affect the range of velocities that are transmitted?
- The provided exercise investigates the transmission of particles with a normal distribution of initial velocities through a Wien filter with different aperture sizes. Discuss the expected outcomes of this investigation and how the histograms of initial and transmitted velocities would differ. What conclusions can be drawn about the filter's selectivity from these results?
- Evaluate the limitations of the simulation model described in the excerpts in representing a real-world Wien filter. What additional physical factors or complexities might need to be considered for a more comprehensive and accurate simulation of such a device?
Glossary of Key Terms
- Charged Particle: A subatomic particle, such as an electron or ion, that carries an electric charge.
- Electric Field (\(\vec{E}\)): A region of space around an electrically charged particle or object in which a force would be exerted on other electrically charged particles or objects. Measured in Newtons per Coulomb (N/C).
- Magnetic Field (\(\vec{B}\)): A field of force produced by moving electric charges and intrinsic magnetic moments of elementary particles that exerts a force on other moving charges. Measured in Tesla (T).
- Lorentz Force: The force exerted on a charged particle in an electromagnetic field, given by \(\vec{F} = q(\vec{E} + \vec{v} \times \vec{B})\).
- Velocity (\(\vec{v}\)): The rate of change of an object's position with respect to a frame of reference, and is a function of time. It is a vector quantity, having both magnitude (speed) and direction. Measured in meters per second (m/s).
- Trajectory: The path traced by a moving object in space as a function of time.
- Numerical Integration: A set of algorithms for calculating the numerical value of a definite integral, and more broadly, for solving differential equations numerically.
- Cartesian Coordinates: A coordinate system that specifies each point uniquely in a plane by a set of numerical coordinates, which are the signed distances to the point from two fixed perpendicular oriented lines, measured in the same unit of length. In three dimensions, three perpendicular planes are used.
- Normal Distribution: A probability distribution that is symmetric about the mean, showing that data near the mean are more frequent in occurrence than data far from the mean. Also known as the Gaussian distribution or bell curve.
- Histogram: A graphical representation of the distribution of numerical data.
- Aperture: An opening or hole, often used to control the amount of something (like particles or light) that passes through.
- Simulation Model: A representation or imitation of a real-world system, used to study its behavior without actually experimenting with the real system.
- Equations of Motion: Mathematical equations that describe the physical movement of a system of physical entities as a function of time.
- Deflection: The act or state of being turned aside from a straight course or fixed direction.
- Velocity Selector: A device using orthogonal electric and magnetic fields to select charged particles with a specific velocity.
- Details
- Written by Fremont
- Parent Category: 05 Electricity and Magnetism
- Category: 08 Electromagnetism
- Hits: 6410






