[Numerics] Make sparse Jacobian accessible from Python

This commit is contained in:
Ray Speth 2025-01-03 13:12:59 -05:00 committed by Ingmar Schoegl
parent 9fa3dda0a7
commit 74340f8e03
2 changed files with 9 additions and 0 deletions

View File

@ -20,6 +20,7 @@ cdef extern from "cantera/numerics/EigenSparseJacobian.h" namespace "Cantera":
CxxEigenSparseJacobian() except +translate_exception
void printPreconditioner()
CxxSparseMatrix matrix() except +translate_exception
CxxSparseMatrix jacobian() except +translate_exception
cdef extern from "cantera/numerics/AdaptivePreconditioner.h" namespace "Cantera":
cdef cppclass CxxAdaptivePreconditioner "Cantera::AdaptivePreconditioner" \

View File

@ -86,6 +86,14 @@ cdef class EigenSparseJacobian(SystemJacobian):
cdef CxxSparseMatrix smat = self.sparse_jac.matrix()
return get_from_sparse(smat, smat.rows(), smat.cols())
property jacobian:
"""
Property to retrieve the latest Jacobian.
"""
def __get__(self):
cdef CxxSparseMatrix smat = self.sparse_jac.jacobian()
return get_from_sparse(smat, smat.rows(), smat.cols())
cdef class EigenSparseDirectJacobian(EigenSparseJacobian):
"""