ParticleTracker

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

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.particles.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

astropy.units.Quantity

v

Current velocity. Shape (n, 3).

Type

astropy.units.Quantity

position_history

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

Type

astropy.units.Quantity

velocity_history

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

Type

astropy.units.Quantity

q

Charge of particle.

Type

astropy.units.Quantity

m

Mass of particle.

Type

astropy.units.Quantity

eff_q

Total charge of macroparticle.

Type

astropy.units.Quantity

eff_m

Total mass of macroparticle.

Type

astropy.units.Quantity

Examples

See Particle Stepper Notebook.

Attributes Summary

integrators

kinetic_energy_history

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.

plot_trajectories()

Draw trajectory history.

run()

Run a simulation instance.

test_kinetic_energy()

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

Quantity

Methods Documentation

boris_push(init=False)

Implement 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')

Draw 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()

Draw trajectory history.

run()

Run a simulation instance.

test_kinetic_energy()

Test conservation of kinetic energy.