Skip to content

Commit e1a36a0

Browse files
committed
Topsort observed equations
1 parent 397b20d commit e1a36a0

File tree

3 files changed

+16
-4
lines changed

3 files changed

+16
-4
lines changed

docs/src/tutorials/acausal_components.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -406,10 +406,15 @@ observed(sys)
406406
capacitor₊n₊v(t) ~ 0.0
407407
source₊n₊v(t) ~ 0.0
408408
ground₊g₊i(t) ~ 0.0
409-
409+
source₊n₊i(t) ~ capacitor₊p₊i(t)
410+
source₊p₊i(t) ~ -capacitor₊p₊i(t)
411+
capacitor₊n₊i(t) ~ -capacitor₊p₊i(t)
412+
resistor₊n₊i(t) ~ -capacitor₊p₊i(t)
410413
ground₊g₊v(t) ~ 0.0
411414
source₊p₊v(t) ~ source₊V
412415
capacitor₊p₊v(t) ~ capacitor₊v(t)
416+
resistor₊p₊v(t) ~ source₊p₊v(t)
417+
resistor₊n₊v(t) ~ capacitor₊p₊v(t)
413418
resistor₊v(t) ~ -((capacitor₊p₊v(t)) - (source₊p₊v(t)))
414419
```
415420

src/systems/abstractsystem.jl

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -467,6 +467,13 @@ end
467467
"""
468468
$(SIGNATURES)
469469
470-
Structurally simplify algebraic equations in a system.
470+
Structurally simplify algebraic equations in a system and compute the
471+
topological sort of the observed equations.
471472
"""
472-
structural_simplify(sys::AbstractSystem) = tearing(alias_elimination(sys))
473+
function structural_simplify(sys::AbstractSystem)
474+
ss = states(sys)
475+
sys = tearing(alias_elimination(sys))
476+
s = structure(sys)
477+
@set! sys.observed = topsort_equations(observed(sys), ss)
478+
return sys
479+
end

src/systems/diffeqs/odesystem.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,7 @@ ODESystem(eq::Equation, args...; kwargs...) = ODESystem([eq], args...; kwargs...
235235
$(SIGNATURES)
236236
237237
Build the observed function assuming the observed equations are all explicit,
238-
i.e. there are no cycles or dependencies.
238+
i.e. there are no cycles.
239239
"""
240240
function build_explicit_observed_function(
241241
sys, syms;

0 commit comments

Comments
 (0)