Skip to content

TestParticle.jl

TestParticle.jl is a flexible tool for tracing charged particles in electromagnetic or body force fields. It supports three-dimensional particle tracking in both relativistic and non-relativistic regimes.

The package handles field definitions in two ways:

  • Analytical Fields: User-defined functions that calculate field values at specific spatial coordinates.

  • Numerical Fields: Discretized fields constructed directly with coordinates or using Meshes.jl and interpolated via Interpolations.jl.

The core trajectory integration is powered by the DifferentialEquations.jl ecosystem, solving the Ordinary Differential Equations (ODEs) of motion.

To accommodate different performance needs, the API provides:

  • In-place versions: Functions ending in !.

  • Out-of-place versions: Functions optimized with StaticArrays. Note that this requires the initial conditions to be passed as a static vector.

For a theoretical background on the physics involved, please refer to Single-Particle Motions.

Installation

julia
julia> ]
pkg> add TestParticle

Usage

Familiarity with the DifferentialEquations.jl workflow is recommended, as TestParticle.jl builds directly upon its ecosystem.

The primary role of this package is to automate the construction of the ODE system based on Newton's second law. This allows users to focus on defining the field configurations and particle initial conditions. For practical demonstrations, please refer to the examples.

In addition to standard integrators, TestParticle.jl includes a native implementation of the Boris solver. It exposes an interface similar to DifferentialEquations.jl for ease of adoption. Further details are provided in the subsequent sections. Check more in examples.

Acknowledgement

Nothing can be done such easily without the support of the Julia community. We appreciate all the contributions from developers around the world.