From c6e9d969efb49e8a99442a8de6e977af958a1812 Mon Sep 17 00:00:00 2001 From: Robert Timms Date: Wed, 2 Mar 2022 10:02:52 +0000 Subject: [PATCH 1/6] #1957 return heat source in isothermal models --- pybamm/models/submodels/thermal/isothermal.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/pybamm/models/submodels/thermal/isothermal.py b/pybamm/models/submodels/thermal/isothermal.py index d620c8f38d..b540de2342 100644 --- a/pybamm/models/submodels/thermal/isothermal.py +++ b/pybamm/models/submodels/thermal/isothermal.py @@ -42,3 +42,7 @@ def get_fundamental_variables(self): ) return variables + + def get_coupled_variables(self, variables): + variables.update(self._get_standard_coupled_variables(variables)) + return variables \ No newline at end of file From c9b604aa0348887d5ee0fd8059f9275ae618e349 Mon Sep 17 00:00:00 2001 From: Robert Timms Date: Wed, 2 Mar 2022 10:05:07 +0000 Subject: [PATCH 2/6] #1957 changelog --- CHANGELOG.md | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3215f71c89..466ea4c9e4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,10 +1,14 @@ # [Unreleased](https://github.com/pybamm-team/PyBaMM/) +## Bug fixes + +- Fixed a bug where isothermal models did not compute any heat source terms ([#1958](https://github.com/pybamm-team/PyBaMM/pull/1958)) + # [v22.2](https://github.com/pybamm-team/PyBaMM/tree/v22.2) - 2022-02-28 ## Features -- Isothermal models now compute heat source terms (but the temperature remains constant). The models now also account for current collector heating when `dimensionality=0` [#1929](https://github.com/pybamm-team/PyBaMM/pull/1929)) +- Isothermal models now compute heat source terms (but the temperature remains constant). The models now also account for current collector heating when `dimensionality=0` ([#1929](https://github.com/pybamm-team/PyBaMM/pull/1929)) - Added new models for power control and resistance control ([#1917](https://github.com/pybamm-team/PyBaMM/pull/1917)) - Initial concentrations can now be provided as a function of `r` as well as `x` ([#1866](https://github.com/pybamm-team/PyBaMM/pull/1866)) From fe06c27d905544c3f5cd9eac93f6b94109c87126 Mon Sep 17 00:00:00 2001 From: Robert Timms Date: Wed, 2 Mar 2022 10:06:25 +0000 Subject: [PATCH 3/6] #1957 style --- CHANGELOG.md | 2 +- pybamm/models/submodels/thermal/isothermal.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 466ea4c9e4..16eef63d26 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,6 @@ # [Unreleased](https://github.com/pybamm-team/PyBaMM/) -## Bug fixes +## Bug fixes - Fixed a bug where isothermal models did not compute any heat source terms ([#1958](https://github.com/pybamm-team/PyBaMM/pull/1958)) diff --git a/pybamm/models/submodels/thermal/isothermal.py b/pybamm/models/submodels/thermal/isothermal.py index b540de2342..ad6fe04271 100644 --- a/pybamm/models/submodels/thermal/isothermal.py +++ b/pybamm/models/submodels/thermal/isothermal.py @@ -45,4 +45,4 @@ def get_fundamental_variables(self): def get_coupled_variables(self, variables): variables.update(self._get_standard_coupled_variables(variables)) - return variables \ No newline at end of file + return variables From cdbe6d701fe50b95f0c75d1a849bf51ded1106f6 Mon Sep 17 00:00:00 2001 From: Robert Timms Date: Wed, 2 Mar 2022 13:10:49 +0000 Subject: [PATCH 4/6] #1957 add heat source option --- .../full_battery_models/base_battery_model.py | 6 ++++ pybamm/models/submodels/thermal/isothermal.py | 34 ++++++++++++++++++- .../test_base_battery_model.py | 1 + .../base_lithium_ion_tests.py | 7 ++++ 4 files changed, 47 insertions(+), 1 deletion(-) diff --git a/pybamm/models/full_battery_models/base_battery_model.py b/pybamm/models/full_battery_models/base_battery_model.py index 80e2aa0b41..408a3311fc 100644 --- a/pybamm/models/full_battery_models/base_battery_model.py +++ b/pybamm/models/full_battery_models/base_battery_model.py @@ -26,6 +26,11 @@ class BatteryModelOptions(pybamm.FuzzyDict): model with prescribed cell volume and cross-sectional area, and (if thermal effects are included) solves a lumped thermal model with prescribed surface area for cooling. + * "compute heat source for isothermal models" : str + Whether to compute the heat source terms during isothermal operation. + Can be "true" or "false". If "false", the heat source terms are set + to zero. Default is "false" since this option may require additional + parameters not needed by the electrochemical model. * "convection" : str Whether to include the effects of convection in the model. Can be "none" (default), "uniform transverse" or "full transverse". @@ -164,6 +169,7 @@ class BatteryModelOptions(pybamm.FuzzyDict): def __init__(self, extra_options): self.possible_options = { "cell geometry": ["arbitrary", "pouch"], + "compute heat source for isothermal models": ["false", "true"], "convection": ["none", "uniform transverse", "full transverse"], "current collector": [ "uniform", diff --git a/pybamm/models/submodels/thermal/isothermal.py b/pybamm/models/submodels/thermal/isothermal.py index ad6fe04271..f02396c302 100644 --- a/pybamm/models/submodels/thermal/isothermal.py +++ b/pybamm/models/submodels/thermal/isothermal.py @@ -44,5 +44,37 @@ def get_fundamental_variables(self): return variables def get_coupled_variables(self, variables): - variables.update(self._get_standard_coupled_variables(variables)) + if self.options["compute heat source for isothermal models"] == "true": + variables.update(self._get_standard_coupled_variables(variables)) + else: + ieh = "irreversible electrochemical heating" + variables.update( + { + "Ohmic heating": pybamm.Scalar(0), + "Ohmic heating [W.m-3]": pybamm.Scalar(0), + "X-averaged Ohmic heating": pybamm.Scalar(0), + "X-averaged Ohmic heating [W.m-3]": pybamm.Scalar(0), + "Volume-averaged Ohmic heating": pybamm.Scalar(0), + "Volume-averaged Ohmic heating [W.m-3]": pybamm.Scalar(0), + "Irreversible electrochemical heating": pybamm.Scalar(0), + "Irreversible electrochemical heating [W.m-3]": pybamm.Scalar(0), + "X-averaged " + ieh: pybamm.Scalar(0), + "X-averaged " + ieh + " [W.m-3]": pybamm.Scalar(0), + "Volume-averaged " + ieh: pybamm.Scalar(0), + "Volume-averaged " + ieh + "[W.m-3]": pybamm.Scalar(0), + "Reversible heating": pybamm.Scalar(0), + "Reversible heating [W.m-3]": pybamm.Scalar(0), + "X-averaged reversible heating": pybamm.Scalar(0), + "X-averaged reversible heating [W.m-3]": pybamm.Scalar(0), + "Volume-averaged reversible heating": pybamm.Scalar(0), + "Volume-averaged reversible heating [W.m-3]": pybamm.Scalar(0), + "Total heating": pybamm.Scalar(0), + "Total heating [W.m-3]": pybamm.Scalar(0), + "X-averaged total heating": pybamm.Scalar(0), + "X-averaged total heating [W.m-3]": pybamm.Scalar(0), + "Volume-averaged total heating": pybamm.Scalar(0), + "Volume-averaged total heating [W.m-3]": pybamm.Scalar(0), + } + ) + return variables diff --git a/tests/unit/test_models/test_full_battery_models/test_base_battery_model.py b/tests/unit/test_models/test_full_battery_models/test_base_battery_model.py index a6cd53ac50..991aff5347 100644 --- a/tests/unit/test_models/test_full_battery_models/test_base_battery_model.py +++ b/tests/unit/test_models/test_full_battery_models/test_base_battery_model.py @@ -15,6 +15,7 @@ PRINT_OPTIONS_OUTPUT = """\ 'cell geometry': 'pouch' (possible: ['arbitrary', 'pouch']) +'compute heat source for isothermal models': 'false' (possible: ['false', 'true']) 'convection': 'none' (possible: ['none', 'uniform transverse', 'full transverse']) 'current collector': 'uniform' (possible: ['uniform', 'potential pair', 'potential pair quite conductive']) 'dimensionality': 0 (possible: [0, 1, 2]) diff --git a/tests/unit/test_models/test_full_battery_models/test_lithium_ion/base_lithium_ion_tests.py b/tests/unit/test_models/test_full_battery_models/test_lithium_ion/base_lithium_ion_tests.py index 2aa77ce113..ffe047658c 100644 --- a/tests/unit/test_models/test_full_battery_models/test_lithium_ion/base_lithium_ion_tests.py +++ b/tests/unit/test_models/test_full_battery_models/test_lithium_ion/base_lithium_ion_tests.py @@ -13,6 +13,13 @@ def test_well_posed(self): options = {"thermal": "isothermal"} self.check_well_posedness(options) + def test_well_posed_isothermal_heat_source(self): + options = { + "compute heat source for isothermal models": "true", + "thermal": "isothermal", + } + self.check_well_posedness(options) + def test_well_posed_2plus1D(self): options = {"current collector": "potential pair", "dimensionality": 1} self.check_well_posedness(options) From 9a1f4553a4a4c831ec4ff0c4d2e8e83b8d74dd58 Mon Sep 17 00:00:00 2001 From: Robert Timms Date: Mon, 7 Mar 2022 09:29:01 +0000 Subject: [PATCH 5/6] #1957 changelog --- CHANGELOG.md | 4 ++++ pybamm/scikits_odes_setup.log | 3 +++ 2 files changed, 7 insertions(+) create mode 100644 pybamm/scikits_odes_setup.log diff --git a/CHANGELOG.md b/CHANGELOG.md index 16eef63d26..bd6d617eb7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # [Unreleased](https://github.com/pybamm-team/PyBaMM/) +## Features + +- Added an option "compute heat source for isothermal models" to choose whether or not the heat generation terms are computed when running models with the option `thermal="isothermal"` ([#1958](https://github.com/pybamm-team/PyBaMM/pull/1958)) + ## Bug fixes - Fixed a bug where isothermal models did not compute any heat source terms ([#1958](https://github.com/pybamm-team/PyBaMM/pull/1958)) diff --git a/pybamm/scikits_odes_setup.log b/pybamm/scikits_odes_setup.log new file mode 100644 index 0000000000..689d8b1624 --- /dev/null +++ b/pybamm/scikits_odes_setup.log @@ -0,0 +1,3 @@ +2022-03-04 15:15:46,487 - scikits.odes setup - INFO - Starting scikits.odes setup +2022-03-04 15:15:46,488 - scikits.odes setup - INFO - Looking for sundials at /home/user/.local +2022-03-04 15:15:46,488 - scikits.odes setup - INFO - Found sundials at /home/user/.local From 2de921e60fd91a83e3d17af637e1ad8d25280472 Mon Sep 17 00:00:00 2001 From: Robert Timms Date: Wed, 9 Mar 2022 10:01:56 +0000 Subject: [PATCH 6/6] #1957 remove scikits log --- pybamm/models/full_battery_models/base_battery_model.py | 2 +- pybamm/scikits_odes_setup.log | 3 --- 2 files changed, 1 insertion(+), 4 deletions(-) delete mode 100644 pybamm/scikits_odes_setup.log diff --git a/pybamm/models/full_battery_models/base_battery_model.py b/pybamm/models/full_battery_models/base_battery_model.py index 0d99387d27..dc128b438a 100644 --- a/pybamm/models/full_battery_models/base_battery_model.py +++ b/pybamm/models/full_battery_models/base_battery_model.py @@ -27,7 +27,7 @@ class BatteryModelOptions(pybamm.FuzzyDict): (if thermal effects are included) solves a lumped thermal model with prescribed surface area for cooling. * "calculate heat source for isothermal models" : str - Whether to compute the heat source terms during isothermal operation. + Whether to calculate the heat source terms during isothermal operation. Can be "true" or "false". If "false", the heat source terms are set to zero. Default is "false" since this option may require additional parameters not needed by the electrochemical model. diff --git a/pybamm/scikits_odes_setup.log b/pybamm/scikits_odes_setup.log deleted file mode 100644 index 689d8b1624..0000000000 --- a/pybamm/scikits_odes_setup.log +++ /dev/null @@ -1,3 +0,0 @@ -2022-03-04 15:15:46,487 - scikits.odes setup - INFO - Starting scikits.odes setup -2022-03-04 15:15:46,488 - scikits.odes setup - INFO - Looking for sundials at /home/user/.local -2022-03-04 15:15:46,488 - scikits.odes setup - INFO - Found sundials at /home/user/.local