From f6ace6ece7d0b206040ee2ed7fa726ca8e43a632 Mon Sep 17 00:00:00 2001 From: liangjg Date: Thu, 28 Mar 2019 17:03:06 -0400 Subject: [PATCH 1/5] fix photon analog tally: do not zero out p->wgt_last_ before tallying --- src/physics.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/src/physics.cpp b/src/physics.cpp index 1cfd316580..258cea9248 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 From e36f67c5bb3ea4705ce3eb42f1178f97802fb801 Mon Sep 17 00:00:00 2001 From: liangjg Date: Thu, 28 Mar 2019 21:07:44 -0400 Subject: [PATCH 2/5] fix particle tally filter bug: the index is stored wrong --- src/tallies/tally.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/tallies/tally.cpp b/src/tallies/tally.cpp index 682db35405..1cbd534240 100644 --- a/src/tallies/tally.cpp +++ b/src/tallies/tally.cpp @@ -718,7 +718,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(); From a8e942b7405b4da3d8e1fe7670a17a9628ea189e Mon Sep 17 00:00:00 2001 From: liangjg Date: Thu, 28 Mar 2019 20:00:27 -0400 Subject: [PATCH 3/5] update photon tally test to cover analog estimator --- .../photon_production/inputs_true.dat | 5 +++++ tests/regression_tests/photon_production/test.py | 12 ++++++++---- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/tests/regression_tests/photon_production/inputs_true.dat b/tests/regression_tests/photon_production/inputs_true.dat index 427078c889..bfee6a7129 100644 --- a/tests/regression_tests/photon_production/inputs_true.dat +++ b/tests/regression_tests/photon_production/inputs_true.dat @@ -47,4 +47,9 @@ 1 2 current + + 2 + total + analog + diff --git a/tests/regression_tests/photon_production/test.py b/tests/regression_tests/photon_production/test.py index ac39b065c0..4e51271090 100644 --- a/tests/regression_tests/photon_production/test.py +++ b/tests/regression_tests/photon_production/test.py @@ -48,10 +48,14 @@ 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 = openmc.Tally() + total_tally.filters = [particle_filter] + total_tally.scores = ['total'] + total_tally.estimator = 'analog' + tallies = openmc.Tallies([current_tally, total_tally]) tallies.export_to_xml() def _get_results(self): From c24a8b2f18b233d46570285f7e21e09a535a4409 Mon Sep 17 00:00:00 2001 From: liangjg Date: Thu, 28 Mar 2019 21:54:50 -0400 Subject: [PATCH 4/5] add tracklength and collision tally for comparison --- .../photon_production/inputs_true.dat | 10 ++++++ .../photon_production/test.py | 31 +++++++++++++------ 2 files changed, 32 insertions(+), 9 deletions(-) diff --git a/tests/regression_tests/photon_production/inputs_true.dat b/tests/regression_tests/photon_production/inputs_true.dat index bfee6a7129..f2c52b4451 100644 --- a/tests/regression_tests/photon_production/inputs_true.dat +++ b/tests/regression_tests/photon_production/inputs_true.dat @@ -48,6 +48,16 @@ current + 2 + total + tracklength + + + 2 + total + collision + + 2 total analog diff --git a/tests/regression_tests/photon_production/test.py b/tests/regression_tests/photon_production/test.py index 4e51271090..55fcabea5b 100644 --- a/tests/regression_tests/photon_production/test.py +++ b/tests/regression_tests/photon_production/test.py @@ -51,21 +51,34 @@ class SourceTestHarness(PyAPITestHarness): current_tally = openmc.Tally() current_tally.filters = [surface_filter, particle_filter] current_tally.scores = ['current'] - total_tally = openmc.Tally() - total_tally.filters = [particle_filter] - total_tally.scores = ['total'] - total_tally.estimator = 'analog' - tallies = openmc.Tallies([current_tally, total_tally]) + 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 From ac048527c81c742e79bd709960174e4d394daacd Mon Sep 17 00:00:00 2001 From: liangjg Date: Thu, 28 Mar 2019 22:15:09 -0400 Subject: [PATCH 5/5] change cylinder size to make sure collision occurs --- .../photon_production/inputs_true.dat | 2 +- .../photon_production/results_true.dat | 13 +++++++++++-- tests/regression_tests/photon_production/test.py | 2 +- 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/tests/regression_tests/photon_production/inputs_true.dat b/tests/regression_tests/photon_production/inputs_true.dat index f2c52b4451..1d43c89137 100644 --- a/tests/regression_tests/photon_production/inputs_true.dat +++ b/tests/regression_tests/photon_production/inputs_true.dat @@ -3,7 +3,7 @@ - + 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 55fcabea5b..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)