bluemira.codes.process._solver ============================== .. py:module:: bluemira.codes.process._solver Attributes ---------- .. autoapisummary:: bluemira.codes.process._solver.BuildConfig Classes ------- .. autoapisummary:: bluemira.codes.process._solver.RunMode bluemira.codes.process._solver.Solver Module Contents --------------- .. py:data:: BuildConfig .. py:class:: RunMode(*args, **kwds) Bases: :py:obj:`bluemira.codes.interface.BaseRunMode` .. autoapi-inheritance-diagram:: bluemira.codes.process._solver.RunMode :parts: 1 :private-bases: Run modes for the PROCESS solver. .. py:attribute:: RUN .. py:attribute:: RUNINPUT .. py:attribute:: READ .. py:attribute:: READALL .. py:attribute:: MOCK .. py:attribute:: NONE .. py:class:: Solver(params: dict | bluemira.base.parameter_frame.ParameterFrame, build_config: collections.abc.Mapping[str, float | str | BuildConfig]) Bases: :py:obj:`bluemira.codes.interface.CodesSolver` .. autoapi-inheritance-diagram:: bluemira.codes.process._solver.Solver :parts: 1 :private-bases: PROCESS solver. Runs, loads or mocks PROCESS to generate a reactor's radial build. :param params: ParameterFrame or dict containing parameters for running PROCESS. See :class:`~bluemira.codes.process.params.ProcessSolverParams` for parameter details. :param build_config: 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 :class:`~bluemira.codes.process._inputs.ProcessInputs`. By default this is an empty instance of the class. To create a new instance :class:`~bluemira.codes.process.template_builder.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 '/IN.DAT'. .. rubric:: 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 :code:`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 :code:`send = False`. * read: Load the radial build from a PROCESS MFILE.DAT. Loads only the parameters with :code:`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. .. py:attribute:: name :type: str :value: 'PROCESS' The name of the solver. In the base class, this is used to find mappings and specialise error messages for the concrete solver. .. py:attribute:: setup_cls :type: 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. .. py:attribute:: run_cls :type: 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. .. py:attribute:: teardown_cls :type: 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. .. py:attribute:: run_mode_cls :type: type[RunMode] Class enumerating the run modes for this solver. Common run modes are RUN, MOCK, READ, etc,. .. py:attribute:: params_cls :type: type[bluemira.codes.process.params.ProcessSolverParams] .. py:attribute:: _setup :type: bluemira.codes.process._setup.Setup | None :value: None .. py:attribute:: _run :type: bluemira.codes.process._run.Run | None :value: None .. py:attribute:: _teardown :type: bluemira.codes.process._teardown.Teardown | None :value: None .. py:attribute:: binary .. py:attribute:: run_directory .. py:attribute:: read_directory .. py:attribute:: template_in_dat .. py:attribute:: custom_solver .. py:attribute:: problem_settings .. py:attribute:: in_dat_path .. py:attribute:: params .. py:method:: execute(run_mode: str | RunMode) -> bluemira.base.parameter_frame.ParameterFrame Execute the solver in the given run mode. :param run_mode: The run mode to execute the solver in. See the :func:`~bluemira.codes.process._solver.Solver.__init__` docstring for details of the behaviour of each run mode. :returns: The modified parameters :raises CodesError: install not found .. py:method:: plot_radial_build(width: float = 1.5, *, show: bool = False) -> matplotlib.pyplot.Axes Plot PROCESS radial build. :param width: The relative width of the plot. :param show: If True then immediately display the plot, else delay displaying the plot until the user shows it, by default True. :rtype: The plot Axes object. .. py:method:: get_raw_variables(params: list | str) -> list[float] Get raw variables from this solver's associate MFile. Mapped bluemira parameters will have bluemira names. :param params: Names of parameters to access. :rtype: The parameter values. :raises CodesError: Cannot read output before creation .. py:method:: get_species_data(impurity: str, confinement_time_ms: float) -> tuple[numpy.ndarray, numpy.ndarray, numpy.ndarray] :staticmethod: Get species data from PROCESS section of OPEN-ADAS database. The data is taken with density $n_e = 10^{19} m^{-3}$. :param impurity: The impurity to get the species data for. This string should be one of the names in the :class:`~bluemira.codes.process.api.Impurities` Enum. :param confinement_time_ms: 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. .. py:method:: get_species_fraction(impurity: str) -> float Get species fraction for the given impurity. :param impurity: The impurity to get the species data for. This string should be one of the names in the :class:`~bluemira.codes.process.api.Impurities` Enum. :returns: * *The species fraction for the impurity taken from the PROCESS* * *output MFile.*