Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
54 commits
Select commit Hold shift + click to select a range
2555b95
Factor out to_xml_element methods for XML classes
pshriwise Nov 3, 2022
ad746cb
Writing all main nodes to a single XML file
pshriwise Nov 4, 2022
a09a61e
Writing all output under a single root node
pshriwise Nov 4, 2022
7a9d8c9
Keeping old option to write separate XMLs so I can still use to tests…
pshriwise Nov 4, 2022
0409652
Adding signatures for reading information from an XML node where nece…
pshriwise Nov 4, 2022
cdd2a6b
Correcting doc scope and some reads
pshriwise Nov 4, 2022
bec9bf6
Refactoring model read into it's own function.
pshriwise Nov 4, 2022
81aa653
Factoring out some common lines between reader functions
pshriwise Nov 4, 2022
9391f17
Adding import for single or multiple XMLs
pshriwise Nov 4, 2022
af6b0af
Fix loop variable overwrite
pshriwise Nov 4, 2022
5ac6e87
Properly call read_plots_xml
pshriwise Nov 4, 2022
2e71658
Other bug fixes
pshriwise Nov 4, 2022
b4dcc30
Removing walrus operator
pshriwise Nov 4, 2022
611475a
Restructureing input function calls a little
pshriwise Nov 5, 2022
021bb28
Adding initial test for exporting model.xmls. Correcting material maps
pshriwise Nov 5, 2022
abd3d51
Correcting doc strings for material mapping sent to
pshriwise Nov 5, 2022
662d83a
Running some existing regression tests using single XML file
pshriwise Nov 10, 2022
1e7dbe9
Making sure meshes are only written once to a model.xml file
pshriwise Nov 10, 2022
d034e1d
Apply suggestions from code review
pshriwise Nov 24, 2022
b76825f
Addressing some comments from PR
pshriwise Nov 24, 2022
d984716
Adding ability to specify an input filename to the executable or to t…
pshriwise Nov 24, 2022
366f9e9
Test comment and updated error messages
pshriwise Nov 24, 2022
1e6cb68
Addressing a few more comments in C++ code
pshriwise Nov 24, 2022
7a203fb
Correcting parenthesis
pshriwise Nov 24, 2022
fe47d56
Spot check in error message from failed run
pshriwise Nov 24, 2022
6f7a6fe
Updating model XML file format w/ indentation.
pshriwise Nov 25, 2022
5d1ead2
Addressing some more PR comments. A couple of typo fixes too.
pshriwise Nov 26, 2022
e7f95b0
Docstring correction and a note about the recursion
pshriwise Nov 28, 2022
b3225be
Adding executor tests
pshriwise Nov 29, 2022
72ff942
Checking RuntimeError message correctly
pshriwise Nov 29, 2022
7f5d2a5
Refactoring model_xml regression tests a bit and adding input checking
pshriwise Nov 29, 2022
3f4a9eb
Reordering geometry XML element attributes
pshriwise Nov 29, 2022
83cf684
Updating expected inputs with reordering
pshriwise Nov 29, 2022
2c27d10
Moving other relevant XML reorder calls and updating expected input a…
pshriwise Nov 29, 2022
cd7c3bf
Updates to import/export methods suggested by @paulromano
pshriwise Dec 6, 2022
ef2f690
Updating handling of single XML input to leverage existing settings::…
pshriwise Dec 6, 2022
574845b
Moving Model.from_separate_xmls back to Model.from_xml.
pshriwise Dec 6, 2022
270331a
Adding function to check if a path is a directory
pshriwise Dec 6, 2022
bc1791d
Updates to simplify model filename checking
pshriwise Dec 6, 2022
5634d83
Changing name of input argument for Python executor
pshriwise Dec 6, 2022
d639d1d
Docstring correction
pshriwise Dec 6, 2022
939adbe
Updating tests to reflect changes to API
pshriwise Dec 6, 2022
7fdfed2
Some cleanup of file utils
pshriwise Dec 7, 2022
55d77cf
Small improvements to read_model_xml
pshriwise Dec 7, 2022
7873b4d
Update tests/regression_tests/model_xml/test.py
pshriwise Dec 7, 2022
ef13643
Some housekeeping in the Python classes
pshriwise Dec 7, 2022
9c942db
Correct use of mesh memo in single XML export
pshriwise Dec 7, 2022
916863f
Renaming and docstring/comment updates
pshriwise Dec 7, 2022
145594e
Apply @paulromano suggestions from code review
pshriwise Dec 13, 2022
f3bcad3
Addressing comments from @paulromano
pshriwise Dec 13, 2022
43687e5
Improve comment on recursion arguments
pshriwise Dec 13, 2022
2eca57a
Adding mesh memo to Settings.from_xml_element
pshriwise Dec 14, 2022
25f2bd5
Several small fixes
paulromano Dec 23, 2022
64aee3b
Merge pull request #16 from paulromano/model-xml-pr
pshriwise Dec 23, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Running some existing regression tests using single XML file
  • Loading branch information
