You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/src/basics/Composition.md
+6-14Lines changed: 6 additions & 14 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -135,42 +135,34 @@ sys.y = u * 1.1
135
135
In a hierarchical system, variables of the subsystem get namespaced by the name of the system they are in. This prevents naming clashes, but also enforces that every unknown and parameter is local to the subsystem it is used in. In some cases it might be desirable to have variables and parameters that are shared between subsystems, or even global. This can be accomplished as follows.
136
136
137
137
```julia
138
-
@parameters a b c d e f
138
+
@parameters a b c d
139
139
140
140
# a is a local variable
141
141
b =ParentScope(b) # b is a variable that belongs to one level up in the hierarchy
142
142
c =ParentScope(ParentScope(c)) # ParentScope can be nested
143
-
d =DelayParentScope(d) # skips one level before applying ParentScope
144
-
e =DelayParentScope(e, 2) # second argument allows skipping N levels
145
-
f =GlobalScope(f)
143
+
d =GlobalScope(d)
146
144
147
-
p = [a, b, c, d, e, f]
145
+
p = [a, b, c, d]
148
146
149
147
level0 =ODESystem(Equation[], t, [], p; name =:level0)
150
148
level1 =ODESystem(Equation[], t, [], []; name =:level1) ∘ level0
151
149
parameters(level1)
152
150
#level0₊a
153
151
#b
154
152
#c
155
-
#level0₊d
156
-
#level0₊e
157
-
#f
153
+
#d
158
154
level2 =ODESystem(Equation[], t, [], []; name =:level2) ∘ level1
159
155
parameters(level2)
160
156
#level1₊level0₊a
161
157
#level1₊b
162
158
#c
163
-
#level0₊d
164
-
#level1₊level0₊e
165
-
#f
159
+
#d
166
160
level3 =ODESystem(Equation[], t, [], []; name =:level3) ∘ level2
0 commit comments