mirror of
https://github.com/openmc-dev/openmc.git
synced 2026-07-29 06:35:48 -04:00
Merge pull request #1433 from paulromano/cell-instance-filter
Cell instance filter
This commit is contained in:
commit
d4ad3cfb75
26 changed files with 707 additions and 58 deletions
0
tests/regression_tests/filter_cellinstance/__init__.py
Normal file
0
tests/regression_tests/filter_cellinstance/__init__.py
Normal file
64
tests/regression_tests/filter_cellinstance/inputs_true.dat
Normal file
64
tests/regression_tests/filter_cellinstance/inputs_true.dat
Normal file
|
|
@ -0,0 +1,64 @@
|
|||
<?xml version='1.0' encoding='utf-8'?>
|
||||
<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 fill="3" id="5" region="3 -4 5 -6" universe="4" />
|
||||
<lattice id="3">
|
||||
<pitch>2 2</pitch>
|
||||
<dimension>4 4</dimension>
|
||||
<lower_left>-4 -4</lower_left>
|
||||
<universes>
|
||||
1 2 2 2
|
||||
2 1 2 2
|
||||
2 2 1 2
|
||||
2 2 2 1 </universes>
|
||||
</lattice>
|
||||
<surface coeffs="0.0 0.0 0.7" id="1" type="z-cylinder" />
|
||||
<surface coeffs="0.0 0.0 0.5" 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>
|
||||
<material depletable="true" id="1">
|
||||
<density units="g/cc" value="4.5" />
|
||||
<nuclide ao="1.0" name="U235" />
|
||||
</material>
|
||||
<material id="2">
|
||||
<density units="g/cc" value="1.0" />
|
||||
<nuclide ao="1.0" name="H1" />
|
||||
</material>
|
||||
</materials>
|
||||
<?xml version='1.0' encoding='utf-8'?>
|
||||
<settings>
|
||||
<run_mode>eigenvalue</run_mode>
|
||||
<particles>1000</particles>
|
||||
<batches>5</batches>
|
||||
<inactive>0</inactive>
|
||||
<source strength="1.0">
|
||||
<space type="point">
|
||||
<parameters>0.0 0.0 0.0</parameters>
|
||||
</space>
|
||||
</source>
|
||||
</settings>
|
||||
<?xml version='1.0' encoding='utf-8'?>
|
||||
<tallies>
|
||||
<filter id="1" type="cellinstance">
|
||||
<bins>3 0 3 1 3 2 3 3 3 4 3 5 3 6 3 7 3 8 3 9 3 10 3 11 2 0 2 1 2 2 2 3</bins>
|
||||
</filter>
|
||||
<filter id="2" type="cellinstance">
|
||||
<bins>2 3 2 2 2 1 2 0 3 11 3 10 3 9 3 8 3 7 3 6 3 5 3 4 3 3 3 2 3 1 3 0</bins>
|
||||
</filter>
|
||||
<tally id="1">
|
||||
<filters>1</filters>
|
||||
<scores>total</scores>
|
||||
</tally>
|
||||
<tally id="2">
|
||||
<filters>2</filters>
|
||||
<scores>total</scores>
|
||||
</tally>
|
||||
</tallies>
|
||||
68
tests/regression_tests/filter_cellinstance/results_true.dat
Normal file
68
tests/regression_tests/filter_cellinstance/results_true.dat
Normal file
|
|
@ -0,0 +1,68 @@
|
|||
k-combined:
|
||||
1.060380E+00 4.511966E-03
|
||||
tally 1:
|
||||
8.636855E-02
|
||||
1.795640E-03
|
||||
1.478489E-01
|
||||
5.007770E-03
|
||||
1.687036E-01
|
||||
6.223488E-03
|
||||
1.035433E-01
|
||||
2.767195E-03
|
||||
2.789537E-01
|
||||
1.720816E-02
|
||||
1.420504E-01
|
||||
4.539772E-03
|
||||
1.325589E-01
|
||||
3.998010E-03
|
||||
2.934613E-01
|
||||
2.064779E-02
|
||||
1.231465E-01
|
||||
3.847169E-03
|
||||
1.282909E-01
|
||||
3.680695E-03
|
||||
1.545480E-01
|
||||
5.588411E-03
|
||||
5.110026E-02
|
||||
5.947113E-04
|
||||
1.119824E+01
|
||||
3.030467E+01
|
||||
2.847726E+01
|
||||
1.920547E+02
|
||||
2.819853E+01
|
||||
1.906807E+02
|
||||
8.816481E+00
|
||||
2.016785E+01
|
||||
tally 2:
|
||||
8.816481E+00
|
||||
2.016785E+01
|
||||
2.819853E+01
|
||||
1.906807E+02
|
||||
2.847726E+01
|
||||
1.920547E+02
|
||||
1.119824E+01
|
||||
3.030467E+01
|
||||
5.110026E-02
|
||||
5.947113E-04
|
||||
1.545480E-01
|
||||
5.588411E-03
|
||||
1.282909E-01
|
||||
3.680695E-03
|
||||
1.231465E-01
|
||||
3.847169E-03
|
||||
2.934613E-01
|
||||
2.064779E-02
|
||||
1.325589E-01
|
||||
3.998010E-03
|
||||
1.420504E-01
|
||||
4.539772E-03
|
||||
2.789537E-01
|
||||
1.720816E-02
|
||||
1.035433E-01
|
||||
2.767195E-03
|
||||
1.687036E-01
|
||||
6.223488E-03
|
||||
1.478489E-01
|
||||
5.007770E-03
|
||||
8.636855E-02
|
||||
1.795640E-03
|
||||
69
tests/regression_tests/filter_cellinstance/test.py
Normal file
69
tests/regression_tests/filter_cellinstance/test.py
Normal file
|
|
@ -0,0 +1,69 @@
|
|||
import openmc
|
||||
import openmc.model
|
||||
import pytest
|
||||
|
||||
from tests.testing_harness import PyAPITestHarness
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def model():
|
||||
model = openmc.model.Model()
|
||||
|
||||
# Materials
|
||||
m1 = openmc.Material()
|
||||
m1.set_density('g/cc', 4.5)
|
||||
m1.add_nuclide('U235', 1.0)
|
||||
m2 = openmc.Material()
|
||||
m2.set_density('g/cc', 1.0)
|
||||
m2.add_nuclide('H1', 1.0)
|
||||
model.materials += [m1, m2]
|
||||
|
||||
# Geometry
|
||||
cyl1 = openmc.ZCylinder(r=0.7)
|
||||
c1 = openmc.Cell(fill=m1, region=-cyl1)
|
||||
c2 = openmc.Cell(fill=m2, region=+cyl1)
|
||||
u1 = openmc.Universe(cells=[c1, c2])
|
||||
|
||||
cyl2 = openmc.ZCylinder(r=0.5)
|
||||
c3 = openmc.Cell(fill=m1, region=-cyl2)
|
||||
c4 = openmc.Cell(fill=m2, region=+cyl2)
|
||||
u2 = openmc.Universe(cells=[c3, c4])
|
||||
|
||||
lat = openmc.RectLattice()
|
||||
lat.lower_left = (-4, -4)
|
||||
lat.pitch = (2, 2)
|
||||
lat.universes = [
|
||||
[u1, u2, u2, u2],
|
||||
[u2, u1, u2, u2],
|
||||
[u2, u2, u1, u2],
|
||||
[u2, u2, u2, u1]
|
||||
]
|
||||
box = openmc.model.rectangular_prism(8.0, 8.0, boundary_type='reflective')
|
||||
main_cell = openmc.Cell(fill=lat, region=box)
|
||||
model.geometry.root_universe = openmc.Universe(cells=[main_cell])
|
||||
model.geometry.determine_paths()
|
||||
|
||||
# Settings
|
||||
model.settings.batches = 5
|
||||
model.settings.inactive = 0
|
||||
model.settings.particles = 1000
|
||||
model.settings.source = openmc.Source(space=openmc.stats.Point())
|
||||
|
||||
instances = ([(c3, i) for i in range(c3.num_instances)] +
|
||||
[(c2, i) for i in range(c2.num_instances)])
|
||||
f1 = openmc.CellInstanceFilter(instances)
|
||||
f2 = openmc.CellInstanceFilter(instances[::-1])
|
||||
t1 = openmc.Tally()
|
||||
t1.filters = [f1]
|
||||
t1.scores = ['total']
|
||||
t2 = openmc.Tally()
|
||||
t2.filters = [f2]
|
||||
t2.scores = ['total']
|
||||
model.tallies += [t1, t2]
|
||||
|
||||
return model
|
||||
|
||||
|
||||
def test_cell_instance(model):
|
||||
harness = PyAPITestHarness('statepoint.5.h5', model)
|
||||
harness.main()
|
||||
Loading…
Add table
Add a link
Reference in a new issue