@@ -17,3 +17,47 @@ def test_tally_init_args():
1717 assert tally .filters == [filter ]
1818 assert tally .nuclides == ['U235' ]
1919 assert tally .estimator == 'tracklength'
20+
21+
22+ def test_heating_estimator_with_photon_transport (run_in_tmpdir ):
23+ """Test that a neutron-only heating tally uses the tracklength estimator
24+ even when photon transport is enabled.
25+
26+ Without a neutron particle filter, photon heating requires the collision
27+ estimator (analog energy balance). But neutron heating has kerma
28+ coefficients that support tracklength scoring, so a neutron-only tally
29+ should keep the tracklength estimator.
30+ """
31+ mat = openmc .Material ()
32+ mat .add_nuclide ('Si28' , 1.0 )
33+ mat .set_density ('g/cm3' , 2.3 )
34+ sph = openmc .Sphere (r = 10.0 , boundary_type = 'vacuum' )
35+ cell = openmc .Cell (fill = mat , region = - sph )
36+
37+ model = openmc .Model ()
38+ model .geometry = openmc .Geometry ([cell ])
39+ model .settings .run_mode = 'fixed source'
40+ model .settings .particles = 100
41+ model .settings .batches = 1
42+ model .settings .photon_transport = True
43+ model .settings .source = openmc .IndependentSource (
44+ space = openmc .stats .Point ()
45+ )
46+
47+ neutron_filter = openmc .ParticleFilter (['neutron' ])
48+
49+ # Neutron-only heating — should get tracklength estimator
50+ t_neutron = openmc .Tally (name = 'heating_neutron' )
51+ t_neutron .filters = [neutron_filter ]
52+ t_neutron .scores = ['heating' ]
53+
54+ # No particle filter — should get collision estimator
55+ t_all = openmc .Tally (name = 'heating_all' )
56+ t_all .scores = ['heating' ]
57+
58+ model .tallies = [t_neutron , t_all ]
59+
60+ sp_filename = model .run ()
61+ with openmc .StatePoint (sp_filename ) as sp :
62+ assert sp .tallies [t_neutron .id ].estimator == 'tracklength'
63+ assert sp .tallies [t_all .id ].estimator == 'collision'
0 commit comments