Microphysics icon indicating copy to clipboard operation
Microphysics copied to clipboard

use C++ autodiff to do Jacobians

Open zingale opened this issue 4 years ago • 4 comments

Instead of hand-coding the Jacobians, we should explore using a C++ autodiff package, e.g.,

https://autodiff.github.io/

to construct the analytic Jacobians.

zingale avatar Jul 10 '20 15:07 zingale

Some aspects of this were addressed in #624 which automatically computes the derivatives with respect to Y in the Jacobian terms. However (at least for the aprox rates) we are still relying on analytical expressions for the d/dT terms, so there is still some possibility for improvement here.

maxpkatz avatar Jul 31 '21 04:07 maxpkatz

interesting question: since screening depends on the plasma state, does this mean that the Jacobian will never be sparse if we differentiate the screening with composition automagically.

zingale avatar Nov 28 '22 18:11 zingale

For the aprox networks, we could straightforwardly implement this in a way where nothing changes about that, because we're already only filling in Jacobian terms if the species we're taking the derivative wrt explicitly appears in the reaction, everything else gets compiled out. So I think that's more of an algorithmic question we would ask ourselves, which would also apply to the existing code.

maxpkatz avatar Nov 28 '22 18:11 maxpkatz

yes, I realize that. I just thought it was neat. Never thought about this part before...

zingale avatar Nov 28 '22 19:11 zingale

we have the core autodiff library merged and the screening functions currently use it. It is straightforward to extend to other things now.

zingale avatar Jun 29 '24 00:06 zingale