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

rename CrateTermination to CRateTermination because the step is CRate #4834

Merged
merged 3 commits into from
Feb 11, 2025
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
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@
- Added 'get_summary_variables' to return dictionary of computed summary variables ([#4824](https://github.com/pybamm-team/PyBaMM/pull/4824))
- Added support for particle size distributions combined with particle mechanics. ([#4807](https://github.com/pybamm-team/PyBaMM/pull/4807))

## Breaking changes

- Deprecated `CrateTermination` and renamed it to `CRateTermination`. ([#4834](https://github.com/pybamm-team/PyBaMM/pull/4834))

# [v25.1.1](https://github.com/pybamm-team/PyBaMM/tree/v25.1.1) - 2025-01-20

## Features
Expand Down
2 changes: 1 addition & 1 deletion docs/source/api/experiment/experiment_steps.rst
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ Standard step termination events are implemented by the following classes, which
called when the termination is specified by a specific string. These classes can be
either be called directly or via the string format specified in the class docstring

.. autoclass:: pybamm.step.CrateTermination
.. autoclass:: pybamm.step.CRateTermination
:members:

.. autoclass:: pybamm.step.CurrentTermination
Expand Down
2 changes: 1 addition & 1 deletion src/pybamm/experiment/step/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from .steps import *
from .base_step import BaseStep, BaseStepExplicit, BaseStepImplicit
from .step_termination import BaseTermination, CurrentTermination, VoltageTermination, CustomTermination, CrateTermination, _read_termination
from .step_termination import BaseTermination, CurrentTermination, VoltageTermination, CustomTermination, CRateTermination, CrateTermination, _read_termination

__all__ = ['base_step', 'step_termination', 'steps']
19 changes: 17 additions & 2 deletions src/pybamm/experiment/step/step_termination.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import pybamm
from warnings import warn


class BaseTermination:
Expand Down Expand Up @@ -43,7 +44,7 @@ def __eq__(self, other):
return False


class CrateTermination(BaseTermination):
class CRateTermination(BaseTermination):
"""
Termination based on C-rate, created when a string termination of the C-rate type
(e.g. "C/10") is provided
Expand All @@ -60,6 +61,20 @@ def get_event(self, variables, step):
return event


class CrateTermination(CRateTermination):
"""
Termination based on C-rate, created when a string termination of the C-rate type
(e.g. "C/10") is provided
"""

def __init__(self, value, operator=None):
super().__init__(value, operator)
warning = DeprecationWarning(
"CrateTermination is deprecated and will be removed in a future release. Use CRateTermination instead."
)
warn(warning, stacklevel=2)


class CurrentTermination(BaseTermination):
"""
Termination based on current, created when a string termination of the current type
Expand Down Expand Up @@ -193,6 +208,6 @@ def _read_termination(termination):
termination_class = {
"current": CurrentTermination,
"voltage": VoltageTermination,
"C-rate": CrateTermination,
"C-rate": CRateTermination,
}[typ]
return termination_class(value)
13 changes: 13 additions & 0 deletions tests/unit/test_experiments/test_experiment_step_termination.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,16 @@ def test_base_termination(self):
assert term == pybamm.step.BaseTermination(1)
assert term != pybamm.step.BaseTermination(2)
assert term != pybamm.step.CurrentTermination(1)

def test_c_rate_termination(self):
term = pybamm.step.CRateTermination(0.02)
assert term.value == 0.02
assert term.operator is None
variables = {"C-rate": pybamm.Scalar(0.02)}
assert term.get_event(variables, None).evaluate() == 0
with pytest.warns(DeprecationWarning):
term_old = pybamm.step.CrateTermination(0.02)
assert (
term.get_event(variables, None).evaluate()
== term_old.get_event(variables, None).evaluate()
)
2 changes: 1 addition & 1 deletion tests/unit/test_experiments/test_experiment_steps.py
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ def test_step_string(self):
"value": 3,
"type": "Voltage",
"duration": 3600 * 24,
"termination": [pybamm.step.CrateTermination(0.02)],
"termination": [pybamm.step.CRateTermination(0.02)],
},
{
"type": "CRate",
Expand Down