limited(actual, limiter) declares that the Newton updates of the
expression actual must be corrected at every iteration, in the manner of
SPICE junction voltage limiting. limiter is an expression in the
placeholders limitnew (the proposed value) and limitold (the previously
accepted value) and the parameters of the system; it must return
limitnew when limitnew == limitold.
Details
A NonlinearProblem() built from a system with limited nodes follows
the predictor and corrector formulation of Aadithya, Keiter and Mei: each
node becomes an auxiliary unknown limited_k with the equation
limited_k ~ actual, and the limiter is applied to that unknown after
every iterate the solver accepts. In ModelingToolkit the lowering happens
in mtkcompile; here it happens when the problem is built. Wherever the
operator is evaluated numerically, as in time dependent problems, it is
actual.
Examples
v <- Variable("v")
sys <- complete(System(list(0 ~ exp(limited(v, Min(limitnew, limitold + 1))) - 5), name = "lim"))
prob <- NonlinearProblem(sys, list(v ~ 0))
sol <- solve(prob, NewtonRaphson())
sol[v]
#> [1] 1.609438