Skip to content

Commit

Permalink
for #7170 accept model.xml for material import
Browse files Browse the repository at this point in the history
  • Loading branch information
moellep committed Feb 20, 2025
1 parent ac35244 commit 9557c09
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 1 deletion.
2 changes: 1 addition & 1 deletion sirepo/package_data/static/json/openmc-schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -359,7 +359,7 @@
},
"geometryInput": {
"dagmcFile": ["Model file", "InputFile", "", "A DAGMC (.h5m) or Step (.stp) file"],
"materialsFile": ["Materials XML file (optional)", "InputFile", "", "An OpenMC materials.xml mapping from names to volume properties", false],
"materialsFile": ["Materials XML file (optional)", "InputFile", "", "An OpenMC materials.xml (or model.xml) mapping from names to volume properties", false],
"exampleURL": ["", "String", ""]
},
"geometry3DReport": {
Expand Down
2 changes: 2 additions & 0 deletions sirepo/package_data/template/openmc/extract_dagmc.py.jinja
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ def _name(material_name):

def add_materials(volumes):
e = xml.etree.ElementTree.parse("{{ materialsFile }}").getroot()
if e.find("materials"):
e = e.find("materials")
for child in e:
n = _name(child.attrib.get("name"))
if not n or n not in volumes:
Expand Down
14 changes: 14 additions & 0 deletions sirepo/template/openmc.py
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,20 @@ def stateful_compute_verify_geometry(data, **kwargs):
"""Ensures the standard material db is available and returns the state of the
geometry animation directory.
"""

# TODO(pjm): the MGXS energy list should be a dynamically computed enum
# import openmc.mgxs

# def sort_name(value):
# m = re.search(r'^(.*?)\-(\d+)', value)
# assert m
# return f"{m.group(1)} {m.group(2).zfill(5)}"

# enum.EnergyGroup = [n[0] for n in sorted(
# map(lambda v: [v, sort_name(v)], openmc.mgxs.GROUP_STRUCTURES.keys()),
# key=lambda v: v[1],
# )]

_prep_standard_material_cache()
return PKDict(
hasGeometry=simulation_db.simulation_dir(SIM_TYPE, sid=data.simulationId)
Expand Down

0 comments on commit 9557c09

Please sign in to comment.