Skip to content

Commit 264d599

Browse files
committed
Adding a test for using the collision track feature with photons
1 parent 07b209c commit 264d599

1 file changed

Lines changed: 22 additions & 0 deletions

File tree

tests/unit_tests/test_collision_track.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,3 +127,25 @@ def test_format_similarity(run_in_tmpdir, model):
127127
np.testing.assert_allclose(data_h5, data_mcpl, rtol=1e-05)
128128
# tolerance not that low due to the strings that is saved in MCPL,
129129
# not enough precision!
130+
131+
132+
def test_photon_particles(run_in_tmpdir, model):
133+
"""Test that the collision track can be used to track photon particles."""
134+
model.settings.collision_track = {"max_collisions": 200, "cell_ids": [1, 2]}
135+
136+
model.settings.source = openmc.IndependentSource(
137+
space=openmc.stats.Box(*model.geometry.bounding_box),
138+
energy=openmc.stats.Discrete([1e5], [1.0]),
139+
particle='photon'
140+
)
141+
model.run()
142+
143+
with h5py.File("collision_track.h5", "r") as f:
144+
source = f["collision_track_bank"]
145+
146+
assert len(source) < 200
147+
148+
allowed_particles = set(openmc.ParticleType(p) for p in ['photon', 'electron'])
149+
150+
for point in source:
151+
assert openmc.ParticleType(point['particle']) in allowed_particles

0 commit comments

Comments
 (0)