Skip to content

Commit

Permalink
#633 started adding unit tests for KLU solver
Browse files Browse the repository at this point in the history
  • Loading branch information
Scottmar93 committed Oct 10, 2019
1 parent 3e1d87a commit 5fad697
Show file tree
Hide file tree
Showing 2 changed files with 673 additions and 8 deletions.
12 changes: 4 additions & 8 deletions pybamm/solvers/klu_sparse_solver.py
Expand Up @@ -34,9 +34,7 @@ def __init__(

super().__init__(method, tol, root_method, root_tol, max_steps)

def integrate(
self, residuals, y0, t_eval, events=None, mass_matrix=None, jacobian=None
):
def integrate(self, residuals, y0, t_eval, events, mass_matrix, jacobian):
"""
Solve a DAE model defined by residuals with initial conditions y0.
Expand All @@ -49,12 +47,12 @@ def integrate(
The initial conditions
t_eval : numeric type
The times at which to compute the solution
events : method, optional
events : method,
A function that takes in t and y and returns conditions for the solver to
stop
mass_matrix : array_like, optional
mass_matrix : array_like,
The (sparse) mass matrix for the chosen spatial method.
jacobian : method, optional
jacobian : method,
A function that takes in t and y and returns the Jacobian. If
None, the solver will approximate the Jacobian.
(see `SUNDIALS docs. <https://computation.llnl.gov/projects/sundials>`).
Expand All @@ -80,7 +78,6 @@ def jacfn(t, y, cj):
jac_eval = jacobian(t, y) - cj * mass_matrix
return sparse.csr_matrix(jac_eval)

# just defining this here for now...
class SundialsJacobian:
def __init__(self):
self.J = None
Expand All @@ -96,7 +93,6 @@ def jac_res(self, t, y, cj):
self.J = jacfn(t, y, cj)

def get_jac_data(self):
# print("nnz: ", self.J.nnz)
return self.J.data

def get_jac_row_vals(self):
Expand Down

0 comments on commit 5fad697

Please sign in to comment.