Microphysics
Microphysics copied to clipboard
use C++ autodiff to do Jacobians
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.
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.
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.
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.
yes, I realize that. I just thought it was neat. Never thought about this part before...
we have the core autodiff library merged and the screening functions currently use it. It is straightforward to extend to other things now.