Outputs
Simulations in HallThruster.jl output Solution
objects. These contain the simulation's state at all requested timesteps in addition to the inputs the simulation was run with. The outputs are organized into Frame
objects, which contain arrays of data for all plasma properties of interest, as well as SpeciesState
objects, grouped by neutral species and ion species.
Types
HallThruster.Solution
— Typestruct Solution{T, C<:HallThruster.Config, CC<:HallThruster.CurrentController}
The solution of a simulation, returned by run_simulation
. These can be passed to any of the postprocessing functions described in Postprocessing, or indexed to extract specific values.
Indexing
There are a few ways to index a solution. First, you can extract a solution containing a single Frame
by indexing the Solution
by an integer.
julia> solution = het.run_simulation(config, simparams)
Hall thruster solution with 101 saved frames (retcode: success, end time: 0.001 seconds)
julia> solution[51]
Hall thruster solution with 1 saved frame (retcode: success, end time: 0.0005 seconds)
Second, you can index a solution by a vector or vector-like object to extract a range of frames
julia> solution[51:end] # get last 51 frames
Hall thruster solution with 51 saved frames (retcode: success, end time: 0.001 seconds)
julia> solution[begin:2:end] # get every other frame
Hall thruster solution with 51 saved frames (retcode: success, end time: 0.001 seconds)
julia> solution[[1, 51, 101]] # get only frames 1, 51, 101
Hall thruster solution with 3 saved frames (retcode: success, end time: 0.001 seconds)
Lastly, you can obtain plasma properties by indexing into the frames contained in the solution
julia> solution.frames[4].Tev; # Electron temperature at fourth frame
julia> solution.frames[end].ions[:Xe][1].u; # Ion velocity of Xenon+ at last frame
julia> solution.frames[end].neutrals[:Xe].n; # Number density of neutral Xenon
For a list of valid fields in a Frame
, call fieldnames(HallThruster.Frame)
Fields
t::Any
: A vector of times (in seconds) at which simulation output has been saved
frames::Vector{HallThruster.Frame}
: A vector ofFrame
objects representing snapshots of the simulation state, at the times specified int
grid::HallThruster.Grid1D
: The grid used for the simulation
config::HallThruster.Config
: TheConfig
used to run the simulation
simulation::HallThruster.SimParams
: The simulation parameters
postprocess::HallThruster.Postprocess
: The postprocessing arguments
retcode::Symbol
: The solution return code. This can be one of three values::success
: the simulation completed successfully.:failure
: the simulation failed due to a numerical issue or instability, resulting in aNaN
orInf being detected somewhere in the solution
:error
: another error occurred. Check theerror
string to see what kind of error.
error::String
: Holds to error text and backtrace, if an error occurred. Empty ifsol.retcode != :error
.
HallThruster.Frame
— Typestruct Frame
A snapshot of the simulation state at a single time, obtained by indexing the frames
field of a Solution
object. Both neutral and ion species properties are stored as SpeciesState
objects in a dictionary. To access one of these objects, index by the symbol of that propellant and (if an ion species) the charge state. For example, the number density of doubly-charged Xenon would be accessed as frame.ions[:Xe][1].n
.
Fields
neutrals::OrderedCollections.OrderedDict{Symbol, HallThruster.SpeciesState}
: Dictionary containing neutral species. Indexed by that species' symbol.ions::OrderedCollections.OrderedDict{Symbol, Vector{HallThruster.SpeciesState}}
: Dictionary containing ion species. Indexed by the species' symbol, followed by charge state.B::Vector{Float64}
: Magnetic field strength (T)ne::Vector{Float64}
: Plasma density (1/m^3)ue::Vector{Float64}
: Electron velocity (m/s)ji::Vector{Float64}
: Ion current (A/m^2)E::Vector{Float64}
: Electric field (V/m)Tev::Vector{Float64}
: Electron temperature (eV)pe::Vector{Float64}
: Electron pressure (eV/m^3)grad_pe::Vector{Float64}
: Electron pressure gradient (eV/m^4)potential::Vector{Float64}
: Electrostatic potential (V)mobility::Vector{Float64}
: Electron mobilitynu_an::Vector{Float64}
: Anomalous collision frequency (1/s)nu_en::Vector{Float64}
: Electron-neutral collision frequency (1/s)nu_ei::Vector{Float64}
: Electron-ion collision frequency (1/s)nu_wall::Vector{Float64}
: Electron-wall collision frequency (1/s)nu_class::Vector{Float64}
: Total electron classical collision frequency (1/s)nu_iz::Vector{Float64}
: Total electron ionization collision frequency (1/s)nu_ex::Vector{Float64}
: Total electron excitation collision frequency (1/s)nu_e::Vector{Float64}
: Total electron momentum transfer collision frequency (1/s)channel_area::Vector{Float64}
: Cross-sectional area of discharge (m^2)dA_dz::Vector{Float64}
: Cross sectional area gradient (m^2 / m)tan_div_angle::Vector{Float64}
: Tangent of plume divergence angleanom_variables::Vector{Vector{Float64}}
: Auxilliary anomalous transport variable cachesanom_multiplier::Array{Float64, 0}
: Anomalous transport multiplier from PID controllerdischarge_current::Array{Float64, 0}
: Discharge current (A)dt::Array{Float64, 0}
: SImulation timestep (s)
HallThruster.SpeciesState
— Typestruct SpeciesState
The properties of a heavy species (neutrals or ions).
Fields
n::Vector{Float64}
: Number density (1/m^3)nu::Vector{Float64}
: Number flux (1/m^2 s)u::Vector{Float64}
: Average velocity (m/s)m::Float64
: Molecular weight (kg)Z::Int64
: Charge number
Functions
HallThruster.write_to_json
— Functionwrite_to_json(
file::String,
sol::HallThruster.Solution;
average_start_time,
save_time_resolved
)
Write sol
to file
, if file
is a JSON file.
Mandatory arguments
file
: the file to which we write the solutionsol
: theSolution
object to be written
Optional keyword args
average_start_time
= -1: the time at which averaging begins. If < 0, no averaged output is written.save_time_resolved
= true: Whether to save all frames of the simulation. Iffalse
, no time-resolved output is written.
HallThruster.valid_fields
— Functionvalid_fields()
Returns a Tuple
of symbols containing fields that can be obtained by indexing a Solution
by a Symbol
. This contains fields actually saved in a frame, in addition to special fields like :z
and :B
, as well as alternate field names for fields with special characters in their names (see HallThruster.alternate_field_names()
for more)
julia> HallThruster.valid_fields()
(:z, :neutrals, :ions, :B, :ne, :ue, :ji, :E, :Tev, :pe, :grad_pe, :potential, :mobility, :nu_an, :nu_en, :nu_ei, :nu_wall, :nu_class, :nu_iz, :nu_ex, :nu_e, :channel_area, :dA_dz, :tan_div_angle, :anom_variables, :anom_multiplier, :discharge_current, :dt, :E, :ωce, :cyclotron_freq, :ni, :ui, :niui, :nn, :μ, :ϕ, :∇pe, :νan, :nu_anom, :νc, :νei, :νen, :νiz, :νex, :tanδ)
HallThruster.alternate_field_names
— Functionalternate_field_names()
Returns a NamedTuple
of mappings between alternate ascii field names and field names with special characters. These can be used when indexing Solution
objects instead of the short names.
Usage
julia> HallThruster.alternate_field_names()
(μ = :mobility, ϕ = :potential, ∇pe = :grad_pe, νan = :nu_an, nu_anom = :nu_a, νc = :nu_class, νei = :nu_ei, νen = :nu_en, νiz = :nu_iz, νex = :nu_ex, tanδ = :tan_div_angle)
Base.getindex
— Methodgetindex(
sol::HallThruster.Solution,
frame::Integer
) -> HallThruster.Solution{T} where T<:(Vector)
Return a solution where frames = [sol.frames[frame]]
and [t = sol.t[frame]]
All other fields remain unchanged.
Base.getindex
— Methodgetindex(
sol::HallThruster.Solution,
frames::AbstractVector
) -> HallThruster.Solution
Return a solution where result.frames = sol.frames[frames] and result.t = sol.t[frames].
This can be used to extract a contiguous slice of frames (by passing in a range like 50:end
) or a discrete sub-selection of frames (by passing in a vector like [1, 51, 100]
)