TestParticle.jl

Dev Build Status Coverage

This package provides test particle tracing in an analytic or numerical electromagnetic field via DifferentialEquations.jl.

Installation

In the Julia REPL,

julia> ]
pkg> add TestParticle

Visualization via Makie, Plots, and PyPlot are supported. Please refer to each visualization library's documentation for installations.

Usage

TestParticle.jl is designed to work together with OrdinaryDiffEq.jl.

A proton trajectory in a static magnetic field can be traced via

using TestParticle, OrdinaryDiffEq, StaticArrays
# Magnetic field
B(x) = SA[0, 0, 1e-8]
# Electric field
E(x) = SA[0, 0, 0]
# Initial conditions
x0 = [1.0, 0.0, 0.0]
v0 = [0.0, 1.0, 0.1]
stateinit = [x0..., v0...]
tspan = (0, 20)
# Assemble particle + fields
param = prepare(E, B, species=Proton)
prob = ODEProblem(trace!, stateinit, tspan, param)
# Trace trajectory and save positions & velocities
sol = solve(prob, Tsit5(); save_idxs=[1,2,3,4,5,6])

For plotting with Makie,

using TestParticleMakie, GLMakie

plot(sol)

More tutorials and examples can be found in the doc.