MTCR

Documentation for MTCR.

MTCR.calculate_electron_electronic_energy_wrapperMethod
calculate_electron_electronic_energy_wrapper(
    teex,
    tvib,
    rho_sp
)

Calculate electron-electronic energy from state variables.

Arguments

  • teex::Float64: Electron-electronic temperature (K)
  • tvib::Float64: Vibrational temperature (K)
  • rho_sp::Vector{Float64}: Species densities (mass/volume)

Returns

  • Float64: Electron-electronic energy density

Throws

  • ErrorException: If MTCR library is not loaded or not initialized
  • ArgumentError: If teex ≤ 0, tvib ≤ 0, or arrays are invalid
source
MTCR.calculate_sources_wrapperMethod
calculate_sources_wrapper(
    rho_sp,
    rho_etot;
    rho_ex,
    rho_vx,
    rho_u,
    rho_v,
    rho_w,
    rho_erot,
    rho_eeex,
    rho_evib
)

Calculate nonequilibrium source terms.

Arguments

  • rho_sp::Vector{Float64}: Species densities (mass/volume)
  • rho_etot::Float64: Total energy density
  • rho_ex::Matrix{Float64}: Electronic state densities (optional)
  • rho_vx::Array{Float64,3}: Vibrational state densities (optional)
  • rho_erot::Float64: Rotational energy density (optional)
  • rho_eeex::Float64: Electron-electronic energy density (optional)
  • rho_evib::Float64: Vibrational energy density (optional)

Returns

  • Tuple of derivative arrays corresponding to input arrays

Throws

  • ErrorException: If MTCR library is not loaded or not initialized
source
MTCR.calculate_temperatures_wrapperMethod
calculate_temperatures_wrapper(
    rho_sp,
    rho_etot;
    rho_ex,
    rho_vx,
    rho_u,
    rho_v,
    rho_w,
    rho_erot,
    rho_eeex,
    rho_evib
)

Calculate temperatures from thermodynamic state.

Arguments

  • rho_sp::Vector{Float64}: Species densities
  • rho_etot::Float64: Total energy density
  • Additional optional energy components

Returns

  • Named tuple with temperatures (tt, trot, teex, tvib, tex, tvx)

Throws

  • ErrorException: If MTCR library is not loaded or not initialized
source
MTCR.calculate_total_energy_wrapperMethod
calculate_total_energy_wrapper(
    tt,
    rho_sp;
    rho_ex,
    rho_vx,
    u,
    v,
    w,
    rho_erot,
    rho_eeex,
    rho_evib
)

Calculate total energy from state variables.

Arguments

  • tt::Float64: Translational temperature (K)
  • rho_sp::Vector{Float64}: Species densities (mass/volume)
  • rho_ex::Matrix{Float64}: Electronic state densities (optional)
  • rho_vx::Array{Float64,3}: Vibrational state densities (optional)
  • u::Float64: x-velocity component (optional)
  • v::Float64: y-velocity component (optional)
  • w::Float64: z-velocity component (optional)
  • rho_erot::Float64: Rotational energy density (optional)
  • rho_eeex::Float64: Electron-electronic energy density (optional)
  • rho_evib::Float64: Vibrational energy density (optional)

Returns

  • Float64: Total energy density

Throws

  • ErrorException: If MTCR library is not loaded or not initialized
source
MTCR.calculate_vibrational_energy_wrapperMethod
calculate_vibrational_energy_wrapper(
    tvib,
    rho_sp;
    rho_ex,
    tex,
    teex
)

Calculate vibrational energy from state variables.

Arguments

  • tvib::Float64: Vibrational temperature (K)
  • rho_sp::Vector{Float64}: Species densities (mass/volume)
  • rho_ex::Matrix{Float64}: Electronic state densities (optional)
  • tex::Vector{Float64}: Electronic temperatures per species (optional)
  • teex::Float64: Electron-electronic temperature (optional)

Returns

  • Float64: Vibrational energy density

Throws

  • ErrorException: If MTCR library is not loaded or not initialized
source
MTCR.convert_sources_cgs_to_siMethod
convert_sources_cgs_to_si(
    drho_sp_cgs,
    drho_etot_cgs;
    drho_erot_cgs,
    drho_eeex_cgs,
    drho_evib_cgs
)

Convert source terms from CGS to SI units.

Arguments

  • drho_sp_cgs::Vector{Float64}: Species source terms in CGS units (g/cm³/s)
  • drho_etot_cgs::Float64: Energy source term in CGS units (erg/cm³/s)
  • Additional optional source terms in CGS units

Returns

  • Named tuple with all source terms converted to SI units
source
MTCR.convert_state_cgs_to_siMethod
convert_state_cgs_to_si(
    rho_sp_cgs,
    rho_etot_cgs;
    rho_erot_cgs,
    rho_eeex_cgs,
    rho_evib_cgs
)

Convert a complete state vector from CGS to SI units from MTCR output.

Arguments

  • rho_sp_cgs::Vector{Float64}: Species densities in CGS units (g/cm³)
  • rho_etot_cgs::Float64: Total energy density in CGS units (erg/cm³)
  • Additional optional energy components in CGS units

Returns

  • Named tuple with all quantities converted to SI units
source
MTCR.convert_state_si_to_cgsMethod
convert_state_si_to_cgs(
    rho_sp_si,
    rho_etot_si,
    number_density_si;
    rho_erot_si,
    rho_eeex_si,
    rho_evib_si
)

Convert a complete state vector from SI to CGS units for MTCR input.

