Skip to content

Commit 5726251

Browse files
committed
#1477 fix bug in base_solver
1 parent a1cf26e commit 5726251

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

pybamm/solvers/base_solver.py

+2-3
Original file line numberDiff line numberDiff line change
@@ -608,9 +608,9 @@ def jacp(*args, **kwargs):
608608

609609
# if we have changed the equations to include the explicit sensitivity
610610
# equations, then we also need to update the mass matrix
611-
n_inputs = model.len_rhs_sens // model.len_rhs
612611
n_state_without_sens = model.len_rhs_and_alg
613612
if calculate_sensitivities_explicit:
613+
n_inputs = model.len_rhs_sens // model.len_rhs
614614
if model.mass_matrix.shape[0] == n_state_without_sens:
615615
model.mass_matrix_inv = pybamm.Matrix(
616616
block_diag(
@@ -625,8 +625,7 @@ def jacp(*args, **kwargs):
625625
)
626626
else:
627627
# take care if calculate_sensitivites used then not used
628-
n_state_with_sens = model.len_rhs_and_alg * (n_inputs + 1)
629-
if model.mass_matrix.shape[0] == n_state_with_sens:
628+
if model.mass_matrix.shape[0] > n_state_without_sens:
630629
model.mass_matrix_inv = pybamm.Matrix(
631630
model.mass_matrix_inv.entries[:n_state_without_sens,
632631
:n_state_without_sens]

0 commit comments

Comments
 (0)