bluemira.codes.openmc.solver

OpenMC designer

Attributes

OPENMC_NAME

NeutronSourceCreator

TALLY_FUNCTION_TYPE

Classes

OpenMCRunModes

OpenMC run modes

OpenMCSimulationRuntimeParameters

Parameters used in the actual simulation

PlotConfig

Plot configuration helper

SourceInfo

Source info storage

FigureData

Figure data storage

OpenMCBaseSetup

Setup task for OpenMC solver

OpenMCCSGSetup

Setup for openmc CSG run

OpenMCDAGSetup

Setup for openmc DAGMC run

OpenMCRun

Run task for OpenMC solver

OpenMCCSGTeardown

Teardown task for OpenMC solver

OpenMCDAGTeardown

Teardown for DAGMC run

OpenMCNeutronicsSolver

OpenMC 2D neutronics solver

OpenMCCSGNeutronicsSolver

Solver for OpenMC CSG neutronics

OpenMCDAGMCNeutronicsSolver

Solver for OpenMC DAGMC neutronics

Module Contents

class bluemira.codes.openmc.solver.OpenMCRunModes(*args, **kwds)

Bases: bluemira.codes.interface.BaseRunMode

Inheritance diagram of bluemira.codes.openmc.solver.OpenMCRunModes

OpenMC run modes

RUN = 'fixed source'
RUN_AND_PLOT
PLOT = 'plot'
VOLUME = 'volume'
bluemira.codes.openmc.solver.OPENMC_NAME = 'OpenMC'
class bluemira.codes.openmc.solver.OpenMCSimulationRuntimeParameters

Parameters used in the actual simulation

Parameters:
  • particles – Number of neutrons emitted by the plasma source per batch.

  • cross_section_xml – Where the xml file for cross-section is stored locally.

  • batches – How many batches to simulate.

  • photon_transport – Whether to simulate the transport of photons (i.e. gamma-rays created) or not.

  • electron_treatment – The way in which OpenMC handles secondary charged particles. ‘thick-target bremsstrahlung’ or ‘local energy deposition’ ‘thick-target bremsstrahlung’ accounts for the energy carried away by bremsstrahlung photons and deposited elsewhere, whereas ‘local energy deposition’ assumes electrons deposit all energies locally. (the latter is expected to be computationally faster.)

  • run_mode – see below for details: https://docs.openmc.org/en/stable/usersguide/settings.html#run-modes

  • openmc_write_summary – whether openmc should write a ‘summary.h5’ file or not.

  • plot_axis – axis to use for openmc plotter

  • plot_pixel_per_metre – number of pixels to plot in openmc plotter

  • rel_max_lost_particles – relative max number of particles to lose before error

  • max_lost_particles – max number of particles to lose before error

particles: int
cross_section_xml: str | pathlib.Path
batches: int = 2
photon_transport: bool = True
electron_treatment: Literal['ttb', 'led'] = 'led'
run_mode: str = 'fixed source'
openmc_write_summary: bool = False
plot_axis: str = 'xz'
plot_pixel_per_metre: int = 100
rel_max_lost_particles: float = 1e-06
max_lost_particles: int = 10
tally_mesh_size: collections.abc.Sequence[float] = (100, 100, 100)
type bluemira.codes.openmc.solver.NeutronSourceCreator = Callable[[Equilibrium, PlasmaSourceParameters], tuple[openmc.Source, float, float]]
class bluemira.codes.openmc.solver.PlotConfig

Plot configuration helper

width: list[float]
pixels: list[int]
basis: str = 'xz'
colour_by: str = 'cell'
show_overlaps: bool = True
class bluemira.codes.openmc.solver.SourceInfo

Source info storage

rate: float
triton_rate: float
class bluemira.codes.openmc.solver.FigureData

Figure data storage

axis: matplotlib.axes.Axes
path: pathlib.Path
class bluemira.codes.openmc.solver.OpenMCBaseSetup(codes_name: str, cross_section_xml: str, eq: bluemira.equilibria.equilibrium.Equilibrium, source, materials)

Bases: bluemira.codes.interface.CodesSetup, abc.ABC

Inheritance diagram of bluemira.codes.openmc.solver.OpenMCBaseSetup

Setup task for OpenMC solver

