diff --git a/src/physics.cpp b/src/physics.cpp index 0d0c603430..67af6dc421 100644 --- a/src/physics.cpp +++ b/src/physics.cpp @@ -56,7 +56,6 @@ void collision(Particle* p) if (p->E_ < settings::energy_cutoff[type]) { p->alive_ = false; p->wgt_ = 0.0; - p->wgt_last_ = 0.0; } // Display information about collision diff --git a/src/tallies/tally.cpp b/src/tallies/tally.cpp index fe1953b26e..84ec223ed9 100644 --- a/src/tallies/tally.cpp +++ b/src/tallies/tally.cpp @@ -717,7 +717,7 @@ void read_tallies_xml() const auto& f = model::tally_filters[i_filter].get(); auto pf = dynamic_cast(f); - if (pf) particle_filter_index = j; + if (pf) particle_filter_index = i_filter; // Change the tally estimator if a filter demands it std::string filt_type = f->type(); diff --git a/tests/regression_tests/photon_production/inputs_true.dat b/tests/regression_tests/photon_production/inputs_true.dat index 427078c889..1d43c89137 100644 --- a/tests/regression_tests/photon_production/inputs_true.dat +++ b/tests/regression_tests/photon_production/inputs_true.dat @@ -3,7 +3,7 @@ - + @@ -47,4 +47,19 @@ 1 2 current + + 2 + total + tracklength + + + 2 + total + collision + + + 2 + total + analog + diff --git a/tests/regression_tests/photon_production/results_true.dat b/tests/regression_tests/photon_production/results_true.dat index 3d9cf68ede..7df7e5dbcf 100644 --- a/tests/regression_tests/photon_production/results_true.dat +++ b/tests/regression_tests/photon_production/results_true.dat @@ -1,3 +1,12 @@ tally 1: -sum = 7.938000E-01 -sum_sq = 6.301184E-01 +9.403000E-01 +8.841641E-01 +tally 2: +8.281718E-01 +6.858685E-01 +tally 3: +8.242000E-01 +6.793056E-01 +tally 4: +8.242000E-01 +6.793056E-01 diff --git a/tests/regression_tests/photon_production/test.py b/tests/regression_tests/photon_production/test.py index ac39b065c0..47215fff30 100644 --- a/tests/regression_tests/photon_production/test.py +++ b/tests/regression_tests/photon_production/test.py @@ -14,7 +14,7 @@ class SourceTestHarness(PyAPITestHarness): materials = openmc.Materials([mat]) materials.export_to_xml() - cyl = openmc.XCylinder(boundary_type='vacuum', r=1.0e-6) + cyl = openmc.XCylinder(boundary_type='vacuum', r=1.0) x_plane_left = openmc.XPlane(boundary_type='vacuum', x0=-1.0) x_plane_center = openmc.XPlane(boundary_type='transmission', x0=1.0) x_plane_right = openmc.XPlane(boundary_type='vacuum', x0=1.0e9) @@ -48,20 +48,37 @@ class SourceTestHarness(PyAPITestHarness): surface_filter = openmc.SurfaceFilter(cyl) particle_filter = openmc.ParticleFilter('photon') - tally = openmc.Tally() - tally.filters = [surface_filter, particle_filter] - tally.scores = ['current'] - tallies = openmc.Tallies([tally]) + current_tally = openmc.Tally() + current_tally.filters = [surface_filter, particle_filter] + current_tally.scores = ['current'] + total_tally_tracklength = openmc.Tally() + total_tally_tracklength.filters = [particle_filter] + total_tally_tracklength.scores = ['total'] + total_tally_tracklength.estimator = 'tracklength' + total_tally_collision = openmc.Tally() + total_tally_collision.filters = [particle_filter] + total_tally_collision.scores = ['total'] + total_tally_collision.estimator = 'collision' + total_tally_analog = openmc.Tally() + total_tally_analog.filters = [particle_filter] + total_tally_analog.scores = ['total'] + total_tally_analog.estimator = 'analog' + tallies = openmc.Tallies([current_tally, total_tally_tracklength, + total_tally_collision, total_tally_analog]) tallies.export_to_xml() def _get_results(self): with openmc.StatePoint(self._sp_name) as sp: outstr = '' - t = sp.get_tally() - outstr += 'tally {}:\n'.format(t.id) - outstr += 'sum = {:12.6E}\n'.format(t.sum[0, 0, 0]) - outstr += 'sum_sq = {:12.6E}\n'.format(t.sum_sq[0, 0, 0]) + for i, tally_ind in enumerate(sp.tallies): + tally = sp.tallies[tally_ind] + results = np.zeros((tally.sum.size * 2, )) + results[0::2] = tally.sum.ravel() + results[1::2] = tally.sum_sq.ravel() + results = ['{0:12.6E}'.format(x) for x in results] + outstr += 'tally {}:\n'.format(i + 1) + outstr += '\n'.join(results) + '\n' return outstr