From f318392fd0804adc3a579c5edf6fca1df0e40d0f Mon Sep 17 00:00:00 2001 From: daleazer <153695308+daleazer@users.noreply.github.com> Date: Mon, 9 Sep 2024 18:31:41 -0400 Subject: [PATCH] Fixing thKernel setting data type (#1855) The thKernel setting is meant to store the name of the primary thermal hydraulics solver for a run. The default value was False, causing the data type of thKernel to be bool. When a user set the value of thKernel to anything in the settings file, it would only be set to True. Changing the default value to an empty string changes its data type to str, allowing the setting to work as originally intended. --- armi/physics/thermalHydraulics/settings.py | 2 +- .../thermalHydraulics/tests/__init__.py | 13 ++++++ .../tests/test_thermalHydraulicsPlugin.py | 41 +++++++++++++++++++ doc/release/0.4.rst | 1 + 4 files changed, 56 insertions(+), 1 deletion(-) create mode 100644 armi/physics/thermalHydraulics/tests/__init__.py create mode 100644 armi/physics/thermalHydraulics/tests/test_thermalHydraulicsPlugin.py diff --git a/armi/physics/thermalHydraulics/settings.py b/armi/physics/thermalHydraulics/settings.py index a8df91ed2..3975a35e7 100644 --- a/armi/physics/thermalHydraulics/settings.py +++ b/armi/physics/thermalHydraulics/settings.py @@ -34,7 +34,7 @@ def defineSettings(): ), setting.Setting( CONF_TH_KERNEL, - default=False, + default="", label="Thermal Hydraulics Kernel", description="Name of primary T/H solver in this run", ), diff --git a/armi/physics/thermalHydraulics/tests/__init__.py b/armi/physics/thermalHydraulics/tests/__init__.py new file mode 100644 index 000000000..84776603f --- /dev/null +++ b/armi/physics/thermalHydraulics/tests/__init__.py @@ -0,0 +1,13 @@ +# Copyright 2024 TerraPower, LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. diff --git a/armi/physics/thermalHydraulics/tests/test_thermalHydraulicsPlugin.py b/armi/physics/thermalHydraulics/tests/test_thermalHydraulicsPlugin.py new file mode 100644 index 000000000..3c9938abc --- /dev/null +++ b/armi/physics/thermalHydraulics/tests/test_thermalHydraulicsPlugin.py @@ -0,0 +1,41 @@ +# Copyright 2024 TerraPower, LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +"""Unit tests for the thermal hydraulics plugin.""" +from armi.physics import thermalHydraulics +from armi.physics.thermalHydraulics.settings import CONF_DO_TH, CONF_TH_KERNEL +from armi.settings import caseSettings +from armi.tests.test_plugins import TestPlugin + + +class TestThermalHydraulicsPlugin(TestPlugin): + plugin = thermalHydraulics.ThermalHydraulicsPlugin + + def test_thermalHydraulicsSettingsLoaded(self): + """Test that the thermal hydraulics case settings are loaded.""" + cs = caseSettings.Settings() + + self.assertIn(CONF_DO_TH, cs) + self.assertIn(CONF_TH_KERNEL, cs) + + def test_thermalHydraulicsSettingsSet(self): + """Test that the thermal hydraulics case settings are applied correctly.""" + cs = caseSettings.Settings() + thKernelName = "testKernel" + + cs[CONF_DO_TH] = True + cs[CONF_TH_KERNEL] = thKernelName + + self.assertTrue(cs[CONF_DO_TH]) + self.assertEqual(cs[CONF_TH_KERNEL], thKernelName) diff --git a/doc/release/0.4.rst b/doc/release/0.4.rst index 2b69760ac..9151fd113 100644 --- a/doc/release/0.4.rst +++ b/doc/release/0.4.rst @@ -25,6 +25,7 @@ Bug Fixes --------- #. Fixed ``DerivedShape.getArea`` for ``cold=True``. (`PR#1831 `_) #. Fixed error parsing command line integers in ``ReportsEntryPoint``. (`PR#1824 `_) +#. Changed data type of ``thKernel`` setting from ``bool`` to ``str`` in ``ThermalHydraulicsPlugin``. (`PR#1855 `_) #. TBD Quality Work