Skip to content

Commit

Permalink
update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
rtimms committed Apr 11, 2024
1 parent c387732 commit 6f93f00
Show file tree
Hide file tree
Showing 6 changed files with 57 additions and 102 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

## Features

- "Basic" models are now compatible with experiments ([#3995](https://github.com/pybamm-team/PyBaMM/pull/3995))
- Updates multiprocess `Pool` in `BaseSolver.solve()` to be constructed with context `fork`. Adds small example for multiprocess inputs. ([#3974](https://github.com/pybamm-team/PyBaMM/pull/3974))
- Added custom experiment steps ([#3835](https://github.com/pybamm-team/PyBaMM/pull/3835))
- Added support for macOS arm64 (M-series) platforms. ([#3789](https://github.com/pybamm-team/PyBaMM/pull/3789))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ def set_degradation_variables(self):
)

# Lithium lost to side reactions
# Different way of measuring LLI but should give same value
# Different way of LLI but should give same value
n_Li_lost_neg_sei = self.variables["Loss of lithium to negative SEI [mol]"]
n_Li_lost_pos_sei = self.variables["Loss of lithium to positive SEI [mol]"]
n_Li_lost_reactions = n_Li_lost_neg_sei + n_Li_lost_pos_sei
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -407,3 +407,7 @@ def __init__(self, name="Composite graphite/silicon Doyle-Fuller-Newman model"):
# per-cycle when running experiments. Typically used to track degradation
# variables (e.g LAM, LLI, capacity fade, etc.)
self.summary_variables = ["Time [s]", "Voltage [V]"]

@property
def default_parameter_values(self):
return pybamm.ParameterValues("Chen2020_composite")

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
#
# Test basic model classes
#
from tests import TestCase
import pybamm

import unittest


class BaseBasicModelTest:
def test_with_experiment(self):
model = self.model
experiment = pybamm.Experiment(
[
"Discharge at C/3 until 3.5V",
"Hold at 3.5V for 1 hour",
"Rest for 10 min",
]
)
sim = pybamm.Simulation(model, experiment=experiment)
sim.solve(calc_esoh=False)


class TestBasicSPM(BaseBasicModelTest, TestCase):
def setUp(self):
self.model = pybamm.lithium_ion.SPM()


class TestBasicDFN(BaseBasicModelTest, TestCase):
def setUp(self):
self.model = pybamm.lithium_ion.DFN()


class TestBasicDFNComposite(BaseBasicModelTest, TestCase):
def setUp(self):
self.model = pybamm.lithium_ion.BasicDFNComposite()


class TestBasicDFNHalfCell(BaseBasicModelTest, TestCase):
def setUp(self):
options = {"working electrode": "positive"}
self.model = pybamm.lithium_ion.BasicDFNHalfCell(options)


if __name__ == "__main__":
print("Add -v for more debug output")
import sys

if "-v" in sys.argv:
debug = True
unittest.main()
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,6 @@ def test_dfn_well_posed(self):
model = pybamm.lithium_ion.BasicDFN()
model.check_well_posedness()

copy = model.new_copy()
copy.check_well_posedness()

def test_spm_well_posed(self):
model = pybamm.lithium_ion.BasicSPM()
model.check_well_posedness()
Expand All @@ -23,26 +20,6 @@ def test_dfn_half_cell_well_posed(self):
model = pybamm.lithium_ion.BasicDFNHalfCell(options=options)
model.check_well_posedness()

def test_dfn_half_cell_simulation_with_experiment_error(self):
options = {"working electrode": "positive"}
model = pybamm.lithium_ion.BasicDFNHalfCell(options=options)
experiment = pybamm.Experiment(
[("Discharge at C/10 for 10 hours or until 3.5 V")]
)
with self.assertRaisesRegex(
NotImplementedError,
"BasicDFNHalfCell is not compatible with experiment simulations.",
):
pybamm.Simulation(model, experiment=experiment)

def test_basic_dfn_half_cell_simulation(self):
model = pybamm.lithium_ion.BasicDFNHalfCell(
options={"working electrode": "positive"}
)
sim = pybamm.Simulation(model=model)
sim.solve([0, 100])
self.assertTrue(isinstance(sim.solution, pybamm.solvers.solution.Solution))

def test_dfn_composite_well_posed(self):
model = pybamm.lithium_ion.BasicDFNComposite()
model.check_well_posedness()
Expand Down

0 comments on commit 6f93f00

Please sign in to comment.