You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I noticed that with MTK@9.60 I can get an initialization failure if I deepcopy a particular system. I cannot reproduce it anymore with the current master, but I don't know if this issue was solve or it just no longer manifests.
Expected behavior
I would not expect to see any differences in behavior due to deepcopy.
Minimal Reproducible Example 👇
using ModelingToolkit, OrdinaryDiffEqRosenbrock
using ModelingToolkitStandardLibrary.Electrical
using ModelingToolkitStandardLibrary.Blocks: Sine
using ModelingToolkit: t_nounits as t
functioncreate_model(; C₁=2.4, C₂=60.0, f=1.0)
# V = 10.0@named resistor1 =Resistor(R=5.0)
@named resistor2 =Resistor(R=2.0)
@named capacitor1 =Capacitor(C=C₁)
@named capacitor2 =Capacitor(C=C₂)
@named source =Voltage()
@named input_signal =Sine(frequency=f)
@named ground =Ground()
@named ampermeter =CurrentSensor()
eqs = [connect(input_signal.output, source.V)
connect(source.p, capacitor1.n, capacitor2.n)
connect(source.n, resistor1.p, resistor2.p, ground.g)
connect(resistor1.n, capacitor1.p, ampermeter.n)
connect(resistor2.n, capacitor2.p, ampermeter.p)]
@named circuit_model =ODESystem(eqs, t,
systems=[
resistor1, resistor2, capacitor1, capacitor2,
source, input_signal, ground, ampermeter
])
end
model =create_model()
sys =structural_simplify(model)
@unpack ampermeter, capacitor2, capacitor1, resistor2 = model
ModelingToolkit.InitializationProblem(sys, 0, [capacitor2.v =>0.0,]) # works
ModelingToolkit.InitializationProblem(deepcopy(sys), 0, [capacitor2.v =>0.0,]) # ERROR: Initialization incomplete.
Error & Stacktrace ⚠️
ERROR: Initialization incomplete. Not all of the state variables of the
DAE system can be determined by the initialization. Missing
variables:
SymbolicUtils.BasicSymbolic{Real}[capacitor2₊v(t), capacitor1₊i(t)]
Stacktrace:
[1] ModelingToolkit.InitializationProblem{…}(sys::ODESystem, t::Int64, u0map::Vector{…}, parammap::SciMLBase.NullParameters; guesses::Vector{…}, check_length::Bool, warn_initialize_determined::Bool, initialization_eqs::Vector{…}, fully_determined::Nothing, check_units::Bool, use_scc::Bool, kwargs::@Kwargs{})
@ ModelingToolkit ~/.julia/packages/ModelingToolkit/iQ7So/src/systems/diffeqs/abstractodesystem.jl:1336
[2] InitializationProblem
@ ~/.julia/packages/ModelingToolkit/iQ7So/src/systems/diffeqs/abstractodesystem.jl:1285 [inlined]
[3] ModelingToolkit.InitializationProblem{true, SciMLBase.AutoSpecialize}(sys::ODESystem, t::Int64, u0map::Vector{Pair{…}})
@ ModelingToolkit ~/.julia/packages/ModelingToolkit/iQ7So/src/systems/diffeqs/abstractodesystem.jl:1285
[4] (ModelingToolkit.InitializationProblem{true})(::ODESystem, ::Int64, ::Vararg{Any}; kwargs::@Kwargs{})
@ ModelingToolkit ~/.julia/packages/ModelingToolkit/iQ7So/src/systems/diffeqs/abstractodesystem.jl:1263
[5] (ModelingToolkit.InitializationProblem{true})(::ODESystem, ::Int64, ::Vararg{Any})
@ ModelingToolkit ~/.julia/packages/ModelingToolkit/iQ7So/src/systems/diffeqs/abstractodesystem.jl:1262
[6] ModelingToolkit.InitializationProblem(::ODESystem, ::Int64, ::Vararg{Any}; kwargs::@Kwargs{})
@ ModelingToolkit ~/.julia/packages/ModelingToolkit/iQ7So/src/systems/diffeqs/abstractodesystem.jl:1251
[7] ModelingToolkit.InitializationProblem(::ODESystem, ::Int64, ::Vararg{Any})
@ ModelingToolkit ~/.julia/packages/ModelingToolkit/iQ7So/src/systems/diffeqs/abstractodesystem.jl:1250
[8] top-level scope
@ ~/bug.jl:194
Some type information was truncated. Use `show(err)` to see complete types.
Environment (please complete the following information):
Describe the bug 🐞
I noticed that with MTK@9.60 I can get an initialization failure if I
deepcopy
a particular system. I cannot reproduce it anymore with the current master, but I don't know if this issue was solve or it just no longer manifests.Expected behavior
I would not expect to see any differences in behavior due to
deepcopy
.Minimal Reproducible Example 👇
Error & Stacktrace⚠️
Environment (please complete the following information):
using Pkg; Pkg.status()
using Pkg; Pkg.status(; mode = PKGMODE_MANIFEST)
versioninfo()
julia> versioninfo() Julia Version 1.11.2 Commit 5e9a32e7af2 (2024-12-01 20:02 UTC) Build Info: Official https://julialang.org/ release Platform Info: OS: Linux (x86_64-linux-gnu) CPU: 32 × Intel(R) Core(TM) i9-14900K WORD_SIZE: 64 LLVM: libLLVM-16.0.6 (ORCJIT, alderlake) Threads: 32 default, 0 interactive, 16 GC (on 32 virtual cores) Environment: JULIA_EDITOR = code
The text was updated successfully, but these errors were encountered: