Solutions

Types

HallThruster.SolutionType
struct Solution{T, P, C, S}

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 index by a symbol or [Symbol, Integer] to get plasma data for all frames in that solution

solution[:ni, 1] 	# get ion density of first charge state for all frames
solution[:ui] 		# get ion velocity for all charge states and frames

# These return the same thing
solution[:∇pe]
solution[:grad_pe]

For a list of valid fields to index by, call HallThruster.valid_fields() For a list of alternate names for fields containing special characters, call HallThruster.alternate_field_names()

See the documentation for Base.getindex(sol::Solution, field::Symbol) and Base.getindex(sol::Solution, field::Symbol, charge::Integer) for more information.

Fields

  • t::Any: A vector of times (in seconds) at which simulation output has been saved
  • frames::Any: A vector of frames, or snapshots of the simulation state, at the times specified in t
  • params::Any: The solution parameters vector. Contains auxilliary information about the simulation.
  • config::Any: The Config used to run the simulation
  • retcode::Symbol: The solution return code. This can be one of three values:
    1. :success: the simulation completed successfully.
    2. :failure: the simulation failed due to a numerical issue or instability, resulting in a NaN or Inf being detected somewhere in the solution
    3. :error: another error occurred. Check the error string to see what kind of error.
  • error::String: Holds to error text and backtrace, if an error occurred. Empty if sol.retcode != :error.
source

Functions

HallThruster.write_to_jsonFunction
write_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 solution
  • sol: the Solution 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. If false, no time-resolved output is written.
source
HallThruster.valid_fieldsFunction
valid_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, :B, :E, :μ, :Tev, :ϕ, :∇ϕ, :ne, :pe, :ue, :∇pe, :νan, :νc, :νen, :νei, :radial_loss_frequency, :νew_momentum, :νiz, :νex, :νe, :Id, :ji, :nn, :anom_multiplier, :ohmic_heating, :wall_losses, :inelastic_losses, :Vs, :channel_area, :inner_radius, :outer_radius, :dA_dz, :tanδ, :anom_variables, :dt, :ni, :ui, :niui, :mobility, :potential, :thermal_conductivity, :grad_pe, :nu_anom, :nu_class, :nu_wall, :nu_ei, :nu_en, :nu_iz, :nu_ex, :tan_divergence_angle, :E, :ωce, :cyclotron_freq)
source
HallThruster.alternate_field_namesFunction
alternate_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 = :ϕ, thermal_conductivity = :κ, grad_pe = :∇pe, nu_anom = :νan, nu_class = :νc, nu_wall = :νew_momentum, nu_ei = :νei, nu_en = :νen, nu_iz = :νiz, nu_ex = :νex, tan_divergence_angle = :tanδ)
source
Base.getindexMethod
getindex(
    sol::HallThruster.Solution,
    frame::Integer
) -> HallThruster.Solution{T, _A, _B, S} where {T<:(Vector), _A, _B, S<:(Vector)}

Return a solution where frames = [sol.frames[frame]] and [t = sol.t[frame]] All other fields remain unchanged.

source
Base.getindexMethod
getindex(
    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])

source
Base.getindexMethod
getindex(sol::HallThruster.Solution, field::Symbol) -> Any

Return plasma data indicated by the field for every frame in sol. Type of returned data depends on the specific field. A list of valid fiels can be found by calling HallThruster.valid_fields(). Most of these return a vector of vectors, i.e. [[field at time 0], [field at time 1], ...]

For ion quantities, this method does not select a specific charge state. Calling sol[:ni] returns a vector of ncharge x ncells matrices, each of which contains the density of ions on the grid for every charge state. To get a specific charge, call sol[:ni, Z] where 1 <= Z <= ncharge and ncharge is the maximum charge state of the simulation.

There are some special-cased convenience fields as well, which may return different values.

  • :B: returns the magnetic field in each grid cell. Always returns a vector rather than vector of vectors, as the magnetic field is static.
  • :cyclotron_freq or ωce: returns the electron cyclotron frequency (e * B / m_e)as a vector of vectors.
  • :E: returns the electric field -∇ϕ as a vector of vectors.
  • :z: returns the cell center locations for the grid as a vector.

Additionally, for values in saved_fields with non-ascii/special characters in their names, we provide alternate accessors, a list of which can be found by calling HallThruster.alternate_field_names()

source
Base.getindexMethod
getindex(
    sol::HallThruster.Solution,
    field::Symbol,
    charge::Integer
) -> Any

For ion quantities (:ni, :ui, and :niui), indexing as sol[field, charge] returns a vector of vectors with the field for charge-charged ions. As an example, sol[:ui, 1] returns the velocity of singly-charged ions for every frame in sol.frames. For non-ion quantities, passing an integer as a second index causes an error.

source