Initial condition underdefined in NonlinearProblem

The following works:

using ModelingToolkit, NonlinearSolve

# Define a nonlinear system
@variables x y z
@parameters σ ρ β
eqs = [0 ~ σ * (y - x)
       0 ~ x * (ρ - z) - y
       0 ~ x * y - β * z]
@mtkbuild ns = NonlinearSystem(eqs)

guesses = [x => y, y => 1.0, z => 0.0]
ps = [σ => 10.0, ρ => 26.0, β => 8 / 3]

prob = NonlinearProblem(ns, guesses, ps)
sol = solve(prob, NewtonRaphson())

output:
retcode: Success
u: 2-element Vector{Float64}:
 -2.129924444096732e-29
 -2.398137151871876e-28

While this doesn’t work:

using ModelingToolkit, NonlinearSolve

# Define a nonlinear system
@variables x y z
@parameters σ ρ β
eqs = [0 ~ σ * (y - x)
       0 ~ x * (ρ - z) - y
       0 ~ x * y - β * z]
@mtkbuild ns = NonlinearSystem(eqs)

guesses = [y => 1.0, z => 0.0]
ps = [σ => 10.0, ρ => 26.0, β => 8 / 3]

prob = NonlinearProblem(ns, guesses, ps)
sol = solve(prob, NewtonRaphson())

output:
ERROR: Initial condition underdefined. Some are missing from the variable map.
Please provide a default (`u0`), initialization equation, or guess
for the following variables:

Set(Any[x])

Is there a good reason for this? I would think that if the initial guess for σ and y are known, the program should be able to automatically calculate the initial guess for x using the equation 0 ~ σ * (y - x)

What version are you using? @cryptic.ax recently added guess propagation but it must just not hit this case.

ModelingToolkit v9.50.0
NonlinearSolve v4.1.0

We don’t build initialization systems for NonlinearProblem yet. The unknowns of the simplfied system are x and z, so it complains if you give it y instead of x because it doesn’t know how to solve for the latter from the former.

Are you planning to add initialization systems for NonlinearProblem?

Yes, it’s in the works

Nice!

Ahh I see why it’s doing this here. Yeah… okay I’ll do my morning reviews :sweat_smile: . Should come soon.