Arguments

  • rho_sp_si::Vector{Float64}: Species densities in SI units (kg/m³)
  • rho_etot_si::Float64: Total energy density in SI units (J/m³)
  • number_density_si::Float64: Total number density in SI units (1/m³)
  • Additional optional energy components in SI units

Returns

  • Named tuple with all quantities converted to CGS units
source
MTCR.create_species_mappingMethod
create_species_mapping(ht_species, mtcr_species)

Create species mapping between HallThruster.jl and MTCR conventions.

Arguments

  • ht_species::Vector{String}: Species names in HallThruster.jl format
  • mtcr_species::Vector{String}: Species names in MTCR format

Returns

  • Dictionary mapping HallThruster.jl species names to MTCR species names
source
MTCR.get_max_number_of_atomic_electronic_states_wrapperMethod
get_max_number_of_atomic_electronic_states_wrapper()

Get the maximum number of electronic states per atomic species supported by MTCR.

Returns

  • Int32: Maximum number of atomic electronic states

Throws

  • ErrorException: If MTCR library is not loaded
source
MTCR.get_max_number_of_molecular_electronic_states_wrapperMethod
get_max_number_of_molecular_electronic_states_wrapper()

Get the maximum number of electronic states per molecular species supported by MTCR.

Returns

  • Int32: Maximum number of molecular electronic states

Throws

  • ErrorException: If MTCR library is not loaded
source
MTCR.get_max_number_of_species_wrapperMethod
get_max_number_of_species_wrapper()

Get the maximum number of species supported by MTCR.

Returns

  • Int32: Maximum number of species

Throws

  • ErrorException: If MTCR library is not loaded
source
MTCR.get_mtcr_handleMethod
get_mtcr_handle()

Get the handle to the loaded MTCR library.

Returns

  • Ptr{Cvoid}: Handle to the loaded library

Throws

  • ErrorException: If no library is loaded
source
MTCR.get_mtcr_lib_pathMethod
get_mtcr_lib_path()

Get the path to the loaded MTCR library.

Returns

  • String: Path to the loaded library

Throws

  • ErrorException: If no library is loaded
source
MTCR.get_species_names_wrapperMethod
get_species_names_wrapper()

Get species names from MTCR.

Returns

  • Vector{String}: Array of species names

Throws

  • ErrorException: If MTCR library is not loaded
source
MTCR.initialize_api_wrapperMethod
initialize_api_wrapper(; case_path)

Initialize the MTCR API system.

Arguments

  • case_path::String: Path to directory containing input/ subdirectory (default: current directory)

Returns

  • NamedTuple: Contains num_species and num_dimensions as determined by MTCR from input files

Throws

  • ErrorException: If case_path doesn't exist, input file is missing, or Fortran call fails
source
MTCR.is_mtcr_loadedMethod
is_mtcr_loaded()

Check if the MTCR library is currently loaded.

Returns

  • Bool: True if library is loaded, false otherwise
source
MTCR.load_mtcr_library!Method
load_mtcr_library!(path)

Set the path to the MTCR shared library and load it.

Arguments

  • path::String: Path to the MTCR shared library file

Throws

  • ErrorException: If the library cannot be loaded
source
MTCR.mass_densities_to_mole_fractionsMethod
mass_densities_to_mole_fractions(
    mass_densities,
    molecular_weights
)

Convert mass densities to mole fractions.

Arguments

  • mass_densities::Vector{Float64}: Species mass densities (g/cm³)
  • molecular_weights::Vector{Float64}: Species molecular weights (g/mol)

Returns

  • Vector of mole fractions
source
MTCR.mole_fractions_to_mass_densitiesMethod
mole_fractions_to_mass_densities(
    mole_fractions,
    molecular_weights,
    total_number_density
)

Convert mole fractions to mass densities.

Arguments

  • mole_fractions::Vector{Float64}: Species mole fractions
  • molecular_weights::Vector{Float64}: Species molecular weights (g/mol)
  • total_number_density::Float64: Total number density (1/cm³)

Returns

  • Vector of mass densities (g/cm³)
source
MTCR.prepare_arrays_for_fortranMethod
prepare_arrays_for_fortran(arrays)

Prepare Julia arrays for passing to Fortran.

Fortran expects column-major arrays, which Julia uses natively. This function ensures proper memory layout and type consistency.

Arguments

  • arrays...: Variable number of Julia arrays to prepare

Returns

  • Tuple of arrays ready for Fortran ccall
source
MTCR.set_electronic_boltzmann_wrapperMethod
set_electronic_boltzmann_wrapper(rho_sp, tex, trot, tvib)

Set electronic state densities to Boltzmann distribution.

Arguments

  • rho_sp::Vector{Float64}: Species densities (mass/volume)
  • tex::Float64: Electronic temperature (K)
  • trot::Float64: Rotational temperature (K)
  • tvib::Float64: Vibrational temperature (K)

Returns

  • Matrix{Float64}: Electronic state densities in Boltzmann distribution

Throws

  • ErrorException: If MTCR library is not loaded or not initialized
  • ArgumentError: If temperatures ≤ 0 or arrays are invalid
source
MTCR.validate_species_dataMethod
validate_species_data(
    species_names,
    mtcr_species,
    densities
)

Validate species data consistency between Julia and MTCR.

Arguments

  • species_names::Vector{String}: Species names from configuration
  • mtcr_species::Vector{String}: Species names from MTCR
  • densities::Vector{Float64}: Species densities

Returns

  • true if validation passes, throws error otherwise
source