Repository: pybamm-team/PyBaMM

Issue:
[Bug]: isothermal model doesn't get heat source terms
### Description

I changed it so that the isothermal models compute the heat source terms using the fixed temperature rather than returning zero, but I forgot to add a `get_coupled_variables` method to `Isothermal` so it currently doesn't calculate anything! Whoops

### Motivation

_No response_

### Possible Implementation

_No response_

### Additional context

_No response_

Discussion:

Patch:
diff --git a/CHANGELOG.md b/CHANGELOG.md
index a2cdf8efd..22e31f970 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,5 +1,13 @@
 # [Unreleased](https://github.com/pybamm-team/PyBaMM/)
 
+## Features
+
+-   Added an option "calculate 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))
+
 ## Breaking changes
 
 -   Dropped support for Windows 32-bit architecture ([#1964](https://github.com/pybamm-team/PyBaMM/pull/1964))
@@ -8,7 +16,7 @@
 
 ## 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 calculate 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))
 
diff --git a/pybamm/models/full_battery_models/base_battery_model.py b/pybamm/models/full_battery_models/base_battery_model.py
index 80e2aa0b4..dc128b438 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.
+            * "calculate heat source for isothermal models" : str
+                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.
             * "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"],
+            "calculate 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 d620c8f38..2fd8270a7 100644
--- a/pybamm/models/submodels/thermal/isothermal.py
+++ b/pybamm/models/submodels/thermal/isothermal.py
@@ -42,3 +42,39 @@ class Isothermal(BaseThermal):
         )
 
         return variables
+
+    def get_coupled_variables(self, variables):
+        if self.options["calculate 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


Test patch:
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 a6cd53ac5..eff8b6490 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 @@ OPTIONS_DICT = {
 
 PRINT_OPTIONS_OUTPUT = """\
 'cell geometry': 'pouch' (possible: ['arbitrary', 'pouch'])
+'calculate 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 2aa77ce11..1ccc80fd9 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 @@ class BaseUnitTestLithiumIon:
         options = {"thermal": "isothermal"}
         self.check_well_posedness(options)
 
+    def test_well_posed_isothermal_heat_source(self):
+        options = {
+            "calculate 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)