bluemira.codes.process._solver

Attributes

BuildConfig

Classes

RunMode

Run modes for the PROCESS solver.

Solver

PROCESS solver. Runs, loads or mocks PROCESS to generate a reactor's

Module Contents

bluemira.codes.process._solver.BuildConfig
class bluemira.codes.process._solver.RunMode(*args, **kwds)

Bases: bluemira.codes.interface.BaseRunMode

Inheritance diagram of bluemira.codes.process._solver.RunMode

Run modes for the PROCESS solver.

RUN
RUNINPUT
READ
READALL
MOCK
NONE
class bluemira.codes.process._solver.Solver(params: dict | bluemira.base.parameter_frame.ParameterFrame, build_config: collections.abc.Mapping[str, float | str | BuildConfig])

Bases: bluemira.codes.interface.CodesSolver

Inheritance diagram of bluemira.codes.process._solver.Solver

PROCESS solver. Runs, loads or mocks PROCESS to generate a reactor’s radial build.

Parameters:
  • params (dict | bluemira.base.parameter_frame.ParameterFrame) – ParameterFrame or dict containing parameters for running PROCESS. See ProcessSolverParams for parameter details.

  • build_config (collections.abc.Mapping[str, float | str | BuildConfig]) –

    Dictionary containing the configuration for this solver. Expected keys are:

    • binary:

      The path to the PROCESS binary. The default assumes the PROCESS executable is on the system path.

    • run_dir:

      The directory in which to run PROCESS. It is also the directory in which to look for PROCESS input and output files. Default is current working directory.

    • read_dir:

      The directory from which data is read when running in read mode.

    • template_in_dat_path:

      The path to a template PROCESS IN.DAT file or and instances of ProcessInputs. By default this is an empty instance of the class. To create a new instance PROCESSTemplateBuilder should be used.

    • problem_settings:

      Any PROCESS parameters that do not correspond to a bluemira parameter.

    • in_dat_path:

      The path to save the IN.DAT file that is run by PROCESS. By default this is ‘<run_dir>/IN.DAT’.

Notes

This solver has several run modes:

  • run: Run PROCESS to generate a radial build.

    Creates a new input file from the given template IN.DAT, which is modified with bluemira parameters that are mapped with send = True.

  • runinput: Run PROCESS with an unmodified template IN.DAT.

    The template IN.DAT is not modified with bluemira parameters. This is equivalent to all bluemira parameters mappings having send = False.

  • read: Load the radial build from a PROCESS MFILE.DAT.

    Loads only the parameters with send = True. A file named ‘MFILE.DAT’ must exist within ‘run_directory’.

  • readall: Load the radial build from a PROCESS MFILE.DAT.

    Loads all mappable parameters from the PROCESS file. A file named ‘MFILE.DAT’ must exist within ‘run_directory’.

  • mock: Load bluemira parameters directly from a JSON file in the

    run directory. This does not run PROCESS.

  • none: Does nothing.

    PROCESS is not run and parameters are not updated. This is useful loading results form previous runs of bluemira, where overwriting data with PROCESS outputs would be undesirable.

name: str = 'PROCESS'

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: type[bluemira.codes.process._setup.Setup]

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: type[bluemira.codes.process._run.Run]

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: type[bluemira.codes.process._teardown.Teardown]

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: type[RunMode]

Class enumerating the run modes for this solver.

Common run modes are RUN, MOCK, READ, etc,.

params_cls: type[bluemira.codes.process.params.ProcessSolverParams]
_setup: bluemira.codes.process._setup.Setup | None = None
_run: bluemira.codes.process._run.Run | None = None
_teardown: bluemira.codes.process._teardown.Teardown | None = None
binary
run_directory
read_directory
template_in_dat
custom_solver
problem_settings
in_dat_path
params
execute(run_mode: str | RunMode) bluemira.base.parameter_frame.ParameterFrame

Execute the solver in the given run mode.

Parameters:

run_mode (str | RunMode) – The run mode to execute the solver in. See the __init__() docstring for details of the behaviour of each run mode.

Returns:

The modified parameters

Raises:

CodesError – install not found

Return type:

bluemira.base.parameter_frame.ParameterFrame

plot_radial_build(width: float = 1.5, *, show: bool = False) matplotlib.pyplot.Axes

Plot PROCESS radial build.

Parameters:
  • width (float) – The relative width of the plot.

  • show (bool) – If True then immediately display the plot, else delay displaying the plot until the user shows it, by default True.

Return type:

The plot Axes object.

get_raw_variables(params: list | str) list[float]

Get raw variables from this solver’s associate MFile.

Mapped bluemira parameters will have bluemira names.

Parameters:

params (list | str) – Names of parameters to access.

Return type:

The parameter values.

Raises:

CodesError – Cannot read output before creation

static get_species_data(impurity: str, confinement_time_ms: float) tuple[numpy.ndarray, numpy.ndarray, numpy.ndarray]

Get species data from PROCESS section of OPEN-ADAS database.

The data is taken with density $n_e = 10^{19} m^{-3}$.

Parameters:
  • impurity (str) – The impurity to get the species data for. This string should be one of the names in the Impurities Enum.

  • confinement_time_ms (float) – the confinement time to read the data for options are: [0.1, 1.0, 10.0, 100.0, 1000.0, np.inf]

Returns:

  • tref – The temperature in eV.

  • l_ref – The loss function value $L_z(n_e, T_e)$ in W.m3.

  • z_ref – Average effective charge.

Return type:

tuple[numpy.ndarray, numpy.ndarray, numpy.ndarray]

get_species_fraction(impurity: str) float

Get species fraction for the given impurity.

Parameters:

impurity (str) – The impurity to get the species data for. This string should be one of the names in the Impurities Enum.

Returns:

  • The species fraction for the impurity taken from the PROCESS

  • output MFile.

Return type:

float