Making materials from components#
To carry out a neutronics simulation material definitions are needed.
In OpenMC, materials can be defined using components that define elements, nuclides and their fractions.
This python notebook allows users to create different materials from components using OpenMC.
First import OpenMC and configure the nuclear data path
import openmc
from pathlib import Path
# Setting the cross section path to the correct location in the docker image.
# If you are running this outside the docker image you will have to change this path to your local cross section path.
openmc.config['cross_sections'] = Path.home() / 'nuclear_data' / 'cross_sections.xml'
The following code block is a simple example of creating a material (water H2O) from components.
This allows one to make a material in a single function call.
import openmc
water_mat = openmc.Material(
name="water",
components={'H': 2.0, 'O': 1.0},
percent_type="ao",
density=0.99821,
density_units='g/cm3'
)
water_mat
Material
ID = 1
Name = water
Temperature = None
Density = 0.99821 [g/cm3]
Volume = None [cm^3]
Depletable = False
S(a,b) Tables
Nuclides
H1 = 1.99968852 [ao]
H2 = 0.00031148 [ao]
O16 = 0.9976206 [ao]
O17 = 0.000379 [ao]
O18 = 0.0020004 [ao]
Materials can also be made from nuclides as well as elements. For example in this material we specify both nuclides and elements.
heavy_water_mat = openmc.Material(
name="water",
components={'H1': 1.0, 'H2':1.0, 'O': 1.0},
percent_type="ao",
density=1.11,
density_units='g/cm3'
)
heavy_water_mat
Material
ID = 2
Name = water
Temperature = None
Density = 1.11 [g/cm3]
Volume = None [cm^3]
Depletable = False
S(a,b) Tables
Nuclides
H1 = 1.0 [ao]
H2 = 1.0 [ao]
O16 = 0.9976206 [ao]
O17 = 0.000379 [ao]
O18 = 0.0020004 [ao]
More complicated keyword dictionaries can be made with other material keywords such as enrichment.
components = {
'Li': {'percent': 4, 'enrichment': 60.0, 'enrichment_target': 'Li7'},
'Si': 1.0,
'O': 4
}
enriched_Li4SiO4 = openmc.Material(
name="water",
components=components,
percent_type="ao",
density=1.11,
density_units='g/cm3'
)
enriched_Li4SiO4
Material
ID = 3
Name = water
Temperature = None
Density = 1.11 [g/cm3]
Volume = None [cm^3]
Depletable = False
S(a,b) Tables
Nuclides
Li6 = 1.5999999999999999 [ao]
Li7 = 2.4 [ao]
Si28 = 0.9222968 [ao]
Si29 = 0.0468316 [ao]
Si30 = 0.0308716 [ao]
O16 = 3.9904824 [ao]
O17 = 0.001516 [ao]
O18 = 0.0080016 [ao]
Dictionary expansion can also be used. This is where a ** is placed before a dictionary and it gets expanded to keyword args. This can be use full when making a material from a dictionary
mat_from_dict = openmc.Material(
**{
"components": {
"H": 0.1,
"H2": 1.0,
"He": 4
},
"material_id": 1,
"name": "neutron_star",
"percent_type": "ao",
"density": 1e17,
"density_units": "kg/m3",
}
)
mat_from_dict
/opt/hostedtoolcache/Python/3.12.12/x64/lib/python3.12/site-packages/openmc/mixin.py:72: IDWarning: Another Material instance already exists with id=1.
warn(msg, IDWarning)
Material
ID = 1
Name = neutron_star
Temperature = None
Density = 1e+17 [kg/m3]
Volume = None [cm^3]
Depletable = False
S(a,b) Tables
Nuclides
H1 = 0.09998442600000002 [ao]
H2 = 1.5574e-05 [ao]
H2 = 1.0 [ao]
He3 = 8e-06 [ao]
He4 = 3.999992 [ao]
Learning Outcomes from Part 6:
Materials can be made in OpenMC using components and keyword args in a single function call.