Parameters:
tally_mats: openmc.Materials
tally_geom: openmc.Geometry | bluemira.codes.openmc.make_csg.CellStage
cross_section_xml
eq
source
_source_rate = 1.0
_source_triton_rate = 1.0
materials
_base_setup(run_mode, rel_max_lost_particles, max_lost_particles, *, debug: bool = False)
Parameters:

debug (bool)

_create_model(settings: openmc.Settings, tallies: openmc.Tallies | None = None) openmc.Model
Parameters:
  • settings (openmc.Settings)

  • tallies (openmc.Tallies | None)

Return type:

openmc.Model

abstract _create_geometry() tuple[openmc.Universe, openmc.geometry]
Return type:

tuple[openmc.Universe, openmc.geometry]

_create_tallies(tally_function: TALLY_FUNCTION_TYPE) openmc.Tallies
Parameters:

tally_function (TALLY_FUNCTION_TYPE)

Return type:

openmc.Tallies

abstract plot(run_mode, runtime_params, eq, source_params, tally_function, *, debug: bool = False)

Plot an openmc run

Parameters:

debug (bool)

abstract volume(run_mode, runtime_params, eq, source_params, tally_function, *, debug: bool = False)

Volume calculation on openmc run

Parameters:

debug (bool)

run(run_mode, runtime_params, eq, source_params, tally_function, *, debug: bool = False) tuple[openmc.Model, SourceInfo]

Run stage for setup openmc

Parameters:

debug (bool)

Return type:

tuple[openmc.Model, SourceInfo]

_plot(run_mode, runtime_params, bounding_box: collections.abc.Sequence[float] | None = None, *, debug: bool = False) tuple[openmc.Model, PlotConfig]

Plot stage for setup openmc

Parameters:
  • bounding_box (collections.abc.Sequence[float] | None)

  • debug (bool)

Return type:

tuple[openmc.Model, PlotConfig]

_volume(run_mode, runtime_params, domain, bounding_box, *, debug: bool = False) tuple[openmc.Model, None]

Stochastic volume stage for setup openmc

Parameters:

debug (bool)

Return type:

tuple[openmc.Model, None]

class bluemira.codes.openmc.solver.OpenMCCSGSetup(codes_name: str, cross_section_xml: str, eq: bluemira.equilibria.equilibrium.Equilibrium, source, materials, cell_arrays, pre_cell_model)

Bases: OpenMCBaseSetup

Inheritance diagram of bluemira.codes.openmc.solver.OpenMCCSGSetup

Setup for openmc CSG run

Parameters:
cell_arrays
pre_cell_model
mat_list
property tally_mats: list[openmc.Material]

Tally materials

Return type:

list[openmc.Material]

property tally_geom: bluemira.codes.openmc.make_csg.CellStage

Tally geometry

Return type:

bluemira.codes.openmc.make_csg.CellStage

_create_geometry()
plot(run_mode, runtime_params, *_args, debug: bool = False) tuple[openmc.Model, PlotConfig]

Plot an openmc run

Parameters:

debug (bool)

Return type:

tuple[openmc.Model, PlotConfig]

volume(run_mode, runtime_params, *_args, debug: bool = False) tuple[openmc.Model, None]

Volume calculation on openmc run

Parameters:

debug (bool)

Return type:

tuple[openmc.Model, None]

class bluemira.codes.openmc.solver.OpenMCDAGSetup(codes_name: str, cross_section_xml: str, eq: bluemira.equilibria.equilibrium.Equilibrium, source, materials, dag_model_path: pathlib.Path)

Bases: OpenMCBaseSetup

Inheritance diagram of bluemira.codes.openmc.solver.OpenMCDAGSetup

Setup for openmc DAGMC run

Parameters:
dag_model_path
_create_geometry()
property tally_mats: list[openmc.Material]

Tally materials

Return type:

list[openmc.Material]

property tally_geom: openmc.Geometry

Tally geometry

Return type:

openmc.Geometry

plot(run_mode, runtime_params, *_args, debug: bool = False) tuple[openmc.Model, PlotConfig]

Plot an openmc run

Parameters:

debug (bool)

Return type:

tuple[openmc.Model, PlotConfig]

volume(run_mode, runtime_params, *_args, debug: bool = False) tuple[openmc.Model, None]

Volume calculation on openmc run

Parameters:

debug (bool)

