diff --git a/docs/source/usersguide/random_ray.rst b/docs/source/usersguide/random_ray.rst index 382381a9eea..64ef7de6d54 100644 --- a/docs/source/usersguide/random_ray.rst +++ b/docs/source/usersguide/random_ray.rst @@ -513,6 +513,7 @@ Supported scores: - total - fission - nu-fission + - kappa-fission - events Supported Estimators: diff --git a/include/openmc/random_ray/flat_source_domain.h b/include/openmc/random_ray/flat_source_domain.h index 4df4e5d8d32..0d4086966dd 100644 --- a/include/openmc/random_ray/flat_source_domain.h +++ b/include/openmc/random_ray/flat_source_domain.h @@ -107,6 +107,7 @@ class FlatSourceDomain { vector nu_sigma_f_; vector sigma_f_; vector chi_; + vector kappa_fission_; // 3D arrays stored in 1D representing values for all materials x energy // groups x energy groups diff --git a/openmc/model/model.py b/openmc/model/model.py index 6e4c1c5856d..7590fda0795 100644 --- a/openmc/model/model.py +++ b/openmc/model/model.py @@ -1179,8 +1179,8 @@ def plot( # Convert ID map to RGB image img = id_map_to_rgb( - id_map=id_map, - color_by=color_by, + id_map=id_map, + color_by=color_by, colors=colors, overlap_color=overlap_color ) @@ -1217,7 +1217,7 @@ def plot( extent=(x_min, x_max, y_min, y_max), **contour_kwargs ) - + # If only showing outline, set the axis limits and aspect explicitly if outline == 'only': axes.set_xlim(x_min, x_max) @@ -1862,12 +1862,14 @@ def _generate_infinite_medium_mgxs( if correction == 'P0': mgxs_lib.mgxs_types = [ 'nu-transport', 'absorption', 'nu-fission', 'fission', - 'consistent nu-scatter matrix', 'multiplicity matrix', 'chi' + 'consistent nu-scatter matrix', 'multiplicity matrix', 'chi', + 'kappa-fission' ] elif correction is None: mgxs_lib.mgxs_types = [ 'total', 'absorption', 'nu-fission', 'fission', - 'consistent nu-scatter matrix', 'multiplicity matrix', 'chi' + 'consistent nu-scatter matrix', 'multiplicity matrix', 'chi', + 'kappa-fission' ] # Specify a "cell" domain type for the cross section tally filters @@ -2068,10 +2070,12 @@ def _generate_stochastic_slab_mgxs( # Specify needed cross sections for random ray if correction == 'P0': mgxs_lib.mgxs_types = ['nu-transport', 'absorption', 'nu-fission', 'fission', - 'consistent nu-scatter matrix', 'multiplicity matrix', 'chi'] + 'consistent nu-scatter matrix', 'multiplicity matrix', 'chi', + 'kappa-fission'] elif correction is None: mgxs_lib.mgxs_types = ['total', 'absorption', 'nu-fission', 'fission', - 'consistent nu-scatter matrix', 'multiplicity matrix', 'chi'] + 'consistent nu-scatter matrix', 'multiplicity matrix', 'chi', + 'kappa-fission'] # Specify a "cell" domain type for the cross section tally filters mgxs_lib.domain_type = "material" @@ -2160,12 +2164,14 @@ def _generate_material_wise_mgxs( if correction == 'P0': mgxs_lib.mgxs_types = [ 'nu-transport', 'absorption', 'nu-fission', 'fission', - 'consistent nu-scatter matrix', 'multiplicity matrix', 'chi' + 'consistent nu-scatter matrix', 'multiplicity matrix', 'chi', + 'kappa-fission' ] elif correction is None: mgxs_lib.mgxs_types = [ 'total', 'absorption', 'nu-fission', 'fission', - 'consistent nu-scatter matrix', 'multiplicity matrix', 'chi' + 'consistent nu-scatter matrix', 'multiplicity matrix', 'chi', + 'kappa-fission' ] # Specify a "cell" domain type for the cross section tally filters diff --git a/src/random_ray/flat_source_domain.cpp b/src/random_ray/flat_source_domain.cpp index 2f5007fc927..c2effaa5d4a 100644 --- a/src/random_ray/flat_source_domain.cpp +++ b/src/random_ray/flat_source_domain.cpp @@ -665,10 +665,15 @@ void FlatSourceDomain::random_ray_tally() score = 1.0; break; + case SCORE_KAPPA_FISSION: + score = flux * volume * kappa_fission_[material * negroups_ + g] * + density_mult; + break; + default: fatal_error("Invalid score specified in tallies.xml. Only flux, " - "total, fission, nu-fission, and events are supported in " - "random ray mode."); + "total, fission, nu-fission, kappa-fission, and events " + "are supported in random ray mode."); break; } // Apply score to the appropriate tally bin @@ -1165,6 +1170,10 @@ void FlatSourceDomain::flatten_xs() } chi_.push_back(chi); + double kappa_fission = + m.get_xs(MgxsType::KAPPA_FISSION, g_out, NULL, NULL, NULL, t, a); + kappa_fission_.push_back(kappa_fission); + for (int g_in = 0; g_in < negroups_; g_in++) { double sigma_s = m.get_xs(MgxsType::NU_SCATTER, g_in, &g_out, NULL, NULL, t, a); @@ -1180,6 +1189,7 @@ void FlatSourceDomain::flatten_xs() nu_sigma_f_.push_back(0); sigma_f_.push_back(0); chi_.push_back(0); + kappa_fission_.push_back(0); for (int g_in = 0; g_in < negroups_; g_in++) { sigma_s_.push_back(0); } diff --git a/src/random_ray/random_ray_simulation.cpp b/src/random_ray/random_ray_simulation.cpp index d475b2593ea..531bb4e108c 100644 --- a/src/random_ray/random_ray_simulation.cpp +++ b/src/random_ray/random_ray_simulation.cpp @@ -143,11 +143,12 @@ void validate_random_ray_inputs() case SCORE_FISSION: case SCORE_NU_FISSION: case SCORE_EVENTS: + case SCORE_KAPPA_FISSION: break; default: fatal_error( - "Invalid score specified. Only flux, total, fission, nu-fission, and " - "event scores are supported in random ray mode."); + "Invalid score specified. Only flux, total, fission, nu-fission, " + "kappa-fission, and event scores are supported in random ray mode."); } } diff --git a/tests/regression_tests/random_ray_auto_convert_kappa_fission/__init__.py b/tests/regression_tests/random_ray_auto_convert_kappa_fission/__init__.py new file mode 100644 index 00000000000..e69de29bb2d diff --git a/tests/regression_tests/random_ray_auto_convert_kappa_fission/infinite_medium/inputs_true.dat b/tests/regression_tests/random_ray_auto_convert_kappa_fission/infinite_medium/inputs_true.dat new file mode 100644 index 00000000000..9f3a827f687 --- /dev/null +++ b/tests/regression_tests/random_ray_auto_convert_kappa_fission/infinite_medium/inputs_true.dat @@ -0,0 +1,73 @@ + + + + mgxs.h5 + + + + + + + + + + + + + + + + + + + + + + + + + + eigenvalue + 100 + 10 + 5 + + + -0.63 -0.63 -1 0.63 0.63 1 + + + true + + + multi-group + + + + -0.63 -0.63 -1.0 0.63 0.63 1.0 + + + 30.0 + 150.0 + + + + + + linear + + + 2 2 + -0.63 -0.63 + 0.63 0.63 + + + + + 1 + + + 61 + kappa-fission + + + diff --git a/tests/regression_tests/random_ray_auto_convert_kappa_fission/infinite_medium/results_true.dat b/tests/regression_tests/random_ray_auto_convert_kappa_fission/infinite_medium/results_true.dat new file mode 100644 index 00000000000..27b32d787bc --- /dev/null +++ b/tests/regression_tests/random_ray_auto_convert_kappa_fission/infinite_medium/results_true.dat @@ -0,0 +1,5 @@ +k-combined: +7.479770E-01 1.624548E-02 +tally 1: +2.965503E+08 +1.762157E+16 diff --git a/tests/regression_tests/random_ray_auto_convert_kappa_fission/material_wise/inputs_true.dat b/tests/regression_tests/random_ray_auto_convert_kappa_fission/material_wise/inputs_true.dat new file mode 100644 index 00000000000..edf68f7e25b --- /dev/null +++ b/tests/regression_tests/random_ray_auto_convert_kappa_fission/material_wise/inputs_true.dat @@ -0,0 +1,73 @@ + + + + mgxs.h5 + + + + + + + + + + + + + + + + + + + + + + + + + + eigenvalue + 100 + 10 + 5 + + + -0.63 -0.63 -1 0.63 0.63 1 + + + true + + + multi-group + + + + -0.63 -0.63 -1.0 0.63 0.63 1.0 + + + 30.0 + 150.0 + + + + + + linear + + + 2 2 + -0.63 -0.63 + 0.63 0.63 + + + + + 1 + + + 97 + kappa-fission + + + diff --git a/tests/regression_tests/random_ray_auto_convert_kappa_fission/material_wise/results_true.dat b/tests/regression_tests/random_ray_auto_convert_kappa_fission/material_wise/results_true.dat new file mode 100644 index 00000000000..5a379db7e33 --- /dev/null +++ b/tests/regression_tests/random_ray_auto_convert_kappa_fission/material_wise/results_true.dat @@ -0,0 +1,5 @@ +k-combined: +7.372542E-01 6.967831E-03 +tally 1: +2.909255E+08 +1.693395E+16 diff --git a/tests/regression_tests/random_ray_auto_convert_kappa_fission/stochastic_slab/inputs_true.dat b/tests/regression_tests/random_ray_auto_convert_kappa_fission/stochastic_slab/inputs_true.dat new file mode 100644 index 00000000000..edf68f7e25b --- /dev/null +++ b/tests/regression_tests/random_ray_auto_convert_kappa_fission/stochastic_slab/inputs_true.dat @@ -0,0 +1,73 @@ + + + + mgxs.h5 + + + + + + + + + + + + + + + + + + + + + + + + + + eigenvalue + 100 + 10 + 5 + + + -0.63 -0.63 -1 0.63 0.63 1 + + + true + + + multi-group + + + + -0.63 -0.63 -1.0 0.63 0.63 1.0 + + + 30.0 + 150.0 + + + + + + linear + + + 2 2 + -0.63 -0.63 + 0.63 0.63 + + + + + 1 + + + 97 + kappa-fission + + + diff --git a/tests/regression_tests/random_ray_auto_convert_kappa_fission/stochastic_slab/results_true.dat b/tests/regression_tests/random_ray_auto_convert_kappa_fission/stochastic_slab/results_true.dat new file mode 100644 index 00000000000..a60e5aa3c6f --- /dev/null +++ b/tests/regression_tests/random_ray_auto_convert_kappa_fission/stochastic_slab/results_true.dat @@ -0,0 +1,5 @@ +k-combined: +6.413334E-01 2.083132E-02 +tally 1: +2.541463E+08 +1.297259E+16 diff --git a/tests/regression_tests/random_ray_auto_convert_kappa_fission/test.py b/tests/regression_tests/random_ray_auto_convert_kappa_fission/test.py new file mode 100644 index 00000000000..6decf165a7f --- /dev/null +++ b/tests/regression_tests/random_ray_auto_convert_kappa_fission/test.py @@ -0,0 +1,60 @@ +import os + +import openmc +from openmc.examples import pwr_pin_cell +from openmc import RegularMesh +from openmc.utility_funcs import change_directory +import pytest + +from tests.testing_harness import TolerantPyAPITestHarness + + +class MGXSTestHarness(TolerantPyAPITestHarness): + def _cleanup(self): + super()._cleanup() + f = 'mgxs.h5' + if os.path.exists(f): + os.remove(f) + + +@pytest.mark.parametrize("method", ["material_wise", "stochastic_slab", "infinite_medium"]) +def test_random_ray_auto_convert(method): + with change_directory(method): + openmc.reset_auto_ids() + + # Start with a normal continuous energy model + model = pwr_pin_cell() + + # Convert to a multi-group model + model.convert_to_multigroup( + method=method, groups='CASMO-2', nparticles=100, + overwrite_mgxs_library=False, mgxs_path="mgxs.h5" + ) + + # Convert to a random ray model + model.convert_to_random_ray() + + # Set the number of particles + model.settings.particles = 100 + + # Overlay a basic 2x2 mesh + n = 2 + mesh = RegularMesh() + mesh.dimension = (n, n) + bbox = model.geometry.bounding_box + mesh.lower_left = (bbox.lower_left[0], bbox.lower_left[1]) + mesh.upper_right = (bbox.upper_right[0], bbox.upper_right[1]) + model.settings.random_ray['source_region_meshes'] = [ + (mesh, [model.geometry.root_universe])] + + # Set the source shape to linear + model.settings.random_ray['source_shape'] = 'linear' + + # Set a material tally + t = openmc.Tally(name = 'KF Tally') + t.filters = [openmc.MaterialFilter(bins=1)] + t.scores = ['kappa-fission'] + model.tallies.append(t) + + harness = MGXSTestHarness('statepoint.10.h5', model) + harness.main()