Skip to content

Commit

Permalink
#1477 fix bug in base_solver
Browse files Browse the repository at this point in the history
  • Loading branch information
martinjrobins committed Aug 2, 2021
1 parent a1cf26e commit 5726251
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions pybamm/solvers/base_solver.py
Original file line number Diff line number Diff line change
Expand Up @@ -608,9 +608,9 @@ def jacp(*args, **kwargs):

# if we have changed the equations to include the explicit sensitivity
# equations, then we also need to update the mass matrix
n_inputs = model.len_rhs_sens // model.len_rhs
n_state_without_sens = model.len_rhs_and_alg
if calculate_sensitivities_explicit:
n_inputs = model.len_rhs_sens // model.len_rhs
if model.mass_matrix.shape[0] == n_state_without_sens:
model.mass_matrix_inv = pybamm.Matrix(
block_diag(
Expand All @@ -625,8 +625,7 @@ def jacp(*args, **kwargs):
)
else:
# take care if calculate_sensitivites used then not used
n_state_with_sens = model.len_rhs_and_alg * (n_inputs + 1)
if model.mass_matrix.shape[0] == n_state_with_sens:
if model.mass_matrix.shape[0] > n_state_without_sens:
model.mass_matrix_inv = pybamm.Matrix(
model.mass_matrix_inv.entries[:n_state_without_sens,
:n_state_without_sens]
Expand Down

0 comments on commit 5726251

Please sign in to comment.