pshriwise committed Dec 6, 2022
commit 662d83a7dd72240b4da8594319bab416977ec71b
2 changes: 2 additions & 0 deletions tests/regression_tests/adj_cell_rotation/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@

from .test import model
1 change: 1 addition & 0 deletions tests/regression_tests/energy_laws/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from .test import model
1 change: 1 addition & 0 deletions tests/regression_tests/lattice_multiple/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from .test import model
Empty file.
38 changes: 38 additions & 0 deletions tests/regression_tests/model_xml/inputs_true.dat
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<?xml version='1.0' encoding='utf-8'?>
<model>
<materials>
Comment thread
paulromano marked this conversation as resolved.
Resolved
<material depletable="true" id="1">
<density units="g/cc" value="10.0" />
<nuclide ao="1.0" name="U235" />
</material>
<material id="2">
<density units="g/cc" value="0.1" />
<nuclide ao="0.1" name="H1" />
</material>
</materials>
<geometry>
<cell id="1" material="1" region="-1" universe="1" />
<cell id="2" material="2" region="1" universe="1" />
<cell id="3" fill="1" region="2 -3 4 -5 6 -8" rotation="10 20 30" universe="2" />
<cell id="4" fill="1" region="2 -3 4 -5 8 -7" translation="0 0 15" universe="2" />
<surface id="1" type="sphere" coeffs="1.0 0.0 0.0 5.0" />
<surface id="2" name="minimum x" type="x-plane" boundary="vacuum" coeffs="-7.5" />
<surface id="3" name="maximum x" type="x-plane" boundary="vacuum" coeffs="7.5" />
<surface id="4" name="minimum y" type="y-plane" boundary="vacuum" coeffs="-7.5" />
<surface id="5" name="maximum y" type="y-plane" boundary="vacuum" coeffs="7.5" />
<surface id="6" type="z-plane" boundary="vacuum" coeffs="-7.5" />
<surface id="7" type="z-plane" boundary="vacuum" coeffs="22.5" />
<surface id="8" type="z-plane" coeffs="7.5" />
</geometry>
<settings>
<run_mode>eigenvalue</run_mode>
<particles>10000</particles>
<batches>10</batches>
<inactive>5</inactive>
<source strength="1.0">
<space type="box">
<parameters>-4.0 -4.0 -4.0 4.0 4.0 4.0</parameters>
</space>
</source>
</settings>
</model>
76 changes: 76 additions & 0 deletions tests/regression_tests/model_xml/test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
from difflib import unified_diff
import filecmp
import os

import openmc
import pytest

from tests.testing_harness import PyAPITestHarness, colorize

# use a few models from other tests to make sure the same results are
# produced when using a single model.xml file as input
from ..adj_cell_rotation import model as adj_cell_rotation_model
Comment thread
paulromano marked this conversation as resolved.
Resolved
from ..lattice_multiple import model as lattice_mult_model
from ..energy_laws import model as energy_laws_model
from ..photon_production import model as photon_prod_model


class ModelXMLTestHarness(PyAPITestHarness):
"""Accept a results file to check against and assume inputs_true is the contents of a model.xml file.
"""
def __init__(self, model=None, inputs_true=None, results_true=None):
statepoint_name = f'statepoint.{model.settings.batches}.h5'
super().__init__(statepoint_name, model, inputs_true)

self.results_true = 'results_true.dat' if results_true is None else results_true

def _build_inputs(self):
self._model.export_to_xml(separate_xmls=False)

def _get_inputs(self):
return open('model.xml').read()

def _compare_inputs(self):
"""Skip input comparisons for now
"""
pass

def _compare_results(self):
"""Make sure the current results agree with the reference."""
compare = filecmp.cmp('results_test.dat', self.results_true)
if not compare:
expected = open(self.results_true).readlines()
actual = open('results_test.dat').readlines()
diff = unified_diff(expected, actual, self.results_true,
'results_test.dat')
print('Result differences:')
print(''.join(colorize(diff)))
os.rename('results_test.dat', 'results_error.dat')
assert compare, 'Results do not agree'

def _cleanup(self):
super()._cleanup()
if os.path.exists('model.xml'):
os.remove('model.xml')


models = [
'adj_cell_rotation_model',
'lattice_mult_model',
'energy_laws_model',
'photon_prod_model'
]
paths = [
'../adj_cell_rotation',
'../lattice_multiple',
'../energy_laws',
'../photon_production'
]
Comment thread
paulromano marked this conversation as resolved.
Resolved


@pytest.mark.parametrize("model, path", zip(models, paths))
def test_model_xml(model, path, request):
inputs = path + "/inputs_true.dat"
results = path + "/results_true.dat"
harness = ModelXMLTestHarness(request.getfixturevalue(model), inputs, results)
harness.main()
1 change: 1 addition & 0 deletions tests/regression_tests/photon_production/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from .test import model