Merge branch 'openmc-dev:develop' into mesh_tally_amalgamation

This commit is contained in:
Ebny Walid Ahammed 2026-05-18 18:01:51 -05:00 committed by GitHub
commit 2d5691110f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 16 additions and 0 deletions

View file

@ -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':

View file

@ -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

View file

@ -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