I’m finding another issue when I place a second resistor in series with r1. The updated script is below:
using ModelingToolkit, OrdinaryDiffEq, Plots
using ModelingToolkitStandardLibrary.Electrical
using ModelingToolkitStandardLibrary.Blocks: Constant
using ModelingToolkit: t_nounits as t
@mtkmodel simple_resistor begin
@parameters begin
V = 800.0
R1 = 4.0*499.0e3
R2 = 4.0*499.0e3
end
@components begin
r1 = Resistor(R = R1)
r2 = Resistor(R = R2)
source = Voltage()
constant = Constant(k = V)
ground = Ground()
end
@equations begin
connect(constant.output, source.V)
connect(source.p, r1.p)
connect(r1.n, r2.p)
connect(source.n, r2.n, ground.g)
end
end
@mtkbuild sys = simple_resistor()
prob=ODEProblem(sys, [], (0, 10.0))
sol = solve(prob)
The “prob=ODEProblem(sys, , (0, 10.0))” fails with:
┌ Warning: Did not converge after `maxiters = 0` substitutions. Either there is a cycle in the rules or `maxiters` needs to be higher.
└ @ Symbolics /home/ricardo/.julia/packages/Symbolics/6CYZh/src/variable.jl:528
{
"name": "ArgumentError",
"message": "ArgumentError: SymbolicUtils.BasicSymbolic{Real}[1.996e6r1₊i(t)] are either missing from the variable map or missing from the system's unknowns/parameters list.",
"stack": "ArgumentError: SymbolicUtils.BasicSymbolic{Real}[1.996e6r1₊i(t)] are either missing from the variable map or missing from the system's unknowns/parameters list.
Stacktrace:
[1] throw_missingvars_in_sys(vars::Vector{SymbolicUtils.BasicSymbolic{Real}})
@ ModelingToolkit ~/.julia/packages/ModelingToolkit/eiNg3/src/utils.jl:771
[2] promote_to_concrete(vs::Vector{SymbolicUtils.BasicSymbolic{Real}}; tofloat::Bool, use_union::Bool)
@ ModelingToolkit ~/.julia/packages/ModelingToolkit/eiNg3/src/utils.jl:790
[3] better_varmap_to_vars(varmap::Dict{Any, Any}, vars::Vector{SymbolicUtils.BasicSymbolic{Real}}; tofloat::Bool, use_union::Bool, container_type::Type, toterm::Function, promotetoconcrete::Nothing, check::Bool, allow_symbolic::Bool)
@ ModelingToolkit ~/.julia/packages/ModelingToolkit/eiNg3/src/systems/problem_utils.jl:288
[4] process_SciMLProblem(constructor::Type, sys::NonlinearSystem, u0map::Dict{SymbolicUtils.BasicSymbolic{Real}, Float64}, pmap::Dict{SymbolicUtils.BasicSymbolic{Real}, Int64}; build_initializeprob::Bool, implicit_dae::Bool, t::Nothing, guesses::Dict{Any, Any}, warn_initialize_determined::Bool, initialization_eqs::Vector{Any}, 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, kwargs::@Kwargs{})
@ ModelingToolkit ~/.julia/packages/ModelingToolkit/eiNg3/src/systems/problem_utils.jl:508
[5] process_SciMLProblem
@ ~/.julia/packages/ModelingToolkit/eiNg3/src/systems/problem_utils.jl:413 [inlined]
[6] (NonlinearProblem{true})(sys::NonlinearSystem, u0map::Dict{SymbolicUtils.BasicSymbolic{Real}, Float64}, parammap::Dict{SymbolicUtils.BasicSymbolic{Real}, Int64}; check_length::Bool, kwargs::@Kwargs{eval_expression::Bool, eval_module::Module})
@ ModelingToolkit ~/.julia/packages/ModelingToolkit/eiNg3/src/systems/nonlinear/nonlinearsystem.jl:499
[7] NonlinearProblem(::NonlinearSystem, ::Dict{SymbolicUtils.BasicSymbolic{Real}, Float64}, ::Vararg{Any}; kwargs::@Kwargs{eval_expression::Bool, eval_module::Module})
@ ModelingToolkit ~/.julia/packages/ModelingToolkit/eiNg3/src/systems/nonlinear/nonlinearsystem.jl:490
[8] ModelingToolkit.InitializationProblem{true, SciMLBase.AutoSpecialize}(sys::ODESystem, t::Int64, u0map::Dict{Any, Any}, parammap::Dict{Any, Any}; guesses::Dict{Any, Any}, check_length::Bool, warn_initialize_determined::Bool, initialization_eqs::Vector{Any}, fully_determined::Bool, check_units::Bool, kwargs::@Kwargs{eval_expression::Bool, eval_module::Module})
@ ModelingToolkit ~/.julia/packages/ModelingToolkit/eiNg3/src/systems/diffeqs/abstractodesystem.jl:1330
[9] (ModelingToolkit.InitializationProblem{true})(::ODESystem, ::Int64, ::Vararg{Any}; kwargs::@Kwargs{guesses::Dict{Any, Any}, warn_initialize_determined::Bool, initialization_eqs::Vector{Any}, eval_expression::Bool, eval_module::Module, fully_determined::Bool, check_units::Bool})
@ ModelingToolkit ~/.julia/packages/ModelingToolkit/eiNg3/src/systems/diffeqs/abstractodesystem.jl:1232
[10] ModelingToolkit.InitializationProblem(::ODESystem, ::Int64, ::Vararg{Any}; kwargs::@Kwargs{guesses::Dict{Any, Any}, warn_initialize_determined::Bool, initialization_eqs::Vector{Any}, eval_expression::Bool, eval_module::Module, fully_determined::Bool, check_units::Bool})
@ ModelingToolkit ~/.julia/packages/ModelingToolkit/eiNg3/src/systems/diffeqs/abstractodesystem.jl:1220
[11] process_SciMLProblem(constructor::Type, sys::ODESystem, u0map::Vector{Any}, pmap::SciMLBase.NullParameters; build_initializeprob::Bool, implicit_dae::Bool, t::Int64, guesses::Dict{Any, Any}, warn_initialize_determined::Bool, initialization_eqs::Vector{Any}, 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, kwargs::@Kwargs{})
@ ModelingToolkit ~/.julia/packages/ModelingToolkit/eiNg3/src/systems/problem_utils.jl:466
[12] process_SciMLProblem
@ ~/.julia/packages/ModelingToolkit/eiNg3/src/systems/problem_utils.jl:413 [inlined]
[13] (ODEProblem{true, SciMLBase.AutoSpecialize})(sys::ODESystem, u0map::Vector{Any}, tspan::Tuple{Int64, Float64}, parammap::SciMLBase.NullParameters; callback::Nothing, check_length::Bool, warn_initialize_determined::Bool, eval_expression::Bool, eval_module::Module, kwargs::@Kwargs{})
@ ModelingToolkit ~/.julia/packages/ModelingToolkit/eiNg3/src/systems/diffeqs/abstractodesystem.jl:811
[14] ODEProblem
@ ~/.julia/packages/ModelingToolkit/eiNg3/src/systems/diffeqs/abstractodesystem.jl:799 [inlined]
[15] (ODEProblem{true, SciMLBase.AutoSpecialize})(sys::ODESystem, u0map::Vector{Any}, tspan::Tuple{Int64, Float64})
@ ModelingToolkit ~/.julia/packages/ModelingToolkit/eiNg3/src/systems/diffeqs/abstractodesystem.jl:799
[16] (ODEProblem{true})(::ODESystem, ::Vector{Any}, ::Vararg{Any}; kwargs::@Kwargs{})
@ ModelingToolkit ~/.julia/packages/ModelingToolkit/eiNg3/src/systems/diffeqs/abstractodesystem.jl:786
[17] (ODEProblem{true})(::ODESystem, ::Vector{Any}, ::Vararg{Any})
@ ModelingToolkit ~/.julia/packages/ModelingToolkit/eiNg3/src/systems/diffeqs/abstractodesystem.jl:785
[18] ODEProblem(::ODESystem, ::Vector{Any}, ::Vararg{Any}; kwargs::@Kwargs{})
@ ModelingToolkit ~/.julia/packages/ModelingToolkit/eiNg3/src/systems/diffeqs/abstractodesystem.jl:775
[19] ODEProblem(::ODESystem, ::Vector{Any}, ::Vararg{Any})
@ ModelingToolkit ~/.julia/packages/ModelingToolkit/eiNg3/src/systems/diffeqs/abstractodesystem.jl:774
[20] top-level scope
@ ~/jupyter/isolation_sensing/jl_notebook_cell_df34fa98e69747e1a8f8a730347b8e2f_W3sZmlsZQ==.jl:1"
}