Need help solving boundary value problem using SciML collocation, when I have unknown parameters in boundary conditions

I have a nonlinear two-point boundary value problem consisting of five first-order differential equations. There are three boundary conditions at t=0 and two at t=1. Each boundary condition set also has one unknown parameter, along with an additional constraint. I want to solve this problem using collocation, as it is expected to be stiff under some conditions. SciML gives a very clear example of using collocation to solve the Mathieu equation with one unknown parameter by setting “fit_parameters = true” in the BVP constructor. However, my problem differs from this example in two important ways: 1) The two unknown parameters are in the boundary conditions, not the differential equations. 2) Both the differential equations and the boundary conditions depend on a number of KNOWN parameters, currently in the vector p, and I don’t want the solver to attempt to fit those. The Mathieu example only has the one unknown parameter in p. Any help or advice would be appreciated. I’m very sorry, but I’m not able to share any actual code in a public forum.

Easiest thing is to just use a closure to bake those into f, and leave the parameters to fit as p. We’re improving this interface over time via SciMLStructures.jl but this is an easy way that will always work.

that’s fine

Chris, I’d been hoping to reach you concerning this issue. Thanks so much for your reply. I do have a few follow-up questions:

Knowing that I am allowed to use a closure for f is game-changing, so thanks very much for that. Am I right that I can also use closures for the bca and bcb boundary condition functions? Is it all right to use such closures as a (bca!, bcb!) tuple, so that I can continue to use the TwoPointBVProblem constructor?

In a related but somewhat different question, I know that I can make the MIRK collocation solvers use the trust region non-linear system solver by doing something like “MIRK6(nlsolve = TrustRegion(radius_update_scheme = RadiusUpdateSchemes.Yuan)”. Can I do the same thing with the LobattoIIIc or RaduaIIa collocation solvers? The TrustRegion solver is the only one I’ve found that (mostly) works for my problem. Using RobustMultiNewton always just defaults to TrustRegion anyway.

Your documentation for the FIRK collocation solvers states: " When solving large boundary value problems, choose [sic] a nested NonlinearSolve.jl solver by setting nested_nlsolve=true in FIRK solvers can achieve better performance." Should I do this? What are the advantages? Does this work in conjunction with the TrustRegion solver (see above)?

Thanks in advance for you help.

yes

it can but not always, it’s worth testing if you’re solving the same system with many different parameters