mirror of
https://github.com/openmc-dev/openmc.git
synced 2026-07-27 05:35:49 -04:00
Adding initial test for exporting model.xmls. Correcting material maps
This commit is contained in:
parent
611475a835
commit
021bb280c9
2 changed files with 23 additions and 1 deletions
|
|
@ -230,8 +230,9 @@ class Model:
|
|||
|
||||
model.settings = openmc.Settings.from_xml_element(root.find('settings'))
|
||||
model.materials = openmc.Materials.from_xml_element(root.find('materials'))
|
||||
materials = {str(m.id): m for m in model.materials}
|
||||
model.geometry = \
|
||||
openmc.Geometry.from_xml_element(root.find('geometry'), model.materials)
|
||||
openmc.Geometry.from_xml_element(root.find('geometry'), materials)
|
||||
|
||||
if root.find('tallies'):
|
||||
model.tallies = openmc.Tallies.from_xml_element(root.find('tallies'))
|
||||
|
|
|
|||
|
|
@ -7,6 +7,8 @@ import pytest
|
|||
import openmc
|
||||
import openmc.lib
|
||||
|
||||
from .. import cdtemp
|
||||
|
||||
|
||||
@pytest.fixture(scope='function')
|
||||
def pin_model_attributes():
|
||||
|
|
@ -529,3 +531,22 @@ def test_calc_volumes(run_in_tmpdir, pin_model_attributes, mpi_intracomm):
|
|||
assert openmc.lib.materials[3].volume == mats[2].volume
|
||||
|
||||
test_model.finalize_lib()
|
||||
|
||||
def test_model_xml():
|
||||
|
||||
with cdtemp():
|
||||
# load a model from examples
|
||||
pwr_model = openmc.examples.pwr_core()
|
||||
|
||||
# export to separate XMLs manually
|
||||
pwr_model.settings.export_to_xml('settings_ref.xml')
|
||||
pwr_model.materials.export_to_xml('materials_ref.xml')
|
||||
pwr_model.geometry.export_to_xml('geometry_ref.xml')
|
||||
|
||||
# now write and read a model.xml file
|
||||
pwr_model.export_to_xml(separate_xmls=False)
|
||||
new_model = openmc.Model.from_xml(separate_xmls=False)
|
||||
|
||||
# make sure we can also export this again to separate
|
||||
# XML files
|
||||
new_model.export_to_xml(separate_xmls=True)
|
||||
Loading…
Add table
Add a link
Reference in a new issue