-
-
Notifications
You must be signed in to change notification settings - Fork 213
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Errors and wrong solutions when solving NonlinearSystem
with initialization_eqs
#3458
Comments
sol[X2] # ERROR: ArgumentError: Symbol X2(t) is not present in the system. (should be 2.0). There is no equation for X2, so I don't see how or why this should be 2.0. You're missing an equation?
Since X2 is not defined, Γ[1] can be anything. |
Ok, that might make a bit of sense. My understanding was that initialization_eqs = [
X2 ~ Γ[1] - X1
] is the equation that allow us to compute Previously I instead did observed = [
X2 ~ Γ[1] - X1
] which still would be my preferred way, but I am also trying to explore alternatives. |
It was pointed out in that conversation that it's a bit ambiguous since using ModelingToolkit, OrdinaryDiffEqDefault, Test
using ModelingToolkit: t_nounits as t, D_nounits as D
# Defines the model.
@parameters k1 k2
@variables X1(t) X2(t)
@parameters Γ[1:1] = missing [guess = [1.0]]
eqs = [
0 ~ k1 * (Γ[1] - X1) - k2 * X1
X2 ~ Γ[1] - X1
]
initialization_eqs = [
Initial(X2) ~ Γ[1] - Initial(X1)
]
@mtkbuild nlsys = NonlinearSystem(eqs, [X1, X2], [k1, k2, Γ]; initialization_eqs)
# Creates the problem.
u0 = [X1 => 1.0, X2 => 2.0]
ps = [k1 => 0.1, k2 => 0.2]
nlprob = NonlinearProblem(nlsys, u0, ps)
# Solves the problem and check the solution.
sol = solve(nlprob)
sol[X1]
sol[X2]
sol.ps[k1]
sol.ps[k2]
sol.ps[Γ[1]] This won't work quite yet as we need to setup |
From the latest understanding this is what one should use with
structural_simplify
? Although, admittedly, I am not really sure anymore.Either case, there is problem with the solution, generating a mix of errors and wrong outputs when you check the solution.
Either this is a bug, or I still do not know how you are supposed to do this.
The text was updated successfully, but these errors were encountered: