Skip to content

Commit

Permalink
#633 fixed rhs-alg id issue
Browse files Browse the repository at this point in the history
  • Loading branch information
Scottmar93 committed Oct 8, 2019
1 parent 66d4fd6 commit 6353506
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
3 changes: 2 additions & 1 deletion examples/scripts/DFN.py
Expand Up @@ -27,7 +27,8 @@

# solve model
t_eval = np.linspace(0, 0.2, 100)
solution = model.default_solver.solve(model, t_eval)
# solution = model.default_solver.solve(model, t_eval)
solution = pybamm.KLU().solve(model, t_eval)

# plot
plot = pybamm.QuickPlot(model, mesh, solution)
Expand Down
7 changes: 6 additions & 1 deletion pybamm/solvers/klu_sparse_solver.py
Expand Up @@ -115,6 +115,11 @@ def rootfn(t, y):

return return_root

# get ids of rhs and algebraic variables
rhs_ids = np.ones(self.rhs(0, y0).shape)
alg_ids = np.zeros(self.algebraic(0, y0).shape)
ids = np.concatenate((rhs_ids, alg_ids))

# solve
sol = klu.solve(
t_eval,
Expand All @@ -129,7 +134,7 @@ def rootfn(t, y):
rootfn,
num_of_events,
use_jac,
mass_matrix.diagonal(), # this should always just be the diagonals
ids,
rtol,
atol,
)
Expand Down

0 comments on commit 6353506

Please sign in to comment.