Bounding variables in a NonlinearSystem using MTK


I have a general question about using ModelingToolkit when solving a NonlinearSystem.

I noticed when building an OptimizationSystem you can bound your variables. Modeling Optimization Problems · ModelingToolkit.jl
I was wondering if you could do the same when solving a NonlinearSystem. Does anyone know? I tried replicating the syntax shown in the link above in my NL system but it did not appear to work.

My motivation stems from the thought that placing bounds may be useful because my model will fail if certain variables dip below known physical bounds (e.g. temperature cannot be less than zero).

Thanks, Chris

I think this is possible, but not via the bounds syntax. You can replace x <= 0 with max(x,0) ~ 0. However, this is now highly non-linear and difficult to solve. Can you not just use an OptimizationSystem directly?

It was already discussed in How does ModelingToolkit use bounds metadata? - #6 by ChrisRackauckas
And I opened an issue based on @ChrisRackauckas reply here Consider supporting bounds for `NonlinearProblem` resolution · Issue #183 · SciML/NonlinearSolve.jl · GitHub

Sorry I missed that thread that was previously discussed.

Using the max method doesn’t sound worthwhile as you pointed out. However, converting the system to an OptimizationSystem sounds reasonable. I believe the equations eqs in the NonlinearSystem would simply become the constraints cons in the optimization sys, and the objective function would be left blank, if possible, right? If not, how would you suggest writing the obj func in order to trick the solver to not try to minimize the obj func, and simply solve the system of equations at hand.