Source code for torx.specializations.genex.normalization_helpers_m

"""Helps read the normalization from GENE-X namelists."""

from pathlib import Path
from torx import Quantity as Q_, unit_registry as ureg
from torx.fileio import read_fortran_namelist
from torx.fileio import filepath_resolver
from torx.autodoc_decorators_m import autodoc_function

[docs] @autodoc_function def create_physical_parameters_dict_from_filepath_genex( \ directory_path: Path) -> dict: """Return a dict of physics parameters from GENE-X simulation path.""" params_normalization_genex = dict( read_fortran_namelist(directory_path / "params_out.txt")["params_normalization"] ) physical_parameters = {} for key in ["b_ref", "t_ref", "n_ref", "l_ref", "m_ref"]: assert key in params_normalization_genex # Magnetic field normalization, usually taken on axis, in Tesla physical_parameters["B0"] = Q_(params_normalization_genex["b_ref"], ureg.tesla) # Electron temperature normalization, in electron-volts physical_parameters["Te0"] = Q_( params_normalization_genex["t_ref"], "kiloelectron_volt" ) # Ion temperature normalization, in electron-volts physical_parameters["Ti0"] = Q_( params_normalization_genex["t_ref"], "kiloelectron_volt" ) # Density normalization, in particles-per-cubic-meters physical_parameters["n0"] = Q_( 1e19 * params_normalization_genex["n_ref"], ureg.meter**-3 ) # Major radius, in meters (n.b. this is also the scale length for parallel # quantities) physical_parameters["R0"] = Q_(params_normalization_genex["l_ref"], ureg.meter) # Ion mass, in amu physical_parameters["Mi"] = Q_( params_normalization_genex["m_ref"], ureg.proton_mass ) # Ion charge state physical_parameters["Z"] = 1.0 # Ion effective charge state physical_parameters["Z_eff"] = 1.0 return physical_parameters