mirror of
https://github.com/openmc-dev/openmc.git
synced 2026-07-28 14:15:42 -04:00
Refactoring model_xml regression tests a bit and adding input checking
This commit is contained in:
parent
72ff942226
commit
7f5d2a5839
5 changed files with 201 additions and 22 deletions
|
|
@ -0,0 +1,38 @@
|
|||
<?xml version='1.0' encoding='utf-8'?>
|
||||
<model>
|
||||
<materials>
|
||||
<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>
|
||||
23
tests/regression_tests/model_xml/energy_laws_inputs_true.dat
Normal file
23
tests/regression_tests/model_xml/energy_laws_inputs_true.dat
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
<?xml version='1.0' encoding='utf-8'?>
|
||||
<model>
|
||||
<materials>
|
||||
<material depletable="true" id="1">
|
||||
<density units="g/cm3" value="20.0" />
|
||||
<nuclide ao="1.0" name="U233" />
|
||||
<nuclide ao="1.0" name="Am244" />
|
||||
<nuclide ao="1.0" name="H2" />
|
||||
<nuclide ao="1.0" name="Na23" />
|
||||
<nuclide ao="1.0" name="Ta181" />
|
||||
</material>
|
||||
</materials>
|
||||
<geometry>
|
||||
<cell id="1" material="1" region="-1" universe="1" />
|
||||
<surface id="1" type="sphere" boundary="reflective" coeffs="0.0 0.0 0.0 100.0" />
|
||||
</geometry>
|
||||
<settings>
|
||||
<run_mode>eigenvalue</run_mode>
|
||||
<particles>1000</particles>
|
||||
<batches>10</batches>
|
||||
<inactive>5</inactive>
|
||||
</settings>
|
||||
</model>
|
||||
|
|
@ -0,0 +1,53 @@
|
|||
<?xml version='1.0' encoding='utf-8'?>
|
||||
<model>
|
||||
<materials>
|
||||
<material depletable="true" id="1" name="UO2">
|
||||
<density units="g/cm3" value="10.0" />
|
||||
<nuclide ao="1.0" name="U235" />
|
||||
<nuclide ao="2.0" name="O16" />
|
||||
</material>
|
||||
<material id="2" name="light water">
|
||||
<density units="g/cm3" value="1.0" />
|
||||
<nuclide ao="2.0" name="H1" />
|
||||
<nuclide ao="1.0" name="O16" />
|
||||
<sab name="c_H_in_H2O" />
|
||||
</material>
|
||||
</materials>
|
||||
<geometry>
|
||||
<cell id="1" material="1" region="-1" universe="1" />
|
||||
<cell id="2" material="2" region="1" universe="1" />
|
||||
<cell id="3" material="1" region="-2" universe="2" />
|
||||
<cell id="4" material="2" region="2" universe="2" />
|
||||
<cell id="5" fill="3" universe="4" />
|
||||
<cell id="6" fill="5" region="3 -4 5 -6" universe="6" />
|
||||
<lattice id="3">
|
||||
<pitch>1.2 1.2</pitch>
|
||||
<outer>1</outer>
|
||||
<dimension>2 2</dimension>
|
||||
<lower_left>-1.2 -1.2</lower_left>
|
||||
<universes>
|
||||
2 1
|
||||
1 1 </universes>
|
||||
</lattice>
|
||||
<lattice id="5">
|
||||
<pitch>2.4 2.4</pitch>
|
||||
<dimension>2 2</dimension>
|
||||
<lower_left>-2.4 -2.4</lower_left>
|
||||
<universes>
|
||||
4 4
|
||||
4 4 </universes>
|
||||
</lattice>
|
||||
<surface id="1" type="z-cylinder" coeffs="0.0 0.0 0.4" />
|
||||
<surface id="2" type="z-cylinder" coeffs="0.0 0.0 0.5" />
|
||||
<surface id="3" name="minimum x" type="x-plane" boundary="reflective" coeffs="-2.4" />
|
||||
<surface id="4" name="maximum x" type="x-plane" boundary="reflective" coeffs="2.4" />
|
||||
<surface id="5" name="minimum y" type="y-plane" boundary="reflective" coeffs="-2.4" />
|
||||
<surface id="6" name="maximum y" type="y-plane" boundary="reflective" coeffs="2.4" />
|
||||
</geometry>
|
||||
<settings>
|
||||
<run_mode>eigenvalue</run_mode>
|
||||
<particles>1000</particles>
|
||||
<batches>10</batches>
|
||||
<inactive>5</inactive>
|
||||
</settings>
|
||||
</model>
|
||||
|
|
@ -0,0 +1,67 @@
|
|||
<?xml version='1.0' encoding='utf-8'?>
|
||||
<model>
|
||||
<materials>
|
||||
<material id="1">
|
||||
<density units="g/cm3" value="2.6989" />
|
||||
<nuclide ao="1.0" name="Al27" />
|
||||
</material>
|
||||
</materials>
|
||||
<geometry>
|
||||
<cell id="1" material="void" region="-1 2 -3" universe="1" />
|
||||
<cell id="2" material="1" region="-1 3 -4" universe="1" />
|
||||
<cell id="3" material="void" region="~(-1 2 -4)" universe="1" />
|
||||
<surface id="1" type="x-cylinder" boundary="vacuum" coeffs="0.0 0.0 1.0" />
|
||||
<surface id="2" type="x-plane" boundary="vacuum" coeffs="-1.0" />
|
||||
<surface id="3" type="x-plane" coeffs="1.0" />
|
||||
<surface id="4" type="x-plane" boundary="vacuum" coeffs="1000000000.0" />
|
||||
</geometry>
|
||||
<settings>
|
||||
<run_mode>fixed source</run_mode>
|
||||
<particles>10000</particles>
|
||||
<batches>1</batches>
|
||||
<source strength="1.0">
|
||||
<space type="point">
|
||||
<parameters>0 0 0</parameters>
|
||||
</space>
|
||||
<angle type="monodirectional" reference_uvw="1.0 0.0 0.0" />
|
||||
<energy type="discrete">
|
||||
<parameters>14000000.0 1.0</parameters>
|
||||
</energy>
|
||||
</source>
|
||||
<electron_treatment>ttb</electron_treatment>
|
||||
<photon_transport>true</photon_transport>
|
||||
<cutoff>
|
||||
<energy_photon>1000.0</energy_photon>
|
||||
</cutoff>
|
||||
</settings>
|
||||
<tallies>
|
||||
<filter id="1" type="surface">
|
||||
<bins>1</bins>
|
||||
</filter>
|
||||
<filter id="2" type="particle">
|
||||
<bins>neutron photon electron positron</bins>
|
||||
</filter>
|
||||
<tally id="1">
|
||||
<filters>1 2</filters>
|
||||
<scores>current</scores>
|
||||
</tally>
|
||||
<tally id="2">
|
||||
<filters>2</filters>
|
||||
<nuclides>Al27 total</nuclides>
|
||||
<scores>total (n,gamma)</scores>
|
||||
<estimator>tracklength</estimator>
|
||||
</tally>
|
||||
<tally id="3">
|
||||
<filters>2</filters>
|
||||
<nuclides>Al27 total</nuclides>
|
||||
<scores>total heating (n,gamma)</scores>
|
||||
<estimator>collision</estimator>
|
||||
</tally>
|
||||
<tally id="4">
|
||||
<filters>2</filters>
|
||||
<nuclides>Al27 total</nuclides>
|
||||
<scores>total heating (n,gamma)</scores>
|
||||
<estimator>analog</estimator>
|
||||
</tally>
|
||||
</tallies>
|
||||
</model>
|
||||
|
|
@ -10,9 +10,9 @@ 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.test import model as adj_cell_rotation_model
|
||||
from ..lattice_multiple.test import model as lattice_mult_model
|
||||
from ..lattice_multiple.test import model as lattice_multiple_model
|
||||
from ..energy_laws.test import model as energy_laws_model
|
||||
from ..photon_production.test import model as photon_prod_model
|
||||
from ..photon_production.test import model as photon_production_model
|
||||
|
||||
|
||||
class ModelXMLTestHarness(PyAPITestHarness):
|
||||
|
|
@ -30,10 +30,10 @@ class ModelXMLTestHarness(PyAPITestHarness):
|
|||
def _get_inputs(self):
|
||||
return open('model.xml').read()
|
||||
|
||||
def _compare_inputs(self):
|
||||
"""Skip input comparisons for now
|
||||
"""
|
||||
pass
|
||||
# def _compare_inputs(self):
|
||||
# """Skip input comparisons for now
|
||||
# """
|
||||
# pass
|
||||
|
||||
def _compare_results(self):
|
||||
"""Make sure the current results agree with the reference."""
|
||||
|
|
@ -54,25 +54,23 @@ class ModelXMLTestHarness(PyAPITestHarness):
|
|||
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'
|
||||
test_names = [
|
||||
'adj_cell_rotation',
|
||||
'lattice_multiple',
|
||||
'energy_laws',
|
||||
'photon_production'
|
||||
]
|
||||
|
||||
|
||||
@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)
|
||||
@pytest.mark.parametrize("test_name", test_names, ids=lambda test: test)
|
||||
def test_model_xml(test_name, request):
|
||||
openmc.reset_auto_ids()
|
||||
|
||||
test_path = '../' + test_name
|
||||
results = test_path + "/results_true.dat"
|
||||
inputs = test_name + "_inputs_true.dat"
|
||||
model_name = test_name + "_model"
|
||||
harness = ModelXMLTestHarness(request.getfixturevalue(model_name), inputs, results)
|
||||
harness.main()
|
||||
|
||||
def test_input_arg(run_in_tmpdir):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue