From 195dff6d1d22cc8dd5ed840d846073ff22fed550 Mon Sep 17 00:00:00 2001 From: Hridoy Kabiraj Date: Mon, 18 May 2026 20:20:59 +0600 Subject: [PATCH 1/2] Fix missing volume checks in material activity/decay heat (#3939) --- openmc/material.py | 5 +++++ tests/unit_tests/test_material.py | 6 ++++++ 2 files changed, 11 insertions(+) diff --git a/openmc/material.py b/openmc/material.py index 2dbe691f52..86cc3d7939 100644 --- a/openmc/material.py +++ b/openmc/material.py @@ -1418,6 +1418,9 @@ class Material(IDManagerMixin): if volume is None: volume = self.volume + if units in {'Bq', 'Ci'} and volume is None: + raise ValueError(f"Volume must be set in order to compute activity in '{units}'.") + if units == 'Bq': multiplier = volume elif units == 'Bq/cm3': @@ -1474,6 +1477,8 @@ class Material(IDManagerMixin): if units == 'W': multiplier = volume if volume is not None else self.volume + if multiplier is None: + raise ValueError("Volume must be set in order to compute total decay heat.") elif units == 'W/cm3': multiplier = 1 elif units == 'W/m3': diff --git a/tests/unit_tests/test_material.py b/tests/unit_tests/test_material.py index 911b8867f9..89dfc03ddd 100644 --- a/tests/unit_tests/test_material.py +++ b/tests/unit_tests/test_material.py @@ -561,6 +561,10 @@ def test_get_activity(): m1.add_element("Fe", 0.7) m1.add_element("Li", 0.3) m1.set_density('g/cm3', 1.5) + with pytest.raises(ValueError, match="Volume must be set"): + m1.get_activity(units='Bq') + with pytest.raises(ValueError, match="Volume must be set"): + m1.get_activity(units='Ci') # activity in Bq/cc and Bq/g should not require volume setting assert m1.get_activity(units='Bq/cm3') == 0 assert m1.get_activity(units='Bq/g') == 0 @@ -619,6 +623,8 @@ def test_get_decay_heat(): m1.add_nuclide("U235", 0.2) m1.add_nuclide("U238", 0.8) m1.set_density('g/cm3', 10.5) + with pytest.raises(ValueError, match="Volume must be set"): + m1.get_decay_heat(units='W') # decay heat in W/cc and W/g should not require volume setting assert m1.get_decay_heat(units='W/cm3') == 0 assert m1.get_decay_heat(units='W/g') == 0 From beed56e6ee44037a1543e7ff3cc8815376634c18 Mon Sep 17 00:00:00 2001 From: charliesheh <59520443+charliesheh@users.noreply.github.com> Date: Mon, 18 May 2026 11:35:56 -0700 Subject: [PATCH 2/2] Check for missing thread count argument for -s/--threads (#3940) --- src/initialize.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/initialize.cpp b/src/initialize.cpp index 991877b242..c04a2fcbdd 100644 --- a/src/initialize.cpp +++ b/src/initialize.cpp @@ -300,6 +300,11 @@ int parse_command_line(int argc, char* argv[]) settings::run_mode = RunMode::VOLUME; } else if (arg == "-s" || arg == "--threads") { // Read number of threads + if (i + 1 >= argc) { + std::string msg {"Number of threads not specified."}; + strcpy(openmc_err_msg, msg.c_str()); + return OPENMC_E_INVALID_ARGUMENT; + } i += 1; #ifdef _OPENMP