Return type:

tuple[openmc.Model, None]

class bluemira.codes.openmc.solver.OpenMCRun(out_path: pathlib.Path, codes_name: str)

Bases: bluemira.codes.interface.CodesTask

Inheritance diagram of bluemira.codes.openmc.solver.OpenMCRun

Run task for OpenMC solver

Parameters:
  • out_path (pathlib.Path)

  • codes_name (str)

out_path
static _run(run_mode, function, **kwargs)

Run openmc

run(run_mode, model: openmc.Model, _config: SourceInfo, *, debug: bool = False)

Run stage for run task

Parameters:
  • model (openmc.Model)

  • _config (SourceInfo)

  • debug (bool)

plot(run_mode, model: openmc.Model, config: PlotConfig, **_kwargs)

Plot stage for run task

Parameters:
volume(run_mode, model: openmc.Model, _config: None, *, debug: bool = False)

Stochastic volume stage for run task

Parameters:
  • model (openmc.Model)

  • _config (None)

  • debug (bool)

class bluemira.codes.openmc.solver.OpenMCCSGTeardown(cell_arrays: bluemira.codes.openmc.make_csg.CellStage, pre_cell_model: bluemira.radiation_transport.neutronics.neutronics_axisymmetric.NeutronicsReactor, out_path: str, codes_name: str)

Bases: bluemira.codes.interface.CodesTeardown

Inheritance diagram of bluemira.codes.openmc.solver.OpenMCCSGTeardown

Teardown task for OpenMC solver

Parameters:
out_path
cell_arrays
pre_cell_model
run(universe, source_info: SourceInfo, statepoint_file)

Run stage for Teardown task

Parameters:

source_info (SourceInfo)

static plot(_universe, _source_info, fig: FigureData, **_kwargs)

Plot stage for Teardown task

Parameters:

fig (FigureData)

volume(_universe, _source_params, _statepoint_file) dict[int, float]

Stochastic volume stage for teardown task

Return type:

dict[int, float]

class bluemira.codes.openmc.solver.OpenMCDAGTeardown(out_path: str, codes_name: str)

Bases: bluemira.codes.interface.CodesTeardown

Inheritance diagram of bluemira.codes.openmc.solver.OpenMCDAGTeardown

Teardown for DAGMC run

Parameters:
  • out_path (str)

  • codes_name (str)

out_path
static run(universe, source_info: SourceInfo, statepoint_file)

Run stage for Teardown task

Parameters:

source_info (SourceInfo)

static plot(_universe, _source_info, fig: FigureData, **_kwargs)

Plot stage for Teardown task

Parameters:

fig (FigureData)

abstract volume(_universe, _source_params, _statepoint_file) dict[int, float]

Stochastic volume stage for teardown task

Return type:

dict[int, float]

bluemira.codes.openmc.solver.TALLY_FUNCTION_TYPE
class bluemira.codes.openmc.solver.OpenMCNeutronicsSolver(params: dict | bluemira.base.parameter_frame.ParameterFrame, build_config: dict, eq: bluemira.equilibria.equilibrium.Equilibrium, source: NeutronSourceCreator)

Bases: bluemira.codes.interface.CodesSolver, abc.ABC

Inheritance diagram of bluemira.codes.openmc.solver.OpenMCNeutronicsSolver

OpenMC 2D neutronics solver

Parameters:
params: bluemira.codes.openmc.params.OpenMCNeutronicsSolverParams
setup_cls: type[OpenMCBaseSetup]

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.

teardown_cls: type[bluemira.codes.interface.CodesTeardown]

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.

name: str = 'OpenMC'

The name of the solver.

In the base class, this is used to find mappings and specialise error messages for the concrete solver.

param_cls: type[bluemira.codes.openmc.params.OpenMCNeutronicsSolverParams]
run_mode_cls: type[OpenMCRunModes]

Class enumerating the run modes for this solver.

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

run_cls: type[OpenMCRun]

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.

build_config
out_path
eq
property source: NeutronSourceCreator

Source term for OpenMC

Return type:

NeutronSourceCreator

property tally_function: TALLY_FUNCTION_TYPE

Function used to set up tallies

Return type:

TALLY_FUNCTION_TYPE

