Skip to content

Commit ca7b9c1

Browse files
fix: handle cyclic u0map in some cases
1 parent 62b8c3c commit ca7b9c1

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
@@ -811,11 +815,11 @@ function process_SciMLProblem(
811815
else
812816
obs, _ = unhack_observed(observed(sys), Equation[x for x in eqs if x isa Equation])
813817
end
814-
is_time_dependent(sys) || add_observed_equations!(u0map, obs)
815818

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

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

840-
is_time_dependent(sys) && add_observed_equations!(op, obs)
844+
add_observed_equations!(op, obs)
841845
add_parameter_dependencies!(sys, op)
842846

843847
if warn_cyclic_dependency

0 commit comments

Comments
 (0)