Skip to content

Commit e12badc

Browse files
authored
Change heat generation units and name (#12)
* Change heat generation units and name * Review comments
1 parent 44e58a3 commit e12badc

2 files changed

Lines changed: 37 additions & 37 deletions

File tree

src/pathsim_batt/cells/pybamm_cell.py

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -271,10 +271,10 @@ def reset(self) -> None:
271271
class CellElectrical(_CellBase):
272272
"""Cell block — electrical outputs only, external thermal coupling.
273273
274-
PathSim integrates both the electrochemical state (via the discretised
275-
PyBaMM ODE) and the cell temperature ODE. Wire ``Q_heat`` to a
276-
``LumpedThermal`` (or similar) block and feed its temperature output
277-
back to ``T_cell``.
274+
PathSim integrates the electrochemical state via the discretised PyBaMM
275+
ODE. Temperature dynamics live outside this block: wire ``Q_dot`` to a
276+
``LumpedThermal`` (or similar) block and feed its temperature output back
277+
to ``T_cell``.
278278
279279
.. note::
280280
The SPMe/SPM ODE is stiff. Use an implicit solver (e.g.
@@ -302,19 +302,19 @@ class CellElectrical(_CellBase):
302302
Outputs
303303
-------
304304
V (0) : terminal voltage [V]
305-
Q_heat (1) : X-averaged volumetric heat generation [W m⁻³]
305+
Q_dot (1) : total heat generation [W]
306306
SOC (2) : state of charge (0–1)
307307
"""
308308

309309
_thermal_option = "isothermal"
310310
_thermal_extra_options = {"calculate heat source for isothermal models": "true"}
311311
_pybamm_output_vars = [
312312
"Terminal voltage [V]",
313-
"X-averaged total heating [W.m-3]",
313+
"Total heating [W]",
314314
]
315315

316316
input_port_labels = {"I": 0, "T_cell": 1}
317-
output_port_labels = {"V": 0, "Q_heat": 1, "SOC": 2}
317+
output_port_labels = {"V": 0, "Q_dot": 1, "SOC": 2}
318318

319319

320320
class CellElectrothermal(_CellBase):
@@ -352,19 +352,19 @@ class CellElectrothermal(_CellBase):
352352
-------
353353
V (0) : terminal voltage [V]
354354
T (1) : cell temperature [K] (part of PyBaMM state)
355-
Q_heat (2) : X-averaged volumetric heat generation [W m⁻³]
355+
Q_dot (2) : total heat generation [W]
356356
SOC (3) : state of charge (0–1)
357357
"""
358358

359359
_thermal_option = "lumped"
360360
_pybamm_output_vars = [
361361
"Terminal voltage [V]",
362362
"X-averaged cell temperature [K]",
363-
"X-averaged total heating [W.m-3]",
363+
"Total heating [W]",
364364
]
365365

366366
input_port_labels = {"I": 0, "T_amb": 1}
367-
output_port_labels = {"V": 0, "T": 1, "Q_heat": 2, "SOC": 3}
367+
output_port_labels = {"V": 0, "T": 1, "Q_dot": 2, "SOC": 3}
368368

369369

370370
class CellCoSimElectrical(_CoSimCellBase):
@@ -396,11 +396,11 @@ class CellCoSimElectrical(_CoSimCellBase):
396396
_thermal_extra_options = {"calculate heat source for isothermal models": "true"}
397397
_pybamm_output_vars = [
398398
"Terminal voltage [V]",
399-
"X-averaged total heating [W.m-3]",
399+
"Total heating [W]",
400400
]
401401

402402
input_port_labels = {"I": 0, "T_cell": 1}
403-
output_port_labels = {"V": 0, "Q_heat": 1, "SOC": 2}
403+
output_port_labels = {"V": 0, "Q_dot": 1, "SOC": 2}
404404

405405

406406
class CellCoSimElectrothermal(_CoSimCellBase):
@@ -431,8 +431,8 @@ class CellCoSimElectrothermal(_CoSimCellBase):
431431
_pybamm_output_vars = [
432432
"Terminal voltage [V]",
433433
"X-averaged cell temperature [K]",
434-
"X-averaged total heating [W.m-3]",
434+
"Total heating [W]",
435435
]
436436

437437
input_port_labels = {"I": 0, "T_amb": 1}
438-
output_port_labels = {"V": 0, "T": 1, "Q_heat": 2, "SOC": 3}
438+
output_port_labels = {"V": 0, "T": 1, "Q_dot": 2, "SOC": 3}

tests/cells/test_pybamm_cell.py

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ def test_electrical_input_labels(self):
2121

2222
def test_electrical_output_labels(self):
2323
self.assertEqual(CellElectrical.output_port_labels["V"], 0)
24-
self.assertEqual(CellElectrical.output_port_labels["Q_heat"], 1)
24+
self.assertEqual(CellElectrical.output_port_labels["Q_dot"], 1)
2525
self.assertEqual(CellElectrical.output_port_labels["SOC"], 2)
2626

2727
def test_electrothermal_input_labels(self):
@@ -31,7 +31,7 @@ def test_electrothermal_input_labels(self):
3131
def test_electrothermal_output_labels(self):
3232
self.assertEqual(CellElectrothermal.output_port_labels["V"], 0)
3333
self.assertEqual(CellElectrothermal.output_port_labels["T"], 1)
34-
self.assertEqual(CellElectrothermal.output_port_labels["Q_heat"], 2)
34+
self.assertEqual(CellElectrothermal.output_port_labels["Q_dot"], 2)
3535
self.assertEqual(CellElectrothermal.output_port_labels["SOC"], 3)
3636

3737
def test_is_dynamic(self):
@@ -40,17 +40,17 @@ def test_is_dynamic(self):
4040

4141
def test_cosim_len_zero(self):
4242
cell_e = CellCoSimElectrical(dt=1.0)
43-
self.assertEqual(len(cell_e), 3) # V, Q_heat, SOC
43+
self.assertEqual(len(cell_e), 3) # V, Q_dot, SOC
4444
cell_et = CellCoSimElectrothermal(dt=1.0)
45-
self.assertEqual(len(cell_et), 4) # V, T, Q_heat, SOC
45+
self.assertEqual(len(cell_et), 4) # V, T, Q_dot, SOC
4646

4747
def test_len_zero(self):
4848
cell_e = CellElectrical()
4949
cell_e.set_solver(ESDIRK43, None)
50-
self.assertEqual(len(cell_e), 3) # V, Q_heat, SOC
50+
self.assertEqual(len(cell_e), 3) # V, Q_dot, SOC
5151
cell_et = CellElectrothermal()
5252
cell_et.set_solver(ESDIRK43, None)
53-
self.assertEqual(len(cell_et), 4) # V, T, Q_heat, SOC
53+
self.assertEqual(len(cell_et), 4) # V, T, Q_dot, SOC
5454

5555
def test_current_always_input(self):
5656
pv = pybamm.ParameterValues("Chen2020")
@@ -168,7 +168,7 @@ def test_outputs_in_range(self):
168168
self.sim.run(1)
169169
self.assertGreater(self.cell.outputs[0], 3.0) # V
170170
self.assertLess(self.cell.outputs[0], 4.3)
171-
self.assertGreaterEqual(self.cell.outputs[1], 0.0) # Q_heat
171+
self.assertGreaterEqual(self.cell.outputs[1], 0.0) # Q_dot
172172
self.assertGreater(self.cell.outputs[2], 0.0) # SOC
173173
self.assertLessEqual(self.cell.outputs[2], 1.0)
174174

@@ -190,11 +190,11 @@ def test_pathsim_state_advances(self):
190190
self.sim.run(2)
191191
self.assertFalse(np.allclose(self.cell.engine.state, state_before))
192192

193-
def test_q_heat_nonzero_during_discharge(self):
194-
"""Q_heat must be strictly positive when a discharge current flows.
193+
def test_q_dot_nonzero_during_discharge(self):
194+
"""Q_dot must be strictly positive when a discharge current flows.
195195
196196
With thermal='isothermal' PyBaMM does not compute heat source terms,
197-
so Q_heat would be identically zero — this test guards against that.
197+
so Q_dot would be identically zero — this test guards against that.
198198
"""
199199
cell = CellElectrical(initial_soc=1.0)
200200
I_src = Constant(5.0) # 1C-ish discharge
@@ -212,7 +212,7 @@ def test_q_heat_nonzero_during_discharge(self):
212212
self.assertGreater(
213213
cell.outputs[1],
214214
0.0,
215-
"Q_heat is zero — thermal model may not compute heat sources",
215+
"Q_dot is zero — thermal model may not compute heat sources",
216216
)
217217

218218
def test_temperature_input_affects_voltage(self):
@@ -276,7 +276,7 @@ def test_outputs_in_range(self):
276276
self.assertLess(self.cell.outputs[0], 4.3)
277277
self.assertGreater(self.cell.outputs[1], 250.0) # T
278278
self.assertLess(self.cell.outputs[1], 400.0)
279-
self.assertGreaterEqual(self.cell.outputs[2], 0.0) # Q_heat
279+
self.assertGreaterEqual(self.cell.outputs[2], 0.0) # Q_dot
280280
self.assertGreater(self.cell.outputs[3], 0.0) # SOC
281281
self.assertLessEqual(self.cell.outputs[3], 1.0)
282282

@@ -298,8 +298,8 @@ def test_pathsim_state_advances(self):
298298
self.sim.run(2)
299299
self.assertFalse(np.allclose(self.cell.engine.state, state_before))
300300

301-
def test_q_heat_nonzero_during_discharge(self):
302-
"""Q_heat must be strictly positive when a discharge current flows."""
301+
def test_q_dot_nonzero_during_discharge(self):
302+
"""Q_dot must be strictly positive when a discharge current flows."""
303303
cell = CellElectrothermal(initial_soc=1.0)
304304
I_src = Constant(5.0)
305305
T_src = Constant(298.15)
@@ -316,7 +316,7 @@ def test_q_heat_nonzero_during_discharge(self):
316316
self.assertGreater(
317317
cell.outputs[2],
318318
0.0,
319-
"Q_heat is zero — thermal model may not compute heat sources",
319+
"Q_dot is zero — thermal model may not compute heat sources",
320320
)
321321

322322
def test_tamb_input_affects_cell_temperature(self):
@@ -375,7 +375,7 @@ def test_outputs_in_range(self):
375375
self.sim.run(2)
376376
self.assertGreater(self.cell.outputs[0], 2.0) # V
377377
self.assertLess(self.cell.outputs[0], 5.0)
378-
self.assertGreaterEqual(self.cell.outputs[1], 0.0) # Q_heat
378+
self.assertGreaterEqual(self.cell.outputs[1], 0.0) # Q_dot
379379
self.assertGreater(self.cell.outputs[2], 0.0) # SOC
380380
self.assertLessEqual(self.cell.outputs[2], 1.0)
381381

@@ -403,8 +403,8 @@ def test_dfn_step_outputs_physical(self):
403403
self.assertGreater(cell.outputs[2], 0.0) # SOC
404404
self.assertLessEqual(cell.outputs[2], 1.0)
405405

406-
def test_q_heat_nonzero_during_discharge(self):
407-
"""Q_heat must be strictly positive when a discharge current flows."""
406+
def test_q_dot_nonzero_during_discharge(self):
407+
"""Q_dot must be strictly positive when a discharge current flows."""
408408
cell = CellCoSimElectrical(initial_soc=1.0, dt=10.0)
409409
I_src = Constant(5.0)
410410
T_src = Constant(298.15)
@@ -421,7 +421,7 @@ def test_q_heat_nonzero_during_discharge(self):
421421
self.assertGreater(
422422
cell.outputs[1],
423423
0.0,
424-
"Q_heat is zero — thermal model may not compute heat sources",
424+
"Q_dot is zero — thermal model may not compute heat sources",
425425
)
426426

427427
def test_temperature_input_affects_voltage(self):
@@ -479,7 +479,7 @@ def test_outputs_in_range(self):
479479
self.assertLess(self.cell.outputs[0], 5.0)
480480
self.assertGreater(self.cell.outputs[1], 250.0) # T
481481
self.assertLess(self.cell.outputs[1], 400.0)
482-
self.assertGreaterEqual(self.cell.outputs[2], 0.0) # Q_heat
482+
self.assertGreaterEqual(self.cell.outputs[2], 0.0) # Q_dot
483483
self.assertGreater(self.cell.outputs[3], 0.0) # SOC
484484
self.assertLessEqual(self.cell.outputs[3], 1.0)
485485

@@ -508,8 +508,8 @@ def test_dfn_step_outputs_physical(self):
508508
self.assertGreater(cell.outputs[3], 0.0) # SOC
509509
self.assertLessEqual(cell.outputs[3], 1.0)
510510

511-
def test_q_heat_nonzero_during_discharge(self):
512-
"""Q_heat must be strictly positive when a discharge current flows."""
511+
def test_q_dot_nonzero_during_discharge(self):
512+
"""Q_dot must be strictly positive when a discharge current flows."""
513513
cell = CellCoSimElectrothermal(initial_soc=1.0, dt=10.0)
514514
I_src = Constant(5.0)
515515
T_src = Constant(298.15)
@@ -526,7 +526,7 @@ def test_q_heat_nonzero_during_discharge(self):
526526
self.assertGreater(
527527
cell.outputs[2],
528528
0.0,
529-
"Q_heat is zero — thermal model may not compute heat sources",
529+
"Q_dot is zero — thermal model may not compute heat sources",
530530
)
531531

532532
def test_tamb_input_affects_cell_temperature(self):

0 commit comments

Comments
 (0)