Skip to content

Commit c59e0c2

Browse files
fix: handle cyclic u0map in some cases
1 parent 581aba2 commit c59e0c2

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
@@ -596,10 +596,14 @@ function build_operating_point!(sys::AbstractSystem,
596596
end
597597

598598
for k in keys(u0map)
599-
u0map[k] = fixpoint_sub(u0map[k], neithermap)
599+
v = fixpoint_sub(u0map[k], neithermap)
600+
isequal(k, v) && continue
601+
u0map[k] = v
600602
end
601603
for k in keys(pmap)
602-
pmap[k] = fixpoint_sub(pmap[k], neithermap)
604+
v = fixpoint_sub(pmap[k], neithermap)
605+
isequal(k, v) && continue
606+
pmap[k] = v
603607
end
604608

605609
return op, missing_unknowns, missing_pars
@@ -785,11 +789,11 @@ function process_SciMLProblem(
785789
else
786790
obs, _ = unhack_observed(observed(sys), Equation[x for x in eqs if x isa Equation])
787791
end
788-
is_time_dependent(sys) || add_observed_equations!(u0map, obs)
789792

790793
op, missing_unknowns, missing_pars = build_operating_point!(sys,
791794
u0map, pmap, defs, cmap, dvs, ps)
792795

796+
add_observed_equations!(u0map, obs)
793797
if u0_constructor === identity && u0Type <: StaticArray
794798
u0_constructor = vals -> SymbolicUtils.Code.create_array(
795799
u0Type, eltype(vals), Val(1), Val(length(vals)), vals...)
@@ -811,7 +815,7 @@ function process_SciMLProblem(
811815
op[iv] = t
812816
end
813817

814-
is_time_dependent(sys) && add_observed_equations!(op, obs)
818+
add_observed_equations!(op, obs)
815819
add_parameter_dependencies!(sys, op)
816820

817821
if warn_cyclic_dependency

0 commit comments

Comments
 (0)