Skip to content

Commit 7b4bf76

Browse files
fix: handle cyclic u0map in some cases
1 parent 9ad30b0 commit 7b4bf76

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

src/systems/problem_utils.jl

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -623,10 +623,14 @@ function build_operating_point!(sys::AbstractSystem,
623623
end
624624

625625
for k in keys(u0map)
626-
u0map[k] = fixpoint_sub(u0map[k], neithermap)
626+
v = fixpoint_sub(u0map[k], neithermap)
627+
isequal(k, v) && continue
628+
u0map[k] = v
627629
end
628630
for k in keys(pmap)
629-
pmap[k] = fixpoint_sub(pmap[k], neithermap)
631+
v = fixpoint_sub(pmap[k], neithermap)
632+
isequal(k, v) && continue
633+
pmap[k] = v
630634
end
631635

632636
return op, missing_unknowns, missing_pars
@@ -812,11 +816,11 @@ function process_SciMLProblem(
812816
else
813817
obs, _ = unhack_observed(observed(sys), Equation[x for x in eqs if x isa Equation])
814818
end
815-
is_time_dependent(sys) || add_observed_equations!(u0map, obs)
816819

817820
op, missing_unknowns, missing_pars = build_operating_point!(sys,
818821
u0map, pmap, defs, cmap, dvs, ps)
819822

823+
add_observed_equations!(u0map, obs)
820824
if u0_constructor === identity && u0Type <: StaticArray
821825
u0_constructor = vals -> SymbolicUtils.Code.create_array(
822826
u0Type, eltype(vals), Val(1), Val(length(vals)), vals...)
@@ -838,7 +842,7 @@ function process_SciMLProblem(
838842
op[iv] = t
839843
end
840844

841-
is_time_dependent(sys) && add_observed_equations!(op, obs)
845+
add_observed_equations!(op, obs)
842846
add_parameter_dependencies!(sys, op)
843847

844848
if warn_cyclic_dependency

0 commit comments

Comments
 (0)