- cell_idCell ID to modify
C++ Type:int
Controllable:No
Description:Cell ID to modify
OpenMCCellMaterialFill
Description
OpenMCCellMaterialFill is a ModelModifier that sets the fill of an OpenMC cell to a user-specified material or list of materials (for distributed cells), prior to execution. If the cell in question is a distribcell (has multiple instances throughout the geometry), then the material in each instance can be individually modified (by providing multiple values for material_ids) or the same material can be applied to all distribcells at once (by providing a single entry in material_ids).
Example Input File Syntax
The following input will modify the material in cell 2; there are three instances of cell 2, and each is modified to material 1.
[Problem<<<{"href": "../../syntax/Problem/index.html"}>>>]
type = OpenMCCellAverageProblem
[ModelModifiers<<<{"href": "../../syntax/Problem/ModelModifiers/index.html"}>>>]
[one]
type = OpenMCCellMaterialFill<<<{"description": "Modifies the cell fill within an OpenMC cell", "href": "OpenMCCellMaterialFill.html"}>>>
cell_id<<<{"description": "Cell ID to modify"}>>> = 2
material_ids<<<{"description": "IDs of the materials to fill into the cell; the length of this array can be one material ID that will be applied to all instances. Otherwise, it must match the number of instances of the cell"}>>> = '1 1 1'
[]
[]
[](test/tests/model_modifiers/cell_material_fill/openmc.i)Providing materials via file
The material_ids_file parameter is powerful for larger models where it would be too tedious and extremely difficult to use the material_ids param in the input file. However, using a file-based set of materials requires care when creating the HDF5 (*.h5) file. For TRISO problems specifically, there is a bit of nuance to be aware of. As soon as there is a reason to vary TRISO material composition throughout the reactor (e.g. to study the effects of depletion or to test loading different enrichments), it becomes necessary to use a distribmat list to specify what OpenMC material goes in which TRISO instance. Models not concerned with this can use the same fuel material in every TRISO in the problem, and do not need this feature.
OpenMC allows specifiying the distribmat list of a cell in the python model building script via openmc.Cell.fill = [...]. The actual list can be used to generate an HDF5 file used by Cardinal. See this section for more details. The list needs to have as many entries as there are cell instances in the entire model. Say there are N TRISO cells per fuel cylinder, then the list [...] needs to start with N entries corresponding to the material ("zone") in the first fuel compact. The next N entries should correspond to whatever material goes in the second fuel compact, and so on. It is highly recommended to use the OpenMC plotter when figuring out the order that the cell instances increase throughout the cells in your model.
The material instance list should be constructed carefully! If the ordering of materials is off, the materials may not line up as you expect. Especially in TRISO models, if the wrong number of materials are specified, the materials may not get applied to the geometry as you expect.
Regarding the number of instances for a TRISO cell when using OpenMC's create_triso_lattice: Say there are M physical TRISOs that are inside a cylinder. The number of instances N typically will be greater than M due to the search lattice. When a TRISO particle splits multiple voxels in the search lattice, there is an instance for each voxel that it is a part of to help accelerate transport. Make sure to verify the number of instances of your TRISO fuel cell. This is how many entries need to exist for each fuel compact, which is not the same as the actual physical number of spheres in the fuel cylinder.
How to automate material fill to HDF5
Here is an exmaple of how to generate an HDF5 file that can be used via the material_ids_file parameter. In this example, there is a command line argument to specify a list of material IDs. However, in a model with a large list of materials to specify, it might be infeasible to type out all of the material IDs. In this case, if the user has a variable corresponding to the list of OpenMC materials, e.g. mats_list, they can generate the input parameter mat_ids for the write_ids function in create_material_fill_ids_h5.py by using a list comprehension mat_ids = [mat.id for mat in mats_list].
import numpy as np
import h5py
from argparse import ArgumentParser
def write_ids(mat_ids, filename):
"""
Takes a list of openmc.Materials and writes the ids to an hdf5 file
so that Cardinal can read it in and assign the fill before running
a multiphysics simulation
Parameters
----------
mat_list : list int, the list of materials for the zoning
filename : str, filename to write the information to
"""
if not filename.endswith(".h5"):
raise ValueError(f"The specified filename {filename} must end with .h5")
with h5py.File(filename, "w") as f:
f.create_dataset("material_fill_ids", data=mat_ids, dtype=np.int32)
if __name__ == "__main__":
ap = ArgumentParser()
ap.add_argument(
"-i",
"--mat_ids",
dest="mat_ids",
type=int,
nargs="+",
default = [1,2,1],
help="List of material IDs",
)
ap.add_argument(
"-f",
"--file_name",
dest="file_name",
type=str,
default = "material_fill_ids.h5",
help="The name of the file to save data in. Must be an .h5 file.",
)
args = ap.parse_args()
write_ids(args.mat_ids, args.file_name)
(test/tests/model_modifiers/cell_material_fill/create_material_fill_ids_h5.py)Input Parameters
- material_idsIDs of the materials to fill into the cell; the length of this array can be one material ID that will be applied to all instances. Otherwise, it must match the number of instances of the cell
C++ Type:std::vector<int>
Controllable:No
Description:IDs of the materials to fill into the cell; the length of this array can be one material ID that will be applied to all instances. Otherwise, it must match the number of instances of the cell
- material_ids_fileFilename containing material ids to assign to the cell instances. Must be an HDF5 (*.h5) file.
C++ Type:std::string
Controllable:No
Description:Filename containing material ids to assign to the cell instances. Must be an HDF5 (*.h5) file.
Optional Parameters
- control_tagsAdds user-defined labels for accessing object parameters via control logic.
C++ Type:std::vector<std::string>
Controllable:No
Description:Adds user-defined labels for accessing object parameters via control logic.
- enableTrueSet the enabled status of the MooseObject.
Default:True
C++ Type:bool
Controllable:No
Description:Set the enabled status of the MooseObject.