-
-
Notifications
You must be signed in to change notification settings - Fork 535
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #808 from pybamm-team/issue-759-non-smooth-dae
Issue 759 non smooth dae
- Loading branch information
Showing
30 changed files
with
585 additions
and
190 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
Event | ||
===== | ||
|
||
.. autoclass:: pybamm.Event | ||
:members: | ||
|
||
.. autoclass:: pybamm.EventType | ||
:members: | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,3 +6,4 @@ Base Models | |
|
||
base_model | ||
base_battery_model | ||
event |
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
from enum import Enum | ||
|
||
|
||
class EventType(Enum): | ||
""" | ||
Defines the type of event, see :class:`pybamm.Event` | ||
TERMINATION indicates an event that will terminate the solver, the expression should | ||
return 0 when the event is triggered | ||
DISCONTINUITY indicates an expected discontinuity in the solution, the expression | ||
should return the time that the discontinuity occurs. The solver will integrate up | ||
to the discontinuity and then restart just after the discontinuity. | ||
""" | ||
TERMINATION = 0 | ||
DISCONTINUITY = 1 | ||
|
||
|
||
class Event: | ||
""" | ||
Defines an event for use within a pybamm model | ||
Attributes | ||
---------- | ||
name: str | ||
A string giving the name of the event | ||
event_type: :class:`pybamm.EventType` | ||
An enum defining the type of event | ||
expression: :class:`pybamm.Symbol` | ||
An expression that defines when the event occurs | ||
""" | ||
|
||
def __init__(self, name, expression, event_type=EventType.TERMINATION): | ||
self._name = name | ||
self._expression = expression | ||
self._event_type = event_type | ||
|
||
def evaluate(self, t=None, y=None, u=None, known_evals=None): | ||
""" | ||
Acts as a drop-in replacement for :func:`pybamm.Symbol.evaluate` | ||
""" | ||
return self._expression.evaluate(t, y, u, known_evals) | ||
|
||
def __str__(self): | ||
return self._name | ||
|
||
@property | ||
def name(self): | ||
return self._name | ||
|
||
@property | ||
def expression(self): | ||
return self._expression | ||
|
||
@expression.setter | ||
def expression(self, value): | ||
self._expression = value | ||
|
||
@property | ||
def event_type(self): | ||
return self._event_type |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.