Cantera / enhancements

Repository for proposed and ongoing enhancements to Cantera
11 stars 5 forks source link

Provide Jacobian to Sundials solvers #86

Open ischoegl opened 3 years ago

ischoegl commented 3 years ago

Abstract

By default, CVODES uses an internal difference quotient function for dense and band matrices. Per user guide:

If a matrix-based linear solver module is used (i.e., a non-NULL SUNmatrix object was supplied to CVodeSetLinearSolver), the user may optionally provide a function of type CVodeJacFn for evaluating the Jacobian of the ODE right-hand side function (or an approximation of it).

Sparse Jacobian formulations are supported.

Motivation

Performance of 0D calculations.

Possible Solutions

Implement analytical derivatives for reaction rates, create user-defined CVLsJacFn to populate Jacobian and link to solver via CVodeSetJacFn.

References

kyleniemeyer commented 3 years ago

Hi @ischoegl, @anthony-walker is working on something extremely relevant to this already

anthony-walker commented 3 years ago

@ischoegl @kyleniemeyer my work should be easily adaptable to this. I will consider it moving forward while I am validating my current pull request.

ischoegl commented 3 years ago

@anthony-walker and @kyleniemeyer ... great! I typed this up as I was under the impression that work on Cantera/cantera#951 was for preconditioning.

PS: As an aside, I am currently looking at simplifying the reaction / reaction rate framework in Cantera/cantera#982. At the moment, Cantera/cantera#951 has not really touched this corner extensively?

anthony-walker commented 3 years ago

@ischoegl Preconditioning is the main focus but the parts of the code affected are the same. I think I have an idea for how to easily adapt what I have.

ischoegl commented 3 years ago

Sounds great - looking forward to seeing more of this! As noted above (my 'PS'), I am currently looking into some of the innermost functions (related to reaction rate evaluations). I am interested in 'inner' derivatives for a different reason, but there are obvious connections to what's needed for a composite formulation that's ultimately fed to Sundials.

PS: I guess I found what I was looking for in Cantera/cantera#951. You indeed calculate the Jacobian, but use a finite difference version (at least in void AdaptivePreconditioner::TemperatureDerivatives)