Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue 2040 events #2212

Merged
merged 16 commits into from
Sep 6, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# [Unreleased](https://github.com/pybamm-team/PyBaMM/)

## Features

- For experiments, the simulation now automatically checks and skips steps that cannot be performed (e.g. "Charge at 1C until 4.2V" from 100% SOC) ([#2212](https://github.com/pybamm-team/PyBaMM/pull/2212))

## Breaking changes

- Events must now be defined in such a way that they are positive at the initial conditions (events will be triggered when they become negative, instead of when they change sign in either direction) ([#2212](https://github.com/pybamm-team/PyBaMM/pull/2212))

# [v22.8](https://github.com/pybamm-team/PyBaMM/tree/v22.8) - 2022-08-31

## Features
Expand Down
2 changes: 1 addition & 1 deletion pybamm/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@
#
# Solver classes
#
from .solvers.solution import Solution, make_cycle_solution
from .solvers.solution import Solution, EmptySolution, make_cycle_solution
from .solvers.processed_variable import ProcessedVariable
from .solvers.base_solver import BaseSolver
from .solvers.dummy_solver import DummySolver
Expand Down
3 changes: 2 additions & 1 deletion pybamm/expression_tree/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ class SolverError(Exception):
Solver error: a solution to the model could not be found with the chosen settings
"""

pass
def __init__(self, *args):
self.message = args[0]


class SolverWarning(UserWarning):
Expand Down
2 changes: 1 addition & 1 deletion pybamm/models/full_battery_models/base_battery_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -1340,7 +1340,7 @@ def x_not_zero(x):
self.events.append(
pybamm.Event(
"Maximum voltage",
V - self.param.voltage_high_cut,
self.param.voltage_high_cut - V,
pybamm.EventType.TERMINATION,
)
)
Expand Down
6 changes: 3 additions & 3 deletions pybamm/models/full_battery_models/lead_acid/basic_full.py
Original file line number Diff line number Diff line change
Expand Up @@ -231,13 +231,13 @@ def __init__(self, name="Basic full model"):
"Zero negative electrode porosity cut-off", pybamm.min(eps_n)
),
pybamm.Event(
"Max negative electrode porosity cut-off", pybamm.max(eps_n) - 1
"Max negative electrode porosity cut-off", 1 - pybamm.max(eps_n)
),
pybamm.Event(
"Zero positive electrode porosity cut-off", pybamm.min(eps_p)
),
pybamm.Event(
"Max positive electrode porosity cut-off", pybamm.max(eps_p) - 1
"Max positive electrode porosity cut-off", 1 - pybamm.max(eps_p)
),
]
)
Expand Down Expand Up @@ -294,6 +294,6 @@ def __init__(self, name="Basic full model"):
self.events.extend(
[
pybamm.Event("Minimum voltage", voltage - param.voltage_low_cut),
pybamm.Event("Maximum voltage", voltage - param.voltage_high_cut),
pybamm.Event("Maximum voltage", param.voltage_high_cut - voltage),
]
)
2 changes: 1 addition & 1 deletion pybamm/models/full_battery_models/lithium_ion/basic_dfn.py
Original file line number Diff line number Diff line change
Expand Up @@ -270,5 +270,5 @@ def __init__(self, name="Doyle-Fuller-Newman model"):
# Events specify points at which a solution should terminate
self.events += [
pybamm.Event("Minimum voltage", voltage - param.voltage_low_cut),
pybamm.Event("Maximum voltage", voltage - param.voltage_high_cut),
pybamm.Event("Maximum voltage", param.voltage_high_cut - voltage),
]
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,7 @@ def __init__(self, options=None, name="Doyle-Fuller-Newman half cell model"):
self.events.append(
pybamm.Event(
"Maximum voltage",
voltage_dim - self.param.voltage_high_cut_dimensional,
self.param.voltage_high_cut_dimensional - voltage_dim,
pybamm.EventType.TERMINATION,
)
)
Expand Down
2 changes: 1 addition & 1 deletion pybamm/models/full_battery_models/lithium_ion/basic_spm.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,5 +179,5 @@ def __init__(self, name="Single Particle Model"):
}
self.events += [
pybamm.Event("Minimum voltage", V - param.voltage_low_cut),
pybamm.Event("Maximum voltage", V - param.voltage_high_cut),
pybamm.Event("Maximum voltage", param.voltage_high_cut - V),
]
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,8 @@ def set_events(self, variables):
self.events.append(
pybamm.Event(
f"{domain} particle crack length larger than particle radius",
pybamm.max(l_cr)
- self.domain_param.prim.R_typ / self.domain_param.l_cr_0,
self.domain_param.prim.R_typ / self.domain_param.l_cr_0
- pybamm.max(l_cr),
pybamm.EventType.TERMINATION,
)
)
4 changes: 2 additions & 2 deletions pybamm/models/submodels/porosity/base_porosity.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ def set_events(self, variables):
self.events.append(
pybamm.Event(
"Max negative electrode porosity cut-off",
pybamm.max(eps_n) - 1,
1 - pybamm.max(eps_n),
pybamm.EventType.TERMINATION,
)
)
Expand All @@ -134,7 +134,7 @@ def set_events(self, variables):
self.events.append(
pybamm.Event(
"Max positive electrode porosity cut-off",
pybamm.max(eps_p) - 1,
1 - pybamm.max(eps_p),
pybamm.EventType.TERMINATION,
)
)
Loading