TestParticle.jl
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. Native particle pusher also follows a similar interface.
For example, a proton 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.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, Vern9())
For plotting with Makie,
using GLMakie
plot(sol)
More tutorials and examples can be found in the doc.