fusion-energy / openmc-dagmc-wrapper

A Python package that extends OpenMC base classes to provide convenience features and standardized tallies when simulating DAGMC geometry with OpenMC.
https://openmc-dagmc-wrapper.readthedocs.io/
MIT License
7 stars 2 forks source link

Density of liquids #101

Closed RemDelaporteMathurin closed 2 years ago

RemDelaporteMathurin commented 2 years ago

I tried to run a sim using correspondence_dict with FLiBe but I get an error asking me to give the temperature:

import openmc_dagmc_wrapper as odw

material_tag_to_material_dict = {
    "lead": "Lead",
    "flibe": "FLiBe",
    "inner_tank_wall": "eurofer",
}

materials = odw.Materials(
    h5m_filename='dagmc_not_merged.h5m',
    correspondence_dict=material_tag_to_material_dict,
)
  File "mwe.py", line 9, in <module>
    materials = odw.Materials(
  File "/opt/conda/lib/python3.8/site-packages/openmc_dagmc_wrapper/Materials.py", line 25, in __init__
    self.set_openmc_materials()
  File "/opt/conda/lib/python3.8/site-packages/openmc_dagmc_wrapper/Materials.py", line 41, in set_openmc_materials
    openmc_material = create_material(material_tag, material_entry)
  File "/opt/conda/lib/python3.8/site-packages/openmc_dagmc_wrapper/utils.py", line 10, in create_material
    openmc_material = nmm.Material.from_library(
  File "/opt/conda/lib/python3.8/site-packages/neutronics_material_maker/material.py", line 875, in from_library
    return Material(name=name, **entry)
  File "/opt/conda/lib/python3.8/site-packages/neutronics_material_maker/material.py", line 197, in __init__
    self._make_openmc_material()
  File "/opt/conda/lib/python3.8/site-packages/neutronics_material_maker/material.py", line 655, in _make_openmc_material
    openmc_material = self._add_density(openmc_material)
  File "/opt/conda/lib/python3.8/site-packages/neutronics_material_maker/material.py", line 765, in _add_density
    raise ValueError(
ValueError: Material.temperature is needed to calculate the density
shimwell commented 2 years ago

Ah yes this one requires more than a string.

As the density is temperature dependent it needs an openmc material or neutronics material maker object passing in

import neutronics_material_maker as nmm
my_mat = nmm.Material.from_library(name='FLiBe', temperature=600, enrichment=60)
my_mat.openmc_material 

Then pass in my_mat to the correspondence_dict This also gives the opportunity to enrich the Li6 content

RemDelaporteMathurin commented 2 years ago

Ah yes sorry

My workaround was:

import openmc
import openmc_dagmc_wrapper as odw
import neutronics_material_maker as nmm

# could set to dagmc.h5m if the imprinted and merged geometry is preferred
my_h5m_filename = "dagmc_not_merged.h5m"

# this links the material tags in the dagmc h5m file with materials.
# these materials are input as strings so they will be looked up in the
# neutronics material maker package
material_tag_to_material_dict = {
    "lead": "Lead",
    "flibe": nmm.Material.from_library(name="FLiBe", temperature=650+273.15, pressure=10.1e5, temperature_to_neutronics_code=False),
    "inner_tank_wall": "eurofer",
}

materials = odw.Materials(
    h5m_filename=my_h5m_filename,
    correspondence_dict=material_tag_to_material_dict,
)

I didn't use the .openmc_material attribute though and it worked!

shimwell commented 2 years ago

I guess it works with or without the openmc_material attribute