forked from pybamm-team/PyBaMM
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into issue-744-particledistribution
- Loading branch information
Showing
32 changed files
with
757 additions
and
247 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,5 +16,6 @@ Expression Tree | |
concatenations | ||
broadcasts | ||
functions | ||
input_parameter | ||
interpolant | ||
operations/index |
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,5 @@ | ||
Input Parameter | ||
=============== | ||
|
||
.. autoclass:: pybamm.InputParameter | ||
: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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
# | ||
# Parameter classes | ||
# | ||
import numpy as np | ||
import pybamm | ||
|
||
|
||
class InputParameter(pybamm.Symbol): | ||
"""A node in the expression tree representing an input parameter | ||
This node's value can be set at the point of solving, allowing parameter estimation | ||
and control | ||
Parameters | ||
---------- | ||
name : str | ||
name of the node | ||
""" | ||
|
||
def __init__(self, name): | ||
super().__init__(name) | ||
|
||
def new_copy(self): | ||
""" See :meth:`pybamm.Symbol.new_copy()`. """ | ||
return InputParameter(self.name) | ||
|
||
def evaluate_for_shape(self): | ||
""" | ||
Returns the scalar 'NaN' to represent the shape of a parameter. | ||
See :meth:`pybamm.Symbol.evaluate_for_shape()` | ||
""" | ||
return np.nan | ||
|
||
def _jac(self, variable): | ||
""" See :meth:`pybamm.Symbol._jac()`. """ | ||
return pybamm.Scalar(0) | ||
|
||
def evaluate(self, t=None, y=None, u=None, known_evals=None): | ||
# u should be a dictionary | ||
# convert 'None' to empty dictionary for more informative error | ||
if u is None: | ||
u = {} | ||
if not isinstance(u, dict): | ||
# if the special input "shape test" is passed, just return 1 | ||
if u == "shape test": | ||
return 1 | ||
raise TypeError("inputs u should be a dictionary") | ||
try: | ||
return u[self.name] | ||
# raise more informative error if can't find name in dict | ||
except KeyError: | ||
raise KeyError("Input parameter '{}' not found".format(self.name)) |
Oops, something went wrong.