22
33Block / model matrix covered
44-----------------------------
5- lead_acid.LOQS — ODE on PyBaMM < 26.7, DAE from 26.7 on → CoSim blocks only there
5+ lead_acid.LOQS — ODE (all 4 blocks), except on PyBaMM 26.7 where it is a DAE
6+ → CoSim blocks only there
67lead_acid.Full — DAE → CoSim blocks only
78"""
89
3132
3233# PyBaMM 26.7 registers "voltage as a state" centrally on every
3334# BaseBatteryModel (default "true"), and lead-acid models don't support
34- # disabling it, so LOQS is a DAE from 26.7 on and can no longer run in the
35- # monolithic (ODE-only) blocks.
36- _PYBAMM_VERSION = tuple ( int ( x ) for x in pybamm . __version__ . split ( "." )[: 2 ])
37- _LOQS_IS_ODE = _PYBAMM_VERSION < ( 26 , 7 )
35+ # disabling it, so LOQS is a DAE there and can't run in the monolithic
36+ # (ODE-only) blocks. 26.8 defaults it back to "false", making LOQS an ODE
37+ # again. Detect this from the model itself rather than the version number.
38+ _LOQS_IS_ODE = not pybamm . lead_acid . LOQS (). algebraic
3839
3940# ---------------------------------------------------------------------------
4041# lead_acid.LOQS (ODE — all 4 blocks)
4445class TestLeadAcidLOQS (unittest .TestCase ):
4546 """lead_acid.LOQS with Sulzer2019 parameters.
4647
47- ODE model (all 4 blocks) on PyBaMM < 26.7; DAE (CoSim blocks only) from
48- 26.7 on . Sulzer2019 cutoffs: lower 1.75 V, upper 2.42 V, nominal capacity
48+ ODE model (all 4 blocks), except on PyBaMM 26.7 where it is a DAE (CoSim
49+ blocks only) . Sulzer2019 cutoffs: lower 1.75 V, upper 2.42 V, nominal capacity
4950 17 A·h.
5051 """
5152
@@ -57,32 +58,32 @@ def setUp(self):
5758 def _model (self ):
5859 return pybamm .lead_acid .LOQS ()
5960
60- @unittest .skipUnless (_LOQS_IS_ODE , "LOQS is a DAE on PyBaMM >= 26.7 " )
61+ @unittest .skipUnless (_LOQS_IS_ODE , "LOQS is a DAE on this PyBaMM version " )
6162 def test_electrical_smoke (self ):
6263 cell = run_electrical (self ._model (), self .pv , current = 17.0 )
6364 assert_electrical_outputs (self , cell , self .v_lo , self .v_hi )
6465
65- @unittest .skipUnless (_LOQS_IS_ODE , "LOQS is a DAE on PyBaMM >= 26.7 " )
66+ @unittest .skipUnless (_LOQS_IS_ODE , "LOQS is a DAE on this PyBaMM version " )
6667 def test_electrothermal_smoke (self ):
6768 cell = run_electrothermal (self ._model (), self .pv , current = 17.0 )
6869 assert_electrothermal_outputs (self , cell , self .v_lo , self .v_hi )
6970
70- @unittest .skipIf (_LOQS_IS_ODE , "LOQS is a pure ODE on PyBaMM < 26.7 " )
71+ @unittest .skipIf (_LOQS_IS_ODE , "LOQS is a pure ODE on this PyBaMM version " )
7172 def test_monolithic_electrical_raises (self ):
72- """LOQS is a DAE on PyBaMM >= 26.7 — CellElectrical must raise."""
73+ """Where LOQS is a DAE ( PyBaMM 26.7), CellElectrical must raise."""
7374 with self .assertRaises (NotImplementedError ):
7475 CellElectrical (model = self ._model (), parameter_values = self .pv )
7576
76- @unittest .skipIf (_LOQS_IS_ODE , "LOQS is a pure ODE on PyBaMM < 26.7 " )
77+ @unittest .skipIf (_LOQS_IS_ODE , "LOQS is a pure ODE on this PyBaMM version " )
7778 def test_monolithic_electrothermal_raises (self ):
78- """LOQS is a DAE on PyBaMM >= 26.7 — CellElectrothermal must raise."""
79+ """Where LOQS is a DAE ( PyBaMM 26.7), CellElectrothermal must raise."""
7980 with self .assertRaises (NotImplementedError ):
8081 CellElectrothermal (model = self ._model (), parameter_values = self .pv )
8182
8283 def test_cosim_electrical_smoke (self ):
8384 # On PyBaMM < 26.7, LOQS disables its Jacobian and IDAKLUSolver (the
8485 # co-sim default) errors without one; CasadiSolver works on every
85- # pinned version (25.12-26.7 ), so use it explicitly here.
86+ # pinned version (25.12-26.8 ), so use it explicitly here.
8687 solver = pybamm .CasadiSolver (mode = "safe" )
8788 cell = CellCoSimElectrical (
8889 model = self ._model (),
@@ -126,19 +127,19 @@ def test_cosim_electrothermal_smoke(self):
126127 sim .run (2 )
127128 assert_electrothermal_outputs (self , cell , self .v_lo , self .v_hi )
128129
129- @unittest .skipUnless (_LOQS_IS_ODE , "LOQS is a DAE on PyBaMM >= 26.7 " )
130+ @unittest .skipUnless (_LOQS_IS_ODE , "LOQS is a DAE on this PyBaMM version " )
130131 def test_electrical_soc_decreases (self ):
131132 """SOC must decrease under discharge current."""
132133 cell = run_electrical (self ._model (), self .pv , current = 17.0 , duration = 60 )
133134 self .assertLess (float (cell .outputs [2 ]), 1.0 )
134135
135- @unittest .skipUnless (_LOQS_IS_ODE , "LOQS is a DAE on PyBaMM >= 26.7 " )
136+ @unittest .skipUnless (_LOQS_IS_ODE , "LOQS is a DAE on this PyBaMM version " )
136137 def test_cutoff_values_match_parameter_set (self ):
137138 cell = CellElectrical (model = self ._model (), parameter_values = self .pv )
138139 self .assertAlmostEqual (cell ._v_lower , self .v_lo )
139140 self .assertAlmostEqual (cell ._v_upper , self .v_hi )
140141
141- @unittest .skipUnless (_LOQS_IS_ODE , "LOQS is a DAE on PyBaMM >= 26.7 " )
142+ @unittest .skipUnless (_LOQS_IS_ODE , "LOQS is a DAE on this PyBaMM version " )
142143 def test_q_dot_nonzero_during_discharge (self ):
143144 """Q_dot must be strictly positive during discharge (isothermal LOQS).
144145
@@ -152,7 +153,7 @@ def test_q_dot_nonzero_during_discharge(self):
152153 "Q_dot is zero — thermal model may not compute heat sources" ,
153154 )
154155
155- @unittest .skipUnless (_LOQS_IS_ODE , "LOQS is a DAE on PyBaMM >= 26.7 " )
156+ @unittest .skipUnless (_LOQS_IS_ODE , "LOQS is a DAE on this PyBaMM version " )
156157 def test_tamb_affects_temperature (self ):
157158 """A warmer ambient temperature must yield a higher output cell temperature."""
158159 solver = pybamm .CasadiSolver (mode = "safe" )
@@ -183,7 +184,7 @@ def test_tamb_affects_temperature(self):
183184 ),
184185 )
185186
186- @unittest .skipUnless (_LOQS_IS_ODE , "LOQS is a DAE on PyBaMM >= 26.7 " )
187+ @unittest .skipUnless (_LOQS_IS_ODE , "LOQS is a DAE on this PyBaMM version " )
187188 def test_soc_scale_factor (self ):
188189 """SOC must be well below 1.0 after sustained discharge.
189190
0 commit comments