From 954450a84145fe2a3feda908a2a7029efc02fab5 Mon Sep 17 00:00:00 2001 From: Miriam Date: Wed, 4 Nov 2020 16:58:43 +0000 Subject: [PATCH] Fixed several bugs related to decay-rate 1) In mdgxs.py, DecayRate, get_xs(). There is no need to reverse the order since there isn't an energy group filter anymore. Also, the new_shape addition formats the cross section like all the others. I updated mgxs_library_hdf5 test results accordingly. 2) In material.cpp. If you use a macroscopic dnesity other than 1.0, the code still pushed back '1.0'. My change fixes that. Using a macro density other than 1.0 wasn't tested anywhere, so I modifed mg_convert to take a density of 1.1. The default macro density of 1.0 is used in many other tests. 3) tally_scoring.cpp. Notice that the score is accumulated, then sent to the function score_fission_delayed_dg where the tally is accumulated. This amounts to "double accumulation". It makes sense to accumulate the score over the delayed groups if there is no delayed group filter, but in this case, when delayed group filter is not None, the score needs to reset each time. In other parts of SCORE_DECAY_RATE, I think the distinction between accumulating and resetting the score is correct. The only place I wasn't sure was line 1057 (and its equivalent in multi-group, line 1962). It's too bad the decay-rate isn't tested very thoroughly. Although I don't have time to do it myself, I think adding a DelayedGroups filter to the mg_tallies test would be a good start. --- openmc/mgxs/mdgxs.py | 6 +---- src/material.cpp | 4 ++-- src/tallies/tally_scoring.cpp | 4 ++-- .../mg_convert/inputs_true.dat | 2 +- .../mg_convert/results_true.dat | 24 +++++++++---------- tests/regression_tests/mg_convert/test.py | 2 +- .../mgxs_library_hdf5/results_true.dat | 16 +++++++++---- 7 files changed, 31 insertions(+), 27 deletions(-) diff --git a/openmc/mgxs/mdgxs.py b/openmc/mgxs/mdgxs.py index 8f35d5879..f51157952 100644 --- a/openmc/mgxs/mdgxs.py +++ b/openmc/mgxs/mdgxs.py @@ -2044,13 +2044,9 @@ class DecayRate(MDGXS): num_delayed_groups) else: new_shape = (num_subdomains, num_delayed_groups) + new_shape += xs.shape[1:] xs = np.reshape(xs, new_shape) - # Reverse data if user requested increasing energy groups since - # tally data is stored in order of increasing energies - if order_groups == 'increasing': - xs = xs[..., ::-1, :] - if squeeze: # We want to squeeze out everything but the polar, azimuthal, # delayed group, and energy group data. diff --git a/src/material.cpp b/src/material.cpp index 1d4e18108..fed915043 100644 --- a/src/material.cpp +++ b/src/material.cpp @@ -149,7 +149,7 @@ Material::Material(pugi::xml_node node) // Set density for macroscopic data if (units == "macro") { - densities.push_back(1.0); + densities.push_back(density_); } else { fatal_error("Units can only be macro for macroscopic data " + name); } @@ -169,7 +169,7 @@ Material::Material(pugi::xml_node node) // Check if no atom/weight percents were specified or if both atom and // weight percents were specified if (units == "macro") { - densities.push_back(1.0); + densities.push_back(density_); } else { bool has_ao = check_for_node(node_nuc, "ao"); bool has_wo = check_for_node(node_nuc, "wo"); diff --git a/src/tallies/tally_scoring.cpp b/src/tallies/tally_scoring.cpp index 396ab2f82..0ffcf821b 100644 --- a/src/tallies/tally_scoring.cpp +++ b/src/tallies/tally_scoring.cpp @@ -1995,13 +1995,13 @@ score_general_mg(Particle& p, int i_tally, int start_index, int filter_index, for (auto d_bin = 0; d_bin < filt.n_bins(); ++d_bin) { auto d = filt.groups()[d_bin] - 1; if (i_nuclide >= 0) { - score += atom_density * flux + score = atom_density * flux * nuc_xs.get_xs(MgxsType::DECAY_RATE, p_g, nullptr, nullptr, &d) * nuc_xs.get_xs(MgxsType::DELAYED_NU_FISSION, p_g, nullptr, nullptr, &d); } else { - score += flux + score = flux * macro_xs.get_xs(MgxsType::DECAY_RATE, p_g, nullptr, nullptr, &d) * macro_xs.get_xs(MgxsType::DELAYED_NU_FISSION, p_g, nullptr, diff --git a/tests/regression_tests/mg_convert/inputs_true.dat b/tests/regression_tests/mg_convert/inputs_true.dat index e2c3a01fa..9db9b7d7c 100644 --- a/tests/regression_tests/mg_convert/inputs_true.dat +++ b/tests/regression_tests/mg_convert/inputs_true.dat @@ -10,7 +10,7 @@ ./mgxs.h5 - + diff --git a/tests/regression_tests/mg_convert/results_true.dat b/tests/regression_tests/mg_convert/results_true.dat index a52b929dc..5a17fe107 100644 --- a/tests/regression_tests/mg_convert/results_true.dat +++ b/tests/regression_tests/mg_convert/results_true.dat @@ -1,24 +1,24 @@ k-combined: -9.930873E-01 2.221904E-03 +9.834385E-01 7.095193E-03 k-combined: -9.948148E-01 1.216270E-03 +9.936965E-01 4.118371E-03 k-combined: -9.930873E-01 2.221904E-03 +9.834385E-01 7.095193E-03 k-combined: -9.755034E-01 6.178296E-03 +9.977232E-01 1.084193E-02 k-combined: -9.738059E-01 4.529068E-03 +9.945011E-01 5.571771E-03 k-combined: -9.866847E-01 9.485912E-03 +9.982627E-01 2.662444E-03 k-combined: -9.755024E-01 6.179047E-03 +9.977232E-01 1.084193E-02 k-combined: -9.738061E-01 4.529462E-03 +9.945007E-01 5.571589E-03 k-combined: -9.866835E-01 9.485832E-03 +9.982620E-01 2.662746E-03 k-combined: -9.719024E-01 4.213166E-03 +1.000071E+00 3.364791E-03 k-combined: -9.930873E-01 2.221904E-03 +9.834385E-01 7.095193E-03 k-combined: -9.930873E-01 2.221904E-03 +9.834385E-01 7.095193E-03 diff --git a/tests/regression_tests/mg_convert/test.py b/tests/regression_tests/mg_convert/test.py index 4cc6b656a..f22c15dc0 100755 --- a/tests/regression_tests/mg_convert/test.py +++ b/tests/regression_tests/mg_convert/test.py @@ -67,7 +67,7 @@ class MGXSTestHarness(PyAPITestHarness): # Instantiate some Materials and register the appropriate objects mat = openmc.Material(material_id=1, name='UO2 fuel') - mat.set_density('macro', 1.0) + mat.set_density('macro', 1.1) mat.add_macroscopic(uo2_data) # Instantiate a Materials collection and export to XML diff --git a/tests/regression_tests/mgxs_library_hdf5/results_true.dat b/tests/regression_tests/mgxs_library_hdf5/results_true.dat index 4a796b0a5..4aa243b9e 100644 --- a/tests/regression_tests/mgxs_library_hdf5/results_true.dat +++ b/tests/regression_tests/mgxs_library_hdf5/results_true.dat @@ -193,10 +193,18 @@ domain=1 type=beta [1.21876271e-04 8.77101834e-05] [4.95946084e-05 3.67414816e-05]] domain=1 type=decay-rate -[1.33568413e-02 3.25887984e-02 1.21105565e-01 3.06139633e-01 - 8.62763808e-01 2.89789222e+00] -[9.57055016e-04 2.28222032e-03 8.35436401e-03 2.06734948e-02 - 5.63019289e-02 1.89486538e-01] +[[1.33568413e-02] + [3.25887984e-02] + [1.21105565e-01] + [3.06139633e-01] + [8.62763808e-01] + [2.89789222e+00]] +[[9.57055016e-04] + [2.28222032e-03] + [8.35436401e-03] + [2.06734948e-02] + [5.63019289e-02] + [1.89486538e-01]] domain=1 type=delayed-nu-fission matrix [[[0.00000000e+00 0.00000000e+00] [0.00000000e+00 0.00000000e+00]]