If I have an MTK model that contains one registered, numeric function, and this numeric function itself uses a nonlinear solver to find a solution…
Can I still linearize the MTK model in the normal way?
If I have an MTK model that contains one registered, numeric function, and this numeric function itself uses a nonlinear solver to find a solution…
Can I still linearize the MTK model in the normal way?
It depends on the specifics of the solver etc., but you might have to define the chain rule for the solver call yourself. ModelingToolkit.linearize
uses ForwardDiff.jl for the linearization. You could probably test this separate from MTK by trying to compute a gradient through your registered function using ForwardDiff.
We will probably use the SimpleTrustRegion solver from NonlinearSolve…
In that case it might work out of the box, I think that NonlinearSolve already defines the required chain rule