Skip to content

Commit

Permalink
pybamm-team#1358 added tests to improve coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
brosaplanella committed Feb 4, 2021
1 parent 16436f5 commit 4565460
Show file tree
Hide file tree
Showing 5 changed files with 57 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,10 @@ def test_options(self):
with self.assertRaisesRegex(pybamm.OptionError, "particle cracking"):
pybamm.BaseBatteryModel({"particle cracking": "bad particle cracking"})

# plating model
with self.assertRaisesRegex(pybamm.OptionError, "lithium plating"):
pybamm.BaseBatteryModel({"lithium plating": "bad plating"})

def test_build_twice(self):
model = pybamm.lithium_ion.SPM() # need to pick a model to set vars and build
with self.assertRaisesRegex(pybamm.ModelError, "Model already built"):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ def test_incompatible_options(self):
pybamm.lead_acid.BaseModel({"dimensionality": 1, "thermal": "x-full"})
with self.assertRaisesRegex(pybamm.OptionError, "SEI"):
pybamm.lead_acid.BaseModel({"sei": "constant"})
with self.assertRaisesRegex(pybamm.OptionError, "lithium plating"):
pybamm.lead_acid.BaseModel({"lithium plating": "reversible"})


if __name__ == "__main__":
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,23 @@ def test_well_posed_both_cracking(self):
model.check_well_posedness()


class TestSPMeWithPlating(unittest.TestCase):
def test_well_posed_none_plating(self):
options = {"lithium plating": "none"}
model = pybamm.lithium_ion.DFN(options)
model.check_well_posedness()

def test_well_posed_reversible_plating(self):
options = {"lithium plating": "reversible"}
model = pybamm.lithium_ion.DFN(options)
model.check_well_posedness()

def test_well_posed_irreversible_plating(self):
options = {"lithium plating": "irreversible"}
model = pybamm.lithium_ion.DFN(options)
model.check_well_posedness()


if __name__ == "__main__":
print("Add -v for more debug output")
import sys
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,23 @@ def test_well_posed_both_cracking(self):
model.check_well_posedness()


class TestSPMeWithPlating(unittest.TestCase):
def test_well_posed_none_plating(self):
options = {"lithium plating": "none"}
model = pybamm.lithium_ion.SPM(options)
model.check_well_posedness()

def test_well_posed_reversible_plating(self):
options = {"lithium plating": "reversible"}
model = pybamm.lithium_ion.SPM(options)
model.check_well_posedness()

def test_well_posed_irreversible_plating(self):
options = {"lithium plating": "irreversible"}
model = pybamm.lithium_ion.SPM(options)
model.check_well_posedness()


if __name__ == "__main__":
print("Add -v for more debug output")
import sys
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,23 @@ def test_well_posed_both_cracking(self):
model.check_well_posedness()


class TestSPMeWithPlating(unittest.TestCase):
def test_well_posed_none_plating(self):
options = {"lithium plating": "none"}
model = pybamm.lithium_ion.SPMe(options)
model.check_well_posedness()

def test_well_posed_reversible_plating(self):
options = {"lithium plating": "reversible"}
model = pybamm.lithium_ion.SPMe(options)
model.check_well_posedness()

def test_well_posed_irreversible_plating(self):
options = {"lithium plating": "irreversible"}
model = pybamm.lithium_ion.SPMe(options)
model.check_well_posedness()


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

0 comments on commit 4565460

Please sign in to comment.