MTCR
Documentation for MTCR.
MTCR.calculate_electron_electronic_energy_wrapper
MTCR.calculate_sources_wrapper
MTCR.calculate_temperatures_wrapper
MTCR.calculate_total_energy_wrapper
MTCR.calculate_vibrational_energy_wrapper
MTCR.close_mtcr_library
MTCR.convert_density_cgs_to_si
MTCR.convert_density_si_to_cgs
MTCR.convert_energy_density_cgs_to_si
MTCR.convert_energy_density_si_to_cgs
MTCR.convert_number_density_cgs_to_si
MTCR.convert_number_density_si_to_cgs
MTCR.convert_pressure_cgs_to_si
MTCR.convert_pressure_si_to_cgs
MTCR.convert_sources_cgs_to_si
MTCR.convert_state_cgs_to_si
MTCR.convert_state_si_to_cgs
MTCR.create_species_mapping
MTCR.finalize_api_wrapper
MTCR.get_max_number_of_atomic_electronic_states_wrapper
MTCR.get_max_number_of_molecular_electronic_states_wrapper
MTCR.get_max_number_of_species_wrapper
MTCR.get_mtcr_handle
MTCR.get_mtcr_lib_path
MTCR.get_species_names_wrapper
MTCR.initialize_api_wrapper
MTCR.is_mtcr_loaded
MTCR.load_mtcr_library!
MTCR.mass_densities_to_mole_fractions
MTCR.mole_fractions_to_mass_densities
MTCR.prepare_arrays_for_fortran
MTCR.set_electronic_boltzmann_wrapper
MTCR.validate_species_data
MTCR.calculate_electron_electronic_energy_wrapper
— Methodcalculate_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 initializedArgumentError
: If teex ≤ 0, tvib ≤ 0, or arrays are invalid
MTCR.calculate_sources_wrapper
— Methodcalculate_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 densityrho_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
MTCR.calculate_temperatures_wrapper
— Methodcalculate_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 densitiesrho_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
MTCR.calculate_total_energy_wrapper
— Methodcalculate_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
MTCR.calculate_vibrational_energy_wrapper
— Methodcalculate_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
MTCR.close_mtcr_library
— Methodclose_mtcr_library()
Close the MTCR library and free resources.
MTCR.convert_density_cgs_to_si
— Methodconvert_density_cgs_to_si(rho_cgs)
Convert species densities from CGS (g/cm³) to SI (kg/m³) units.
MTCR.convert_density_si_to_cgs
— Methodconvert_density_si_to_cgs(rho_si)
Convert species densities from SI (kg/m³) to CGS (g/cm³) units.
MTCR.convert_energy_density_cgs_to_si
— Methodconvert_energy_density_cgs_to_si(energy_cgs)
Convert energy density from CGS (erg/cm³) to SI (J/m³) units.
MTCR.convert_energy_density_si_to_cgs
— Methodconvert_energy_density_si_to_cgs(energy_si)
Convert energy density from SI (J/m³) to CGS (erg/cm³) units.
MTCR.convert_number_density_cgs_to_si
— Methodconvert_number_density_cgs_to_si(n_cgs)
Convert number density from CGS (1/cm³) to SI (1/m³) units.
MTCR.convert_number_density_si_to_cgs
— Methodconvert_number_density_si_to_cgs(n_si)
Convert number density from SI (1/m³) to CGS (1/cm³) units.
MTCR.convert_pressure_cgs_to_si
— Methodconvert_pressure_cgs_to_si(pressure_cgs)
Convert pressure from CGS (dyne/cm²) to SI (Pa) units.
MTCR.convert_pressure_si_to_cgs
— Methodconvert_pressure_si_to_cgs(pressure_si)
Convert pressure from SI (Pa) to CGS (dyne/cm²) units.
MTCR.convert_sources_cgs_to_si
— Methodconvert_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
MTCR.convert_state_cgs_to_si
— Methodconvert_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
MTCR.convert_state_si_to_cgs
— Methodconvert_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
MTCR.create_species_mapping
— Methodcreate_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 formatmtcr_species::Vector{String}
: Species names in MTCR format
Returns
- Dictionary mapping HallThruster.jl species names to MTCR species names
MTCR.finalize_api_wrapper
— Methodfinalize_api_wrapper()
Finalize the MTCR API system and clean up resources.
MTCR.get_max_number_of_atomic_electronic_states_wrapper
— Methodget_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
MTCR.get_max_number_of_molecular_electronic_states_wrapper
— Methodget_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
MTCR.get_max_number_of_species_wrapper
— Methodget_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
MTCR.get_mtcr_handle
— Methodget_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
MTCR.get_mtcr_lib_path
— Methodget_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
MTCR.get_species_names_wrapper
— Methodget_species_names_wrapper()
Get species names from MTCR.
Returns
Vector{String}
: Array of species names
Throws
ErrorException
: If MTCR library is not loaded
MTCR.initialize_api_wrapper
— Methodinitialize_api_wrapper(; case_path)
Initialize the MTCR API system.
Arguments
case_path::String
: Path to directory containing input/ subdirectory (default: current directory)
Returns
NamedTuple
: Containsnum_species
andnum_dimensions
as determined by MTCR from input files
Throws
ErrorException
: If case_path doesn't exist, input file is missing, or Fortran call fails
MTCR.is_mtcr_loaded
— Methodis_mtcr_loaded()
Check if the MTCR library is currently loaded.
Returns
Bool
: True if library is loaded, false otherwise
MTCR.load_mtcr_library!
— Methodload_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
MTCR.mass_densities_to_mole_fractions
— Methodmass_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
MTCR.mole_fractions_to_mass_densities
— Methodmole_fractions_to_mass_densities(
mole_fractions,
molecular_weights,
total_number_density
)
Convert mole fractions to mass densities.
Arguments
mole_fractions::Vector{Float64}
: Species mole fractionsmolecular_weights::Vector{Float64}
: Species molecular weights (g/mol)total_number_density::Float64
: Total number density (1/cm³)
Returns
- Vector of mass densities (g/cm³)
MTCR.prepare_arrays_for_fortran
— Methodprepare_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
MTCR.set_electronic_boltzmann_wrapper
— Methodset_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 initializedArgumentError
: If temperatures ≤ 0 or arrays are invalid
MTCR.validate_species_data
— Methodvalidate_species_data(
species_names,
mtcr_species,
densities
)
Validate species data consistency between Julia and MTCR.
Arguments
species_names::Vector{String}
: Species names from configurationmtcr_species::Vector{String}
: Species names from MTCRdensities::Vector{Float64}
: Species densities
Returns
true
if validation passes, throws error otherwise