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