[sundials-users] quadrature of CVODE-computed state variables

0 views
Skip to first unread message

David Lorenzetti

unread,
Jan 6, 2026, 5:14:12 PM (5 days ago) Jan 6
to SUNDIAL...@listserv.llnl.gov
Sundials community,

I am using `CVode()` to integrate an ODE system, and would like to perform "pure quadrature integration" on the computed state variables.

So I am looking for advice on the best way to do this, from anybody who has dealt with this kind of problem before.

In particular, given a computed state variable y1, I would like to accumulate integrals of

\int  y1(t)^n dt

for various values of $n$.

Obviously for each state variable, and each value of `n`, I can just add another state variable, y2, with

d(y2) / dt = y1^n

However, I hate to blow up the size of the ODE system for what should be a trivial post-processing quadrature problem.

I saw in the frequently asked questions that CVODES has a way to mark such equations for "pure quadratic integration," so that those equations get left out of the system solutions
(https://sundials.readthedocs.io/en/latest/FAQ_link.html).

Having poked around in the CVODE documentation, I don't see that a similar capability exists in CVODE.

My sense is that the best option with CVODE is to run in one-step mode
(`itask = CV_ONE_STEP`),
and then, at the completion of each internal step, to use
`CVodeGetDky()`
to get at the details of the solution over each internal step.

A brute-force way to use `CVodeGetDky()` would be to perform numerical quadrature on values estimated by that function.  But I believe the solution is represented internally as a polynomial, in which case the quadrature problem has a straightforward analytical solution (given the polynomial coefficients).  So the best approach would be to use `CVodeGetDky()`, or perhaps direct inspection of the integrator memory, to extract the polynomial coefficients?

If anybody has any comments, suggestions, or advice, I look forward to learning it.

Thanks,
-Dave

David Lorenzetti
Lawrence Berkeley National Laboratory


To unsubscribe from the SUNDIALS-USERS list: write to: mailto:SUNDIALS-USERS-...@LISTSERV.LLNL.GOV

Balos, Cody

unread,
Jan 6, 2026, 5:20:58 PM (5 days ago) Jan 6
to SUNDIAL...@listserv.llnl.gov
Hi David,

There is not a similar capability in CVODE, but CVODES is just a superset of CVODE.  You should be able to switch to CVODES simply by linking to CVODES instead of CVODE and changing the include paths from cvode/cvode.h to cvodes/cvodes.h. Then you can consult https://sundials.readthedocs.io/en/latest/cvodes/Usage/SIM.html#integration-of-pure-quadrature-equations to learn more about how to use the pure quadrature integration capability of CVODES.

Regards,
Cody
Reply all
Reply to author
Forward
0 new messages