Skip to content

Commit

Permalink
#858 fixes for diff
Browse files Browse the repository at this point in the history
  • Loading branch information
martinjrobins committed Mar 7, 2020
1 parent c8eeb81 commit 06ccfe8
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
3 changes: 2 additions & 1 deletion pybamm/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,14 +108,15 @@ def version(formatted=False):
)
from .expression_tree.scalar import Scalar
from .expression_tree.variable import Variable, ExternalVariable, VariableDot
from .expression_tree.variable import VariableBase
from .expression_tree.independent_variable import (
IndependentVariable,
Time,
SpatialVariable,
)
from .expression_tree.independent_variable import t
from .expression_tree.vector import Vector
from .expression_tree.state_vector import StateVector, StateVectorDot
from .expression_tree.state_vector import StateVectorBase, StateVector, StateVectorDot

from .expression_tree.exceptions import (
DomainError,
Expand Down
8 changes: 6 additions & 2 deletions pybamm/expression_tree/symbol.py
Original file line number Diff line number Diff line change
Expand Up @@ -485,6 +485,12 @@ def diff(self, variable):
return pybamm.Scalar(1)
elif any(variable.id == x.id for x in self.pre_order()):
return self._diff(variable)
elif variable.id == pybamm.t.id and \
any(
isinstance(x, (pybamm.VariableBase, pybamm.StateVectorBase))
for x in self.pre_order()
):
return self._diff(variable)
else:
return pybamm.Scalar(0)

Expand Down Expand Up @@ -770,5 +776,3 @@ def test_shape(self):
self.shape_for_testing
except ValueError as e:
raise pybamm.ShapeError("Cannot find shape (original error: {})".format(e))


0 comments on commit 06ccfe8

Please sign in to comment.