Skip to content

Commit

Permalink
#2376 changelog
Browse files Browse the repository at this point in the history
  • Loading branch information
rtimms committed Dec 14, 2022
1 parent 80e26e1 commit 6528ea9
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 3 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

- Add functionality to create `pybamm.ParameterValues` from a [BPX standard](https://github.com/pybamm-team/BPX) JSON file ([#2555](https://github.com/pybamm-team/PyBaMM/pull/2555)).
- Added variables "Loss of lithium due to loss of active material in negative/positive electrode [mol]". These should be included in the calculation of "total lithium in system" to make sure that lithium is truly conserved. ([#2529](https://github.com/pybamm-team/PyBaMM/pull/2529))
- `initial_soc` can now be a string "x V", in which case the simulation is initialized to start from that voltage ([#2508](https://github.com/pybamm-team/PyBaMM/pull/2508))
- The `ElectrodeSOH` solver can now calculate electrode balance based on a target "cell capacity" (requires cell capacity "Q" as input), as well as the default "cyclable cell capacity" (requires cyclable lithium capacity "Q_Li" as input). Use the keyword argument `known_value` to control which is used. ([#2508](https://github.com/pybamm-team/PyBaMM/pull/2508))
Expand Down
2 changes: 1 addition & 1 deletion pybamm/parameters/bpx.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ def bpx_to_param_dict(bpx: BPX) -> dict:
pybamm_dict[domain.pre_name + "Bruggeman coefficient (electrolyte)"] = 1.5
pybamm_dict[domain.pre_name + "Bruggeman coefficient (electrode)"] = 1.5

# BPX is for single-cell in series, user can chnage this later
# BPX is for single cell in series, user can change this later
pybamm_dict["Number of cells connected in series to make a battery"] = 1
pybamm_dict[
"Number of electrodes connected in parallel to make a cell"
Expand Down
25 changes: 23 additions & 2 deletions tests/unit/test_parameters/test_bpx.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,12 @@
import unittest
import json
import pybamm
import copy


class TestBPX(unittest.TestCase):
def test_bpx(self):
bpx_obj = {
def setUp(self):
self.base = {
"Header": {
"BPX": 1.0,
"Title": "Parametrisation example",
Expand Down Expand Up @@ -104,6 +105,9 @@ def test_bpx(self):
},
}

def test_bpx(self):
bpx_obj = copy.copy(self.base)

filename = "tmp.json"
with tempfile.NamedTemporaryFile(
suffix=filename, delete=False, mode="w"
Expand All @@ -125,6 +129,23 @@ def test_bpx(self):
sim = pybamm.Simulation(model, parameter_values=pv, experiment=experiment)
sim.solve()

def test_bpx_soc_error(self):
bpx_obj = copy.copy(self.base)

filename = "tmp.json"
with tempfile.NamedTemporaryFile(
suffix=filename, delete=False, mode="w"
) as tmp:
# write to a tempory file so we can
# get the source later on using inspect.getsource
# (as long as the file still exists)
json.dump(bpx_obj, tmp)
tmp.flush()

with self.assertRaisesRegex(ValueError, "Target SOC"):
pybamm.ParameterValues.create_from_bpx(tmp.name, target_soc=10)



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

0 comments on commit 6528ea9

Please sign in to comment.