I am trying to re-initialize an ODEProblem with a new x-position on the last point pos[1, end]
. A bit like in the example here: Initialization of ODESystems · ModelingToolkit.jl
dt = 0.05
tol = 1e-6
tspan = (0.0, se.duration)
ts = 0:dt:se.duration
p2 = [-40, 0, -47]
p1 = [0, 0, 0]
u0map = vcat(
[simple_sys.acc[j, i] => 0 for j in 1:3 for i in 1:se.segments],
[simple_sys.vel[j, i] => 0 for j in 1:3 for i in 1:se.segments+1],
[simple_sys.pos[j, end] => p2[j] for j in 1:3],
[simple_sys.pos[j, 1] => p1[j] for j in 1:3],
)
guesses = vcat(
[simple_sys.segment[j, i] => 1.0 for j in 1:3 for i in 1:se.segments],
[simple_sys.total_force[j, i] => 1.0 for j in 1:3 for i in 1:se.segments+1],
)
prob = ODEProblem(simple_sys, u0map, tspan; guesses, fully_determined=true) # how to remake iprob with new parameters
integ = init(prob, FBDF(autodiff=true); dt, abstol=tol, reltol=tol, saveat=ts)
prob = remake(prob; u0=[simple_sys.pos[1, end] => 40])
integ = init(prob, FBDF(autodiff=true); dt, abstol=tol, reltol=tol, saveat=ts)
But the line prob = remake(prob; u0=[simple_sys.pos[1, end] => 40])
is causing the error:
┌ Warning: Did not converge after `maxiters = 0` substitutions. Either there is a cycle in the rules or `maxiters` needs to be higher.
└ @ Symbolics ~/.julia/packages/Symbolics/GYV9b/src/variable.jl:546
┌ Warning: Did not converge after `maxiters = 0` substitutions. Either there is a cycle in the rules or `maxiters` needs to be higher.
└ @ Symbolics ~/.julia/packages/Symbolics/GYV9b/src/variable.jl:546
┌ Warning: Did not converge after `maxiters = 0` substitutions. Either there is a cycle in the rules or `maxiters` needs to be higher.
└ @ Symbolics ~/.julia/packages/Symbolics/GYV9b/src/variable.jl:546
┌ Warning: Did not converge after `maxiters = 0` substitutions. Either there is a cycle in the rules or `maxiters` needs to be higher.
└ @ Symbolics ~/.julia/packages/Symbolics/GYV9b/src/variable.jl:546
┌ Warning: Did not converge after `maxiters = 0` substitutions. Either there is a cycle in the rules or `maxiters` needs to be higher.
└ @ Symbolics ~/.julia/packages/Symbolics/GYV9b/src/variable.jl:546
┌ Warning: Did not converge after `maxiters = 0` substitutions. Either there is a cycle in the rules or `maxiters` needs to be higher.
└ @ Symbolics ~/.julia/packages/Symbolics/GYV9b/src/variable.jl:546
┌ Warning: Did not converge after `maxiters = 0` substitutions. Either there is a cycle in the rules or `maxiters` needs to be higher.
└ @ Symbolics ~/.julia/packages/Symbolics/GYV9b/src/variable.jl:546
ERROR: LoadError: Found symbolic value -(pos(t))[3, 1] + (pos(t))[3, 2] for variable (segment(t))[3, 1]. You may be missing an initial condition or have cyclic initial conditions. If this is intended, pass `symbolic_u0 = true`. In case the initial conditions are not cyclic but require more substitutions to resolve, increase `substitution_limit`. To report cycles in initial conditions of unknowns/parameters, pass `warn_cyclic_dependency = true`. If the cycles are still not reported, you may need to pass a larger value for `circular_dependency_max_cycle_length` or `circular_dependency_max_cycles`.
Stacktrace:
[1] better_varmap_to_vars(varmap::Dict{…}, vars::Vector{…}; tofloat::Bool, use_union::Bool, container_type::Type, toterm::Function, promotetoconcrete::Nothing, check::Bool, allow_symbolic::Bool)
@ ModelingToolkit ~/.julia/packages/ModelingToolkit/89pF2/src/systems/problem_utils.jl:303
[2] process_SciMLProblem(constructor::Type, sys::NonlinearSystem, u0map::Dict{…}, pmap::Dict{…}; build_initializeprob::Bool, implicit_dae::Bool, t::Nothing, guesses::Dict{…}, warn_initialize_determined::Bool, initialization_eqs::Vector{…}, eval_expression::Bool, eval_module::Module, fully_determined::Bool, check_initialization_units::Bool, tofloat::Bool, use_union::Bool, u0_constructor::typeof(identity), du0map::Nothing, check_length::Bool, symbolic_u0::Bool, warn_cyclic_dependency::Bool, circular_dependency_max_cycle_length::Int64, circular_dependency_max_cycles::Int64, substitution_limit::Int64, kwargs::@Kwargs{})
@ ModelingToolkit ~/.julia/packages/ModelingToolkit/89pF2/src/systems/problem_utils.jl:610
[3] (NonlinearProblem{true})(sys::NonlinearSystem, u0map::Dict{Any, Int64}, parammap::Dict{SymbolicUtils.BasicSymbolic{Real}, Float64}; check_length::Bool, kwargs::@Kwargs{})
@ ModelingToolkit ~/.julia/packages/ModelingToolkit/89pF2/src/systems/nonlinear/nonlinearsystem.jl:499
[4] (NonlinearProblem{true})(sys::NonlinearSystem, u0map::Dict{Any, Int64}, parammap::Dict{SymbolicUtils.BasicSymbolic{Real}, Float64})
@ ModelingToolkit ~/.julia/packages/ModelingToolkit/89pF2/src/systems/nonlinear/nonlinearsystem.jl:493
[5] NonlinearProblem(::NonlinearSystem, ::Dict{Any, Int64}, ::Vararg{Any}; kwargs::@Kwargs{})
@ ModelingToolkit ~/.julia/packages/ModelingToolkit/89pF2/src/systems/nonlinear/nonlinearsystem.jl:490
[6] NonlinearProblem(::NonlinearSystem, ::Dict{Any, Int64}, ::Vararg{Any})
@ ModelingToolkit ~/.julia/packages/ModelingToolkit/89pF2/src/systems/nonlinear/nonlinearsystem.jl:489
[7] ModelingToolkit.InitializationProblem{…}(sys::ODESystem, t::Float64, u0map::Dict{…}, parammap::Dict{…}; guesses::Vector{…}, check_length::Bool, warn_initialize_determined::Bool, initialization_eqs::Vector{…}, fully_determined::Bool, check_units::Bool, kwargs::@Kwargs{})
@ ModelingToolkit ~/.julia/packages/ModelingToolkit/89pF2/src/systems/diffeqs/abstractodesystem.jl:1330
[8] ModelingToolkit.InitializationProblem{true, SciMLBase.AutoSpecialize}(sys::ODESystem, t::Float64, u0map::Dict{Any, Any}, parammap::Dict{Any, Any})
@ ModelingToolkit ~/.julia/packages/ModelingToolkit/89pF2/src/systems/diffeqs/abstractodesystem.jl:1254
[9] (ModelingToolkit.InitializationProblem{true})(::ODESystem, ::Float64, ::Vararg{Any}; kwargs::@Kwargs{})
@ ModelingToolkit ~/.julia/packages/ModelingToolkit/89pF2/src/systems/diffeqs/abstractodesystem.jl:1232
[10] InitializationProblem
@ ~/.julia/packages/ModelingToolkit/89pF2/src/systems/diffeqs/abstractodesystem.jl:1231 [inlined]
[11] #InitializationProblem#991
@ ~/.julia/packages/ModelingToolkit/89pF2/src/systems/diffeqs/abstractodesystem.jl:1220 [inlined]
[12] InitializationProblem
@ ~/.julia/packages/ModelingToolkit/89pF2/src/systems/diffeqs/abstractodesystem.jl:1219 [inlined]
[13] remake_initializeprob(sys::ODESystem, odefn::Function, u0::Vector{Pair{Num, Int64}}, t0::Float64, p::Missing)
@ ModelingToolkit ~/.julia/packages/ModelingToolkit/89pF2/src/systems/nonlinear/initializesystem.jl:322
[14] remake_initialization_data
@ ~/.julia/packages/SciMLBase/gZRU3/src/remake.jl:216 [inlined]
[15] remake(prob::ODEProblem{…}; f::Missing, u0::Vector{…}, tspan::Missing, p::Missing, kwargs::Missing, interpret_symbolicmap::Bool, build_initializeprob::Bool, use_defaults::Bool, _kwargs::@Kwargs{})
@ SciMLBase ~/.julia/packages/SciMLBase/gZRU3/src/remake.jl:128
[16] macro expansion
@ ./timing.jl:279 [inlined]
[17] simulate(se::Settings3, simple_sys::ODESystem, p1::Vector{Int64}, p2::Vector{Int64})
@ Main ~/Code/Tethers.jl/src/Tether_10.jl:185
[18] main(; p1::Vector{Int64}, p2::Vector{Int64}, fix_p1::Bool, fix_p2::Bool)
@ Main ~/Code/Tethers.jl/src/Tether_10.jl:228
[19] top-level scope
@ ~/Code/Tethers.jl/src/Tether_10.jl:236
[20] include(fname::String)
@ Base.MainInclude ./client.jl:494
[21] top-level scope
@ REPL[21]:1
in expression starting at /home/bart/Code/Tethers.jl/src/Tether_10.jl:236
Some type information was truncated. Use `show(err)` to see complete types.
What could be the issue here? I am on ModelingToolkit v. 9.51.0