ParticleTracker
- class plasmapy.simulation.particletracker.ParticleTracker(plasma, particle_type='p', n_particles=1, scaling=1, dt=<Quantity inf s>, nt=inf, integrator='explicit_boris')[source]
Bases:
object
Object representing a species of particles: ions, electrons, or simply a group of particles with a particular initial velocity distribution.
Attention
This functionality is under development. Backward incompatible changes might occur in future releases.
- Parameters:
plasma (Plasma object) – Plasma from which fields can be pulled.
type (
str
) – Particle type. Seeplasmapy.particles.particle_class.ParticleLike
for suitable arguments. The default is a proton.n_particles (
int
) – Number of macroparticles. The default is a single particle.scaling (
float
) – Number of particles represented by each macroparticle. The default is 1, which means a \(1:1\) correspondence between particles and macroparticles.dt (
astropy.units.Quantity
) – Duration of timestep.nt (
int
) – Number of timesteps.
- x
Current position. Shape (n, 3).
- Type:
- v
Current velocity. Shape (n, 3).
- Type:
- position_history
History of position. Shape (nt, n, 3).
- Type:
- velocity_history
History of velocity. Shape (nt, n, 3).
- Type:
- q
Charge of particle.
- Type:
- m
Mass of particle.
- Type:
- eff_q
Total charge of macroparticle.
- Type:
- eff_m
Total mass of macroparticle.
- Type:
Examples
See Particle Stepper Notebook.
Attributes Summary
Calculate the kinetic energy history for each particle.
Methods Summary
boris_push
([init])Implement the Boris algorithm for moving particles and updating their velocities.
plot_time_trajectories
([plot])Draw position history versus time.
Draw trajectory history.
run
()Run a simulation instance.
Test conservation of kinetic energy.
Attributes Documentation
- integrators = {'explicit_boris': <function boris_push>}
- kinetic_energy_history
Calculate the kinetic energy history for each particle.
- Returns:
Array of kinetic energies, shape (nt, n).
- Return type:
Methods Documentation
- boris_push(init=False)[source]
Implement the Boris algorithm for moving particles and updating their velocities.
- Parameters:
init (
bool
, optional) – IfTrue
, does not change the particle positions and setsdt
to-dt/2
.
Notes
The Boris algorithm [Boris, 1970] is the standard energy particle movement in plasma physics. See pages 58–63 of Birdsall and Langdon [2004] for more details.
Conceptually, the algorithm has three phases:
Add half the impulse from electric field.
Rotate the particle velocity about the direction of the magnetic field.
Add the second half of the impulse from the electric field.
This ends up causing the magnetic field action to be properly “centered” in time, and the algorithm conserves energy.