-
-
Notifications
You must be signed in to change notification settings - Fork 589
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#759 create Event class for storing events of different types
- Loading branch information
1 parent
f772517
commit 4618751
Showing
10 changed files
with
122 additions
and
29 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
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,52 @@ | ||
import pybamm | ||
|
||
from enum import Enum | ||
|
||
|
||
class EventType(Enum): | ||
"""Defines the type of event, see Event""" | ||
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: EventType | ||
An enum defining the type of event, see EventType | ||
expression: 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 __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 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