ParticleTracker

class plasmapy.simulation.particletracker.ParticleTracker(plasma, particle_type='p', n_particles=1, scaling=1, dt=<Quantity inf s>, nt=inf)

Bases: object

Object representing a species of particles: ions, electrons, or simply a group of particles with a particular initial velocity distribution.

Parameters:
  • plasma (Plasma) – plasma from which fields can be pulled
  • type (str) – particle type. See plasmapy.atomic.atomic 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) – length of timestep
  • nt (int) – number of timesteps
x
Type:astropy.units.Quantity
v

Current position and velocity, respectively. Shape (n, 3).

Type:astropy.units.Quantity
position_history
Type:astropy.units.Quantity
velocity_history

History of position and velocity. Shape (nt, n, 3).

Type:astropy.units.Quantity
q
Type:astropy.units.Quantity
m

Charge and mass of particle.

Type:astropy.units.Quantity
eff_q
Type:astropy.units.Quantity
eff_m

Total charge and mass of macroparticle.

Type:astropy.units.Quantity
kinetic_energy

calculated from v, as in, current velocity.

kinetic_energy_history

calculated from velocity_history.

Examples

See plasmapy/examples/particle-stepper.ipynb.

Attributes Summary

kinetic_energy_history Calculates the kinetic energy history for each particle.

Methods Summary

boris_push([init]) Implements the Boris algorithm for moving particles and updating their velocities.
plot_time_trajectories([plot]) Draws position history versus time.
plot_trajectories() Draws trajectory history.
run() Runs a simulation instance.
test_kinetic_energy() Test conservation of kinetic energy.

Attributes Documentation

kinetic_energy_history

Calculates the kinetic energy history for each particle.

Returns:Array of kinetic energies, shape (nt, n).
Return type:Quantity

Methods Documentation

boris_push(init=False)

Implements the Boris algorithm for moving particles and updating their velocities.

Parameters:init (bool (optional)) – If True, does not change the particle positions and sets dt to -dt/2.

Notes

The Boris algorithm is the standard energy conserving algorithm for particle movement in plasma physics. See [1] for more details.

Conceptually, the algorithm has three phases:

  1. Add half the impulse from electric field.
  2. Rotate the particle velocity about the direction of the magnetic field.
  3. 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.

References

[1]C. K. Birdsall, A. B. Langdon, “Plasma Physics via Computer Simulation”, 2004, p. 58-63
plot_time_trajectories(plot='xyz')

Draws position history versus time.

Parameters:plot (str (optional)) – Enable plotting of position component x, y, z for each of these letters included in plot.
plot_trajectories()

Draws trajectory history.

run()

Runs a simulation instance.

test_kinetic_energy()

Test conservation of kinetic energy.