# ModelingToolkit: How to interpret "ERROR: Cyclic guesses detected in the system" during initialization?

**URL:** https://discourse.julialang.org/t/modelingtoolkit-how-to-interpret-error-cyclic-guesses-detected-in-the-system-during-initialization/134146
**Category:** Modelling & Simulations
**Created:** [November 26, 2025, 5:48pm UTC](https://discourse.julialang.org/t/modelingtoolkit-how-to-interpret-error-cyclic-guesses-detected-in-the-system-during-initialization/134146 "2025-11-26T17:48:13Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![NicholasHemenway](https://avatars.discourse-cdn.com/v4/letter/n/e99b99/32.png) [@NicholasHemenway](https://discourse.julialang.org/u/NicholasHemenway)
#### Post date: [November 26, 2025, 5:48pm UTC](https://discourse.julialang.org/t/modelingtoolkit-how-to-interpret-error-cyclic-guesses-detected-in-the-system-during-initialization/134146/1 "2025-11-26T17:48:14Z")

</div>

I’ve got a simple RC circuit with two series resistors:

```julia-auto
using ModelingToolkit, DifferentialEquations
using ModelingToolkitStandardLibrary.Electrical
using ModelingToolkitStandardLibrary.Blocks

@mtkmodel Circuit begin
    @components begin
        # Battery Model
        v_source = Constant(k=1)
        voltage = Voltage()
        resistor1 = Resistor(R=1)
        resistor2 = Resistor(R=1)
        capacitor = Capacitor(C=1)
        ground = Ground()
    end
    @equations begin
        # Input to voltage source
        connect(v_source.output, voltage.V)
        # Circuit connections
        connect(voltage.p, resistor1.p)
        connect(resistor1.n, resistor2.p)
        connect(resistor2.n, capacitor.p)
        connect(capacitor.n, ground.g, voltage.n)
    end
end

@mtkcompile sys = Circuit()

```

I can initialize the system by specifying the initial capacitor current as follows:

```julia-auto
prob = ODEProblem(sys, [sys.capacitor.i=>0], (0,5))

```

But if I try to initialize the system by specifying the capacitor voltage instead,

```julia-auto
prob = ODEProblem(sys, [sys.capacitor.v=>0], (0,5))

```

I get an `ERROR; Cyclic guesses detected in the system...` with the following full traceback

```julia-auto
┌ Warning: Did not converge after `maxiters = 100` substitutions. Either there is a cycle in the rules or `maxiters` needs to be higher.
└ @ Symbolics C:\Users\nhemenway\.julia\packages\Symbolics\xD5Pj\src\variable.jl:646
ERROR: Cyclic guesses detected in the system. Symbolic values were found for the following variables/parameters in the map: 
resistor1₊v(t) => -capacitor₊i(t)
In order to resolve this, please provide additional numeric guesses so that the chain can be resolved to assign numeric values to each variable.

Stacktrace:
  [1] varmap_to_vars(varmap::Dict{…}, vars::Vector{…}; tofloat::Bool, use_union::Bool, container_type::Type, buffer_eltype::Type, toterm::Function, check::Bool, allow_symbolic::Bool, is_initializeprob::Bool, substitution_limit::Int64)
    @ ModelingToolkit C:\Users\nhemenway\.julia\packages\ModelingToolkit\KTR1R\src\systems\problem_utils.jl:408
  [2] process_SciMLProblem(constructor::Type, sys::System, op::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::Nothing, check_initialization_units::Bool, u0_eltype::Nothing, tofloat::Bool, u0_constructor::typeof(identity), p_constructor::typeof(identity), check_length::Bool, symbolic_u0::Bool, warn_cyclic_dependency::Bool, circular_dependency_max_cycle_length::Int64, circular_dependency_max_cycles::Int64, substitution_limit::Int64, use_scc::Bool, time_dependent_init::Bool, algebraic_only::Bool, allow_incomplete::Bool, is_initializeprob::Bool, kwargs::@Kwargs{…})
    @ ModelingToolkit C:\Users\nhemenway\.julia\packages\ModelingToolkit\KTR1R\src\systems\problem_utils.jl:1443
  [3] (NonlinearProblem{…})(sys::System, op::Dict{…}; expression::Type, check_length::Bool, check_compatibility::Bool, kwargs::@Kwargs{…})
    @ ModelingToolkit C:\Users\nhemenway\.julia\packages\ModelingToolkit\KTR1R\src\problems\nonlinearproblem.jl:66
  [4] NonlinearProblem
    @ C:\Users\nhemenway\.julia\packages\ModelingToolkit\KTR1R\src\problems\nonlinearproblem.jl:57 [inlined]
  [5] NonlinearProblem
    @ .\none:-1 [inlined]
  [6] (SCCNonlinearProblem{…} where iip)(sys::System, op::Dict{…}; eval_expression::Bool, eval_module::Module, cse::Bool, u0_constructor::Function, kwargs::@Kwargs{…})
    @ ModelingToolkit C:\Users\nhemenway\.julia\packages\ModelingToolkit\KTR1R\src\problems\sccnonlinearproblem.jl:110
  [7] InitializationProblem{…}(sys::System, t::Int64, op::Dict{…}; guesses::Dict{…}, check_length::Bool, warn_initialize_determined::Bool, initialization_eqs::Vector{…}, fully_determined::Nothing, check_units::Bool, use_scc::Bool, allow_incomplete::Bool, algebraic_only::Bool, time_dependent_init::Bool, kwargs::@Kwargs{…})
    @ ModelingToolkit C:\Users\nhemenway\.julia\packages\ModelingToolkit\KTR1R\src\problems\initializationproblem.jl:138
  [8] InitializationProblem
    @ C:\Users\nhemenway\.julia\packages\ModelingToolkit\KTR1R\src\problems\initializationproblem.jl:20 [inlined]
  [9] #_#1180
    @ .\none:-1 [inlined]
 [10] maybe_build_initialization_problem(sys::System, iip::Bool, op::Dict{…}, t::Int64, defs::Dict{…}, guesses::Dict{…}, missing_unknowns::Set{…}; implicit_dae::Bool, time_dependent_init::Bool, u0_constructor::Function, p_constructor::Function, floatT::Type, initialization_eqs::Vector{…}, use_scc::Bool, eval_expression::Bool, eval_module::Module, kwargs::@Kwargs{…})
    @ ModelingToolkit C:\Users\nhemenway\.julia\packages\ModelingToolkit\KTR1R\src\systems\problem_utils.jl:1135
 [11] process_SciMLProblem(constructor::Type, sys::System, op::Vector{…}; build_initializeprob::Bool, implicit_dae::Bool, t::Int64, guesses::Dict{…}, warn_initialize_determined::Bool, initialization_eqs::Vector{…}, eval_expression::Bool, eval_module::Module, fully_determined::Nothing, check_initialization_units::Bool, u0_eltype::Nothing, tofloat::Bool, u0_constructor::typeof(identity), p_constructor::typeof(identity), check_length::Bool, symbolic_u0::Bool, warn_cyclic_dependency::Bool, circular_dependency_max_cycle_length::Int64, circular_dependency_max_cycles::Int64, substitution_limit::Int64, use_scc::Bool, time_dependent_init::Bool, algebraic_only::Bool, allow_incomplete::Bool, is_initializeprob::Bool, kwargs::@Kwargs{…})
    @ ModelingToolkit C:\Users\nhemenway\.julia\packages\ModelingToolkit\KTR1R\src\systems\problem_utils.jl:1409
 [12] (ODEProblem{…})(sys::System, op::Vector{…}, tspan::Tuple{…}; callback::Nothing, check_length::Bool, eval_expression::Bool, expression::Type, eval_module::Module, check_compatibility::Bool, kwargs::@Kwargs{})
    @ ModelingToolkit C:\Users\nhemenway\.julia\packages\ModelingToolkit\KTR1R\src\problems\odeproblem.jl:81
 [13] ODEProblem
    @ C:\Users\nhemenway\.julia\packages\ModelingToolkit\KTR1R\src\problems\odeproblem.jl:73 [inlined]
 [14] ODEProblem
    @ .\none:-1 [inlined]
 [15] ODEProblem(sys::System, op::Vector{Pair{Num, Int64}}, tspan::Tuple{Int64, Int64})
    @ ModelingToolkit .\none:-1
 [16] top-level scope
    @ c:\Users\nhemenway\OneDrive - Brunswick Corporation\Documents\01_Projects\Snapper\TRs\TR2024-0506-005_snapper_battery_cable_sizing\julia\example.jl:27
Some type information was truncated. Use `show(err)` to see complete types.

```

I’ve read the documentation on [initialization](https://docs.sciml.ai/ModelingToolkit/dev/tutorials/initialization/) and believe I’m doing everything correct. I’m confused by why it’s failing, and more importantly, how to interpret the error message to be able to debug this in the future.

---

<div class="post-metadata">

### Author: ![NicholasHemenway](https://avatars.discourse-cdn.com/v4/letter/n/e99b99/32.png) [@NicholasHemenway](https://discourse.julialang.org/u/NicholasHemenway)
#### Post date: [November 26, 2025, 6:14pm UTC](https://discourse.julialang.org/t/modelingtoolkit-how-to-interpret-error-cyclic-guesses-detected-in-the-system-during-initialization/134146/2 "2025-11-26T18:14:54Z")

</div>

After playing with it a bit more, the system will initialize if I provide a guess for the capacitor current as:

```julia-auto
prob = ODEProblem(sys, [sys.capacitor.v=>0], (0,5), guesses=[sys.capacitor.i=>0])

```

But then if I specify the resistor current in `resistor1` (which is the same as the capacitor current), I get the same “Cyclic guesses” error.

```julia-auto
prob = ODEProblem(sys, [sys.capacitor.v=>0], (0,5), guesses=[sys.resistor1.i=>0])

```

However, supplying a guess for the current in `resistor2` works fine:

```julia-auto
prob = ODEProblem(sys, [sys.capacitor.v=>0], (0,5), guesses=[sys.resistor2.i=>0])

```

I’m puzzled.

---

<div class="post-metadata">

### Author: ![ChrisRackauckas](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/chrisrackauckas/32/77_2.png) [@ChrisRackauckas](https://discourse.julialang.org/u/ChrisRackauckas)
#### Post date: [November 26, 2025, 10:52pm UTC](https://discourse.julialang.org/t/modelingtoolkit-how-to-interpret-error-cyclic-guesses-detected-in-the-system-during-initialization/134146/3 "2025-11-26T22:52:07Z")

</div>

That might be a bug in the cycle detection? Open an issue and we can dig in further.
