Skip to content
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

Updated ODEProblem parameters don't propagate to initializeprob #2717

Open
MarcBerliner opened this issue May 15, 2024 · 0 comments
Open

Updated ODEProblem parameters don't propagate to initializeprob #2717

MarcBerliner opened this issue May 15, 2024 · 0 comments
Assignees
Labels
bug Something isn't working

Comments

@MarcBerliner
Copy link
Contributor

Setting new ODEProblem parameters with setp and remake do not update prob.f.initializeprob. E.g.,

using ModelingToolkit, SymbolicIndexingInterface, OrdinaryDiffEq
using ModelingToolkit: t_nounits as t
D = Differential(t)

pars = @parameters a = 1.0
vars = @variables begin
    x(t), [guess = 0.1]
    y(t), [guess = 1.0]
end

eqs = [D(x) ~ 1
    y ~ x]

initialization_eqs = [a ~ exp(-pi + x)]

@named sys = ODESystem(eqs, t, vars, pars; initialization_eqs)
sys = complete(structural_simplify(sys))

tspan = (0.0, 0.2)
prob = ODEProblem(sys, [], tspan, [])

setp(prob, a)(prob, NaN)
integ = init(prob, FBDF())
integ[x] = 3.1415926535896306 # should be NaN
# New parameter values
julia> prob.p[1]
1-element Vector{Float64}:
 NaN

julia> integ.p[1]
1-element Vector{Float64}:
 NaN
# Old parameter values
julia> prob.f.initializeprob.p[1]
2-element Vector{Float64}:
 1.0
 0.0

cc @AayushSabharwal

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants