EPOCH is a code for plasma physics simulations using the Particle-in-Cell method. The simulation results are written is
.sdf binary files. Several readers for this files are available at https://cfsa-pmw.warwick.ac.uk/SDF.
This package intends to help users read and analyse EPOCH simulations.
Install the package using
Assuming that you have a folder with
.sdf files generated from
an EPOCH simulation, use
read_simulation to read the metadata
for the simulation. You can index into the resulting object and access
individual simulation files. Note that by default EPOCH starts indexing
form 0, while in Julia we usually start from 1.
using SDFReader dir = "my_simulation" sim = read_simulation(dir) sim # corresponds to the first sdf file (usually 0000.sdf).
keys function you can observe what data was saved in the
simulation. The symbols correspond to the names used for the
saved variables. Note that some identifiers used by EPOCH, such
as the ones for species properties are not valid julia symbols
px/electron), so instead you can use strings (e.g.
In order to read the data for scalar field quantities such as
you can simply index into the file
file = sim Ex = file[:ex]
The returned object will be a
ScalarVariable for the components
of particle variables such as
"px/electron") and will contain the information
regarding the data (with units via Unitful.jl)
and the corresponding coordinate values.
These objects are
AbstractArrays and via indexing you can access the stored values.
You can use broadcasting to compute derived quantities. For example, to compute the x component of the angular momentum you can simply use
function compute_Lx(file) w, r, py, pz = file["weight/electron", "grid/electron", "py/electron", "pz/electron"] y = r z = r Lx = @. w * (y * pz - z * py) end
You can also acces the (simulation) time corresponding to a file with
and also the parameters from the
input.deck file with
input.deck parser only supports simple
key=value expressions (no arithmetic operations or function calls).
You can also access nested values by providing a second argument.
nx = get_parameter(file, :nx) λ = get_parameter(file, :laser, :lambda)