mirror of
https://github.com/openmc-dev/openmc.git
synced 2026-07-28 06:05:58 -04:00
Updating the cpp driver test to include testing of the new set_temperature behavior. Includes a fix to the dynamic source test to remove the CMake file as well.
This commit is contained in:
parent
c7fe3ab9a3
commit
00fffc8590
5 changed files with 82 additions and 11 deletions
|
|
@ -1,6 +1,8 @@
|
|||
|
||||
#include "openmc/capi.h"
|
||||
#include "openmc/cell.h"
|
||||
#include "openmc/geometry.h"
|
||||
#include "openmc/summary.h"
|
||||
#include "openmc/tallies/filter.h"
|
||||
#include "openmc/tallies/filter_cell.h"
|
||||
#include "openmc/tallies/tally.h"
|
||||
|
|
@ -29,6 +31,17 @@ int main(int argc, char** argv) {
|
|||
tally->set_filters(filters);
|
||||
tally->set_scores({"flux"});
|
||||
|
||||
// set the temperature of the cell containing
|
||||
// the lattice
|
||||
auto& root_univ = openmc::model::universes[openmc::model::root_universe];
|
||||
auto& lattice_cell = openmc::model::cells[root_univ->cells_[0]];
|
||||
lattice_cell->set_temperature(300, 1, true);
|
||||
|
||||
// the summary file will be used to check that
|
||||
// temperatures were set correctly so clear
|
||||
// error output can be provided
|
||||
openmc::write_summary();
|
||||
|
||||
openmc_run();
|
||||
openmc_finalize();
|
||||
return 0;
|
||||
|
|
|
|||
|
|
@ -2,8 +2,22 @@
|
|||
<geometry>
|
||||
<cell id="1" material="1" region="-1" universe="1" />
|
||||
<cell id="2" material="2" region="1 -2" universe="1" />
|
||||
<cell id="3" material="3" region="2" universe="1" />
|
||||
<cell fill="2" id="4" region="3 -4 5 -6" universe="3" />
|
||||
<lattice id="2">
|
||||
<pitch>4.0 4.0</pitch>
|
||||
<dimension>2 2</dimension>
|
||||
<lower_left>-4.0 -4.0</lower_left>
|
||||
<universes>
|
||||
1 1
|
||||
1 1 </universes>
|
||||
</lattice>
|
||||
<surface coeffs="0.0 0.0 1.5" id="1" type="z-cylinder" />
|
||||
<surface boundary="reflective" coeffs="0.0 0.0 3.0" id="2" type="z-cylinder" />
|
||||
<surface coeffs="0.0 0.0 1.7" id="2" type="z-cylinder" />
|
||||
<surface boundary="reflective" coeffs="-4.0" id="3" name="minimum x" type="x-plane" />
|
||||
<surface boundary="reflective" coeffs="4.0" id="4" name="maximum x" type="x-plane" />
|
||||
<surface boundary="reflective" coeffs="-4.0" id="5" name="minimum y" type="y-plane" />
|
||||
<surface boundary="reflective" coeffs="4.0" id="6" name="maximum y" type="y-plane" />
|
||||
</geometry>
|
||||
<?xml version='1.0' encoding='utf-8'?>
|
||||
<materials>
|
||||
|
|
@ -11,7 +25,11 @@
|
|||
<density units="g/cc" value="11" />
|
||||
<nuclide ao="1.0" name="U235" />
|
||||
</material>
|
||||
<material id="2" name="water">
|
||||
<material id="2" name="cladding">
|
||||
<density units="g/cc" value="6.44" />
|
||||
<nuclide ao="1.0" name="Zr90" />
|
||||
</material>
|
||||
<material id="3" name="water">
|
||||
<density units="g/cc" value="1.0" />
|
||||
<nuclide ao="2.0" name="H1" />
|
||||
<nuclide ao="1.0" name="O16" />
|
||||
|
|
|
|||
|
|
@ -1,7 +1,11 @@
|
|||
k-combined:
|
||||
1.857752E+00 2.922425E-02
|
||||
1.934690E+00 2.593158E-02
|
||||
tally 1:
|
||||
5.337194E+01
|
||||
3.209877E+02
|
||||
1.621671E+02
|
||||
2.939588E+03
|
||||
8.771138E+01
|
||||
8.618680E+02
|
||||
2.643695E+01
|
||||
7.811923E+01
|
||||
8.917373E+01
|
||||
8.880318E+02
|
||||
2.033221E+02
|
||||
4.619301E+03
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ import shutil
|
|||
import subprocess
|
||||
import textwrap
|
||||
|
||||
from numpy.testing import assert_allclose
|
||||
import openmc
|
||||
import pytest
|
||||
|
||||
|
|
@ -46,6 +47,7 @@ def cpp_driver(request):
|
|||
finally:
|
||||
# Remove local build directory when test is complete
|
||||
shutil.rmtree('build')
|
||||
os.remove('CMakeLists.txt')
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
|
|
@ -57,22 +59,39 @@ def model():
|
|||
u235.add_nuclide('U235', 1.0, 'ao')
|
||||
u235.set_density('g/cc', 11)
|
||||
|
||||
zirc = openmc.Material(name='cladding')
|
||||
zirc.add_nuclide('Zr90', 1.0)
|
||||
zirc.set_density('g/cc', 6.44)
|
||||
|
||||
water = openmc.Material(name="water")
|
||||
water.add_nuclide('H1', 2.0, 'ao')
|
||||
water.add_nuclide('O16', 1.0, 'ao')
|
||||
water.set_density('g/cc', 1.0)
|
||||
|
||||
mats = openmc.Materials([u235, water])
|
||||
mats = openmc.Materials([u235, zirc, water])
|
||||
model.materials = mats
|
||||
|
||||
# geometry
|
||||
fuel_or = openmc.ZCylinder(r=1.5)
|
||||
coolant_or = openmc.ZCylinder(r=3.0, boundary_type='reflective')
|
||||
cladding_or = openmc.ZCylinder(r=1.7)
|
||||
|
||||
fuel = openmc.Cell(fill=u235, region=-fuel_or)
|
||||
coolant = openmc.Cell(fill=water, region=+fuel_or & -coolant_or)
|
||||
cladding = openmc.Cell(fill=zirc, region=+fuel_or & -cladding_or)
|
||||
moderator = openmc.Cell(fill=water, region=+cladding_or)
|
||||
|
||||
model.geometry = openmc.Geometry([fuel, coolant])
|
||||
pincell_univ = openmc.Universe(cells=[fuel, cladding, moderator])
|
||||
|
||||
# lattice
|
||||
lattice = openmc.RectLattice()
|
||||
lattice.pitch = (4.0, 4.0)
|
||||
lattice.lower_left = (-4.0, -4.0)
|
||||
lattice.universes = [[pincell_univ, pincell_univ], [pincell_univ, pincell_univ]]
|
||||
lattice_region = openmc.model.rectangular_prism(8.0,
|
||||
8.0,
|
||||
boundary_type='reflective')
|
||||
lattice_cell = openmc.Cell(fill=lattice, region=lattice_region)
|
||||
|
||||
model.geometry = openmc.Geometry([lattice_cell])
|
||||
|
||||
model.settings.particles = 100
|
||||
model.settings.batches = 10
|
||||
|
|
@ -97,6 +116,22 @@ class ExternalDriverTestHarness(PyAPITestHarness):
|
|||
openmc.run(openmc_exec=self.executable,
|
||||
event_based=config['event'])
|
||||
|
||||
def _compare_results(self):
|
||||
super()._compare_results()
|
||||
|
||||
# load the summary file
|
||||
summary = openmc.Summary('summary.h5')
|
||||
|
||||
# get the summary cells
|
||||
cells = summary.geometry.get_all_cells()
|
||||
|
||||
# for the 2 by 2 lattice, each cell should have 4
|
||||
# temperature values set to 300 K
|
||||
for cell in cells.values():
|
||||
if isinstance(cell.fill, openmc.Material):
|
||||
assert len(cell.temperature) == 4
|
||||
assert_allclose(cell.temperature, 300.0)
|
||||
|
||||
|
||||
def test_cpp_driver(cpp_driver, model):
|
||||
harness = ExternalDriverTestHarness(cpp_driver, 'statepoint.10.h5', model)
|
||||
|
|
|
|||
|
|
@ -39,6 +39,7 @@ def compile_source(request):
|
|||
|
||||
# Remove local build directory when test is complete
|
||||
shutil.rmtree('build')
|
||||
os.remove('CMakeLists.txt')
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue