Skip to content

TCLiuu/TestParticle.jl

This branch is 9 commits ahead of, 203 commits behind henry2004y/TestParticle.jl:master.

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Oct 27, 2023
b247145 · Oct 27, 2023
Oct 27, 2023
Jul 17, 2022
Oct 27, 2023
Oct 27, 2023
Oct 26, 2023
Oct 26, 2023
Apr 23, 2023
Jan 30, 2021
Oct 26, 2023
Oct 26, 2023
Mar 24, 2023

Repository files navigation

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 GLMakie

plot(sol)

More tutorials and examples can be found in the doc.

About

Test particle tracing in static electromagnetic field

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Julia 100.0%