-
-
Notifications
You must be signed in to change notification settings - Fork 231
Closed
Description
If I use the RC example from MTK:
rc_model = let
@named resistor = Resistor(R=1)
@named capacitor = Capacitor(C=1)
@named source = ConstantVoltage(V=1)
@named ground = Ground()
rc_eqs = [
connect(source.p, resistor.p)
connect(resistor.n, capacitor.p)
connect(capacitor.n, source.n)
connect(capacitor.n, ground.g)
]
@named rc_model = ODESystem(rc_eqs, t)
compose(rc_model, [resistor, capacitor, source, ground])
end
I can access the subsystems directly:
julia> propertynames(rc_model)
18-element Vector{Symbol}:
:resistor
:capacitor
:source
:ground
:source₊p₊i
:resistor₊p₊i
:source₊p₊v
:resistor₊p₊v
:capacitor₊p₊i
:resistor₊n₊i
:resistor₊n₊v
:capacitor₊p₊v
:capacitor₊n₊i
:source₊n₊i
:capacitor₊n₊v
:source₊n₊v
:ground₊g₊i
:ground₊g₊v
However, if I apply rc_model_simp = structural_simplify(rc_model)
I can no longer access the subsystems (:resistor, :capacitor, :source, :ground
):
julia> propertynames(rc_model_simp)
23-element Vector{Symbol}:
:capacitor₊v
:resistor₊i
:resistor₊R
:capacitor₊C
:source₊V
:capacitor₊i
:source₊i
:source₊p₊i
:source₊n₊i
:capacitor₊p₊v
:ground₊g₊i
:capacitor₊n₊i
:resistor₊n₊v
:source₊n₊v
:capacitor₊n₊v
:ground₊g₊v
:source₊v
:resistor₊n₊i
:resistor₊v
:resistor₊p₊v
:resistor₊p₊i
:capacitor₊p₊i
:source₊p₊v
So the structure changed I guess.
How can I access a specific variable?
In the documentation this is always done via a direct reference to the subsystems like:
u0 = [
capacitor.v => 0.0
]
or
sol[resistor.v]
However, apart from some test scripts I will not always have those around.
I find e.g. rc_model_simp.capacitor₊v
odd because of the unicode characters.
So what is the indented way of accessing a variable?
Metadata
Metadata
Assignees
Labels
No labels