Open bradcarman opened 2 days ago
Does it work if you add use_defaults = true
to remake()
?
use_defaults = true
doesn't work unfortunately, I still get...
julia> @test prb2.u0[4] == prb2.ps[x0] # ERROR!!
Test Failed at c:\Work\Packages\ActiveSuspension\ActiveSuspensionModel.jl\test\mwe.jl:16
Expression: prb2.u0[4] == prb2.ps[x0]
Evaluated: 1.0 == 10.0
Which means prb2
just takes the u0
value from prb
It works if you also pass u0 = Dict()
:
using Test
using ModelingToolkit
using ModelingToolkit: t_nounits as t, D_nounits as D
using DifferentialEquations
@parameters g x0
@variables x(t)=x0 y(t) [state_priority = 10] λ(t)
eqs = [D(D(x)) ~ λ * x
D(D(y)) ~ λ * y - g
x^2 + y^2 ~ 1]
@mtkbuild pend = ODESystem(eqs, t)
prb = ODEProblem(pend, [y => 0], (0.0, 1.5), [g => 1, x0 => 1], guesses = [λ => 1])
@test prb.u0[4] == prb.ps[x0]
prb2 = remake(prb; u0=Dict(), p=[x0=>10], use_defaults=true)
@test prb2.u0[4] == prb2.ps[x0]
Interesting, thanks for finding that! I think this should still stay open as a bug.
Also, use_defaults
is not needed here.
prb2 = remake(prb; u0=Dict(), p=[x0=>10])
@test prb2.u0[4] == prb2.ps[x0] # OK
@AayushSabharwal why would the Dict be required?
If either u0
or p
is not specified, it keeps its original value. This is to avoid updating based on dependent defaults when the user doesn't want to
I'm a little more concerned that defaults are used when use_defaults = false
😅
MWE...