ukaea/neutronics_material_maker

adding scale material outputs

shimwell opened this issue · 3 comments

To allow shift material format to be exported we could add another function like this one that outputs mcnp materials

def make_mcnp_material(mat):
"""Returns the material in a string compatable with MCNP6"""
if mat.material_id is None:
raise ValueError(
"Material.material_id needs setting before mcnp_material can be made"
)
if mat.material_tag is None:
name = mat.material_name
else:
name = mat.material_tag
if mat.zaid_suffix is None:
zaid_suffix = ""
else:
zaid_suffix = mat.zaid_suffix
mat_card = [
"c "
+ name
+ " density "
+ f"{mat.openmc_material.get_mass_density():.{mat.decimal_places}e}"
+ " g/cm3"
]
for i, isotope in enumerate(mat.openmc_material.nuclides):
if i == 0:
start = f"M{mat.material_id: <5}"
else:
start = " "
if isotope[2] == "ao":
prefix = " "
elif isotope[2] == "wo":
prefix = " -"
rest = (
isotope_to_zaid(isotope[0])
+ zaid_suffix
+ prefix
+ f"{isotope[1]:.{mat.decimal_places}e}"
)
mat_card.append(start + rest)
return "\n".join(mat_card)

then we could add a new property for the scale shift export in materials.py like this one that does mcnp

@property
def mcnp_material(self):
"""
Returns a MCNP version of the Material. Requires the
Material.material_id to be set. Decimal places can be controlled with
the Material.decimal_places attribute.
:type: str
"""
self._mcnp_material = make_mcnp_material(self)
return self._mcnp_material
@mcnp_material.setter
def mcnp_material(self, value):
self._mcnp_material = value

and another in the multimaterial class like this one

@property
def mcnp_material(self):
"""
Returns a MCNP version of the Material.
:type: str
"""
self._mcnp_material = make_mcnp_material(self)
return self._mcnp_material
@mcnp_material.setter
def mcnp_material(self, value):
self._mcnp_material = value

what do you think @jbae11 does this look like the best option

@shimwell is there a dictionary of isotopic atomic mass (e.g. {'h1': 1.0078})?

So Shift's material composition unit is [atoms/barn-cm], meaning that the material density is 'baked into' the material definition, which is different than MCNP. Thus I'd need the atomic mass to convert from wo. If there isn't a dictionary of isotopic atomic mass, I think I have one, I can add that in the utils.py as well. Let me know :)

Perhaps openmc.Material().get_nuclide_atom_densities() is useful here

solved in #114