bluemira.codes.plasmod.api._solver
The API for the plasmod solver.
Classes
RunModes for plasmod |
|
Plasmod solver class. |
Module Contents
- class bluemira.codes.plasmod.api._solver.RunMode(*args, **kwds)
Bases:
bluemira.codes.interface.BaseRunModeRunModes for plasmod
- RUN
- READ
- MOCK
- class bluemira.codes.plasmod.api._solver.Solver(params: dict | bluemira.base.parameter_frame.ParameterFrame, build_config: dict[str, Any] | None = None)
Bases:
bluemira.codes.interface.CodesSolverPlasmod solver class.
- Parameters:
params (dict | bluemira.base.parameter_frame.ParameterFrame) – ParameterFrame for plasmod.
build_config (dict[str, Any] | None) –
Build configuration dictionary. Expected keys include:
binary: str, path to the plasmod binary.
problem_settings: Dict[str, Any], any plasmod specific parameters (i.e., parameters that bluemira does not have direct mappings to through the ParameterFrame).
input_file: str, the path to write the plasmod input file to, this can be a relative path.
output_file: str, the path to write the plasmod scalar output file to.
profiles_file: str, the path to write the plasmod profiles output file to.
- name = 'PLASMOD'
The name of the solver.
In the base class, this is used to find mappings and specialise error messages for the concrete solver.
- setup_cls
Class defining the run modes for the setup stage of the solver.
Typically, this class performs parameter mappings for some external code, or derives dependent parameters. But it can also define any required non-computational set up.
- run_cls
Class defining the run modes for the computational stage of the solver.
This class is where computations should be defined. This may be something like calling a bluemira problem, or executing some external code or process.
- teardown_cls
Class defining the run modes for the teardown stage of the solver.
This class should perform any clean-up operations required by the solver. This may be deleting temporary files, or could involve mapping parameters from some external code to bluemira parameters.
- run_mode_cls
Class enumerating the run modes for this solver.
Common run modes are RUN, MOCK, READ, etc,.
- DEFAULT_INPUT_FILE = 'plasmod_input.dat'
- DEFAULT_OUTPUT_FILE = 'plasmod_output.dat'
- DEFAULT_PROFILES_FILE = 'plasmod_profiles.dat'
- params
- build_config
- binary
- problem_settings
- input_file
- output_file
- profiles_file
- run_directory
- read_directory
- execute(run_mode: str | RunMode) bluemira.base.parameter_frame.ParameterFrame
Execute this plasmod solver.
This solver:
writes a plasmod input file using the given bluemira and problem parameters.
processes that file using a shell call to plasmod.
reads the plasmod output files, and updates this object’s ParameterFrame with the results.
- Parameters:
run_mode (str | RunMode) – The mode to execute this solver in.
- Return type:
bluemira.base.parameter_frame.ParameterFrame
- _scale_x_profile()
- _from_phi_to_psi(profile_data)
Convert the profile to the magnetic coordinate sqrt((psi - psi_ax)/(psi_b - psi_ax))
- get_profile(profile: str | bluemira.codes.plasmod.mapping.Profiles) numpy.ndarray
Get a single plasmod profile.
- Parameters:
profile (str | bluemira.codes.plasmod.mapping.Profiles) – A profile to get the data for.
- Return type:
A plasmod profile.
Notes
pprime and ffprime profiles from PLASMOD are currently inconsistent with the output jpar profile, even if isawt=FULLY_RELAXED. This is a known issue, and is under investigation. In the meantime, a crude rescaling of the flux functions is provided here.
- get_profiles(profiles: collections.abc.Iterable[str | bluemira.codes.plasmod.mapping.Profiles]) dict[bluemira.codes.plasmod.mapping.Profiles, numpy.ndarray]
Get a dictionary of plasmod profiles.
- Parameters:
profiles (collections.abc.Iterable[str | bluemira.codes.plasmod.mapping.Profiles]) – An iterable of Profiles enum values.
- Return type:
A dictionary mapping profile enum to values.
- plasmod_outputs() bluemira.codes.plasmod.api._outputs.PlasmodOutputs
Return a structure of unmapped plasmod outputs.
Use
paramsattribute for mapped outputs.- Return type:
The scalar plasmod outputs.
- Raises:
CodesError – plasmod must be run before there are outputs