Skip to content

Commit 8cd3911

Browse files
Reset DAGMC history when reviving from source. (#3601)
Co-authored-by: Paul Romano <paul.k.romano@gmail.com>
1 parent c0f302d commit 8cd3911

File tree

4 files changed

+101
-0
lines changed

4 files changed

+101
-0
lines changed

src/particle.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,9 @@ void Particle::from_source(const SourceSite* src)
121121
fission() = false;
122122
zero_flux_derivs();
123123
lifetime() = 0.0;
124+
#ifdef OPENMC_DAGMC_ENABLED
125+
history().reset();
126+
#endif
124127

125128
// Copy attributes from source bank site
126129
type() = src->particle;

tests/unit_tests/weightwindows/dagmc/__init__.py

Whitespace-only changes.
57.3 KB
Binary file not shown.
Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
import pytest
2+
3+
import openmc
4+
import openmc.lib
5+
6+
pytestmark = pytest.mark.skipif(
7+
not openmc.lib._dagmc_enabled(),
8+
reason="DAGMC CAD geometry is not enabled.",
9+
)
10+
11+
12+
def test_dagmc_weight_windows_near_boundary(run_in_tmpdir, request):
13+
"""Ensure splitting near a boundary doesn't lose particles due to
14+
a stale DAGMC history on the particle object."""
15+
16+
# DAGMC model overview:
17+
# * Three nested cubes; innermost cube contains a fusion neutron source.
18+
# * Two outer cubes filled with tungsten. Weight windows defined on a mesh
19+
# cause particles to split moving outward.
20+
# Outer cubes are similar in size (outer slightly larger) so particles
21+
# frequently cross the problem boundary immediately after splitting. No lost
22+
# particles are allowed to the correct DAGMC history after splitting is used.
23+
model = openmc.Model()
24+
25+
dagmc_file = request.path.parent / 'nested_shell_geometry.h5m'
26+
dagmc_univ = openmc.DAGMCUniverse(dagmc_file)
27+
model.geometry = openmc.Geometry(dagmc_univ)
28+
29+
tungsten = openmc.Material(name='shell')
30+
tungsten.add_element('W', 1.0)
31+
tungsten.set_density('g/cm3', 7.8)
32+
materials = openmc.Materials([tungsten])
33+
model.materials = materials
34+
35+
settings = openmc.Settings()
36+
settings.output = {'tallies': False, 'summary': False}
37+
38+
source = openmc.IndependentSource()
39+
source.space = openmc.stats.Point((0.0, 0.0, 0.0))
40+
source.angle = openmc.stats.Isotropic()
41+
source.energy = openmc.stats.Discrete([14.1e6], [1.0])
42+
settings.source = source
43+
44+
settings.batches = 2
45+
settings.particles = 500
46+
settings.run_mode = 'fixed source'
47+
settings.survival_biasing = False
48+
settings.max_lost_particles = 1
49+
settings.max_history_splits = 10_000_000
50+
51+
settings.weight_window_checkpoints = {
52+
'surface': True,
53+
'collision': True,
54+
}
55+
56+
mesh = openmc.RegularMesh()
57+
mesh.lower_left = (-60.0, -60.0, -60.0)
58+
mesh.upper_right = (60.0, 60.0, 60.0)
59+
mesh.dimension = (24, 1, 1)
60+
61+
weight_windows_lower = [
62+
0.030750733294361156,
63+
0.056110505674355333,
64+
0.08187875047968339,
65+
0.1101743496347699,
66+
0.13982370013053508,
67+
0.17443799246829372,
68+
0.21576286623367483,
69+
0.26416659508033646,
70+
0.318574932646899,
71+
0.3804031702117963,
72+
0.42899359749256355,
73+
0.4954283294279403,
74+
0.49999999999999994,
75+
0.43432341070872266,
76+
0.38302303850488206,
77+
0.32148375935490886,
78+
0.2637416945702018,
79+
0.21498369367288853,
80+
0.17163611765361744,
81+
0.13832102142074995,
82+
0.10717772257151495,
83+
0.07986176041282561,
84+
0.05499644859408233,
85+
0.03058023506703803,
86+
]
87+
88+
weight_windows = openmc.WeightWindows(
89+
mesh,
90+
lower_ww_bounds=weight_windows_lower,
91+
upper_bound_ratio=5.0,
92+
)
93+
weight_windows.max_lower_bound_ratio = 1.0
94+
settings.weight_windows = weight_windows
95+
settings.weight_windows_on = True
96+
model.settings = settings
97+
98+
model.run()

0 commit comments

Comments
 (0)