execute(run_mode, *, debug=False) tuple[bluemira.codes.openmc.output.OpenMCCSGResult | bluemira.codes.openmc.output.OpenMCDAGMCResult, bluemira.base.parameter_frame.ParameterFrame] | dict[int, float]

Execute the setup, run, and teardown tasks, in order.

Return type:

tuple[bluemira.codes.openmc.output.OpenMCCSGResult | bluemira.codes.openmc.output.OpenMCDAGMCResult, bluemira.base.parameter_frame.ParameterFrame] | dict[int, float]

_single_run(run_mode: OpenMCRunModes, source_params: bluemira.codes.openmc.params.PlasmaSourceParameters, runtime_params: OpenMCSimulationRuntimeParameters, *, debug=False) tuple[bluemira.codes.openmc.output.OpenMCCSGResult | bluemira.codes.openmc.output.OpenMCDAGMCResult, bluemira.base.parameter_frame.ParameterFrame] | dict[int, float]
Parameters:
Return type:

tuple[bluemira.codes.openmc.output.OpenMCCSGResult | bluemira.codes.openmc.output.OpenMCDAGMCResult, bluemira.base.parameter_frame.ParameterFrame] | dict[int, float]

class bluemira.codes.openmc.solver.OpenMCCSGNeutronicsSolver(params: dict | bluemira.base.parameter_frame.ParameterFrame, build_config: dict, eq: bluemira.equilibria.equilibrium.Equilibrium, source: NeutronSourceCreator, neutronics_model: bluemira.radiation_transport.neutronics.neutronics_axisymmetric.NeutronicsReactor, op_cond: matproplib.conditions.OperationalConditions, tally_function: TALLY_FUNCTION_TYPE | None = None)

Bases: OpenMCNeutronicsSolver

Inheritance diagram of bluemira.codes.openmc.solver.OpenMCCSGNeutronicsSolver

Solver for OpenMC CSG neutronics

Parameters:
setup_cls: type[OpenMCCSGSetup]

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.

teardown_cls: type[bluemira.codes.interface.CodesTeardown]

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.

neutronics_model
materials
cell_arrays
tally_function

Function used to set up tallies

_single_run(run_mode: OpenMCRunModes, source_params: bluemira.codes.openmc.params.PlasmaSourceParameters, runtime_params: OpenMCSimulationRuntimeParameters, *, debug=False) tuple[bluemira.codes.openmc.output.OpenMCCSGResult, bluemira.base.parameter_frame.ParameterFrame] | dict[int, float]
Parameters:
Return type:

tuple[bluemira.codes.openmc.output.OpenMCCSGResult, bluemira.base.parameter_frame.ParameterFrame] | dict[int, float]

class bluemira.codes.openmc.solver.OpenMCDAGMCNeutronicsSolver(params: dict | bluemira.base.parameter_frame.ParameterFrame, build_config: dict, eq: bluemira.equilibria.equilibrium.Equilibrium, source: NeutronSourceCreator, dagmc_model_path: pathlib.Path, materials, tally_function: TALLY_FUNCTION_TYPE | None = None)

Bases: OpenMCNeutronicsSolver

Inheritance diagram of bluemira.codes.openmc.solver.OpenMCDAGMCNeutronicsSolver

Solver for OpenMC DAGMC neutronics

Parameters:
  • params (dict | bluemira.base.parameter_frame.ParameterFrame)

  • build_config (dict)

  • eq (bluemira.equilibria.equilibrium.Equilibrium)

  • source (NeutronSourceCreator)

  • dagmc_model_path (pathlib.Path)

  • tally_function (TALLY_FUNCTION_TYPE | None)

setup_cls: type[OpenMCDAGSetup]

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.

teardown_cls: type[bluemira.codes.interface.CodesTeardown]

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.

dagmc_model_path
materials
tally_function

Function used to set up tallies

_single_run(run_mode: OpenMCRunModes, source_params: bluemira.codes.openmc.params.PlasmaSourceParameters, runtime_params: OpenMCSimulationRuntimeParameters, *, debug=False) tuple[bluemira.codes.openmc.output.OpenMCDAGMCResult, bluemira.base.parameter_frame.ParameterFrame] | dict[int, float]
Parameters:
Return type:

tuple[bluemira.codes.openmc.output.OpenMCDAGMCResult, bluemira.base.parameter_frame.ParameterFrame] | dict[int, float]