Adding a test for setting cell temperatures under a specific higher level cell instance in the cpp driver test.

This commit is contained in:
Patrick Shriwise 2021-08-17 19:31:50 -05:00
parent b9851b4c36
commit 0bed3f53b2
4 changed files with 22 additions and 7 deletions

View file

@ -6,6 +6,7 @@
#include "openmc/cell.h"
#include "openmc/error.h"
#include "openmc/geometry.h"
#include "openmc/geometry_aux.h"
#include "openmc/message_passing.h"
#include "openmc/summary.h"
#include "openmc/tallies/filter.h"
@ -31,11 +32,14 @@ int main(int argc, char** argv) {
for (auto& entry : openmc::model::cell_map) {
cell_indices.push_back(entry.second);
}
// enable distribcells offsets for all cells
prepare_distribcell(&cell_indices);
// sort to make sure the cell bins appear in the same
// order as the test relying on the openmc exe
std::sort(cell_indices.begin(), cell_indices.end());
cell_filter->set_cells(cell_indices);
// create a new tally
auto tally = Tally::create();
std::vector<Filter*> filters = {cell_filter};
@ -46,7 +50,7 @@ int main(int argc, char** argv) {
// 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);
lattice_cell->set_temperature(300.0, 0, true);
// check that material-filled cells return no contained cells
for (auto& cell : openmc::model::cells) {
@ -56,6 +60,9 @@ int main(int argc, char** argv) {
}
}
// set a higher temperature for only one of the lattice cells (ID is 4 in the model)
model::cells[model::cell_map[4]]->set_temperature(400.0, 3, true);
// the summary file will be used to check that
// temperatures were set correctly so clear
// error output can be provided

View file

@ -3,14 +3,15 @@
<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">
<cell fill="1" id="4" universe="2" />
<cell fill="3" id="5" region="3 -4 5 -6" universe="4" />
<lattice id="3">
<pitch>4.0 4.0</pitch>
<dimension>2 2</dimension>
<lower_left>-4.0 -4.0</lower_left>
<universes>
1 1
1 1 </universes>
2 2
2 2 </universes>
</lattice>
<surface coeffs="0.0 0.0 1.5" id="1" type="z-cylinder" />
<surface coeffs="0.0 0.0 1.7" id="2" type="z-cylinder" />

View file

@ -9,3 +9,5 @@ tally 1:
9.919885E+02
2.174849E+02
5.292948E+03
2.174849E+02
5.292948E+03

View file

@ -81,11 +81,15 @@ def model():
pincell_univ = openmc.Universe(cells=[fuel, cladding, moderator])
# insert an additional cell to add another level to the geometry
extra_cell = openmc.Cell(fill=pincell_univ)
extra_univ = openmc.Universe(cells=[extra_cell])
# 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.universes = [[extra_univ, extra_univ], [extra_univ, extra_univ]]
lattice_region = openmc.model.rectangular_prism(8.0,
8.0,
boundary_type='reflective')
@ -130,7 +134,8 @@ class ExternalDriverTestHarness(PyAPITestHarness):
for cell in cells.values():
if isinstance(cell.fill, openmc.Material):
assert len(cell.temperature) == 4
assert_allclose(cell.temperature, 300.0)
assert_allclose(cell.temperature[:3], 300.0)
assert_allclose(cell.temperature[-1:], 400.0)
def test_cpp_driver(cpp_driver, model):