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

Power mode bug #1735

Merged
merged 3 commits into from
Oct 11, 2021
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
13 changes: 10 additions & 3 deletions pybamm/expression_tree/symbol.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,9 +112,16 @@ def is_matrix_x(expr, x):

if is_constant(expr):
result = expr.evaluate_ignoring_errors(t=None)
return (issparse(result) and np.all(result.__dict__["data"] == x)) or (
isinstance(result, np.ndarray) and np.all(result == x)
)
return (
issparse(result)
and (
(x == 0 and np.prod(len(result.__dict__["data"])) == 0)
or (
len(result.__dict__["data"]) == np.prod(result.shape)
and np.all(result.__dict__["data"] == x)
)
)
) or (isinstance(result, np.ndarray) and np.all(result == x))
else:
return False

Expand Down
10 changes: 5 additions & 5 deletions pybamm/spatial_methods/finite_volume.py
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ def laplacian(self, symbol, discretised_symbol, boundary_conditions):
return self.divergence(grad, grad, boundary_conditions)

def integral(self, child, discretised_child, integration_dimension):
"""Vector-vector dot product to implement the integral operator. """
"""Vector-vector dot product to implement the integral operator."""
integration_vector = self.definite_integral_matrix(
child, integration_dimension=integration_dimension
)
Expand Down Expand Up @@ -315,9 +315,9 @@ def definite_integral_matrix(
# repeat matrix for each node in higher dimensions
third_dim_repeats = self._get_auxiliary_domain_repeats(
{
k: v for k, v in domains.items() if (
k == "tertiary" or k == "quaternary"
)
k: v
for k, v in domains.items()
if (k == "tertiary" or k == "quaternary")
}
)
# generate full matrix from the submatrix
Expand All @@ -330,7 +330,7 @@ def definite_integral_matrix(
return pybamm.Matrix(csr_matrix(matrix))

def indefinite_integral(self, child, discretised_child, direction):
"""Implementation of the indefinite integral operator. """
"""Implementation of the indefinite integral operator."""

# Different integral matrix depending on whether the integrand evaluates on
# edges or nodes
Expand Down