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
+8-13Lines changed: 8 additions & 13 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -16,22 +16,20 @@ of `decay2` is the value of the unknown variable `x`.
16
16
17
17
```@example composition
18
18
using ModelingToolkit
19
+
using ModelingToolkit: t_nounits as t, D_nounits as D
19
20
20
21
function decay(; name)
21
-
@parameters t a
22
+
@parameters a
22
23
@variables x(t) f(t)
23
-
D = Differential(t)
24
24
ODESystem([
25
25
D(x) ~ -a * x + f
26
-
];
26
+
], t;
27
27
name = name)
28
28
end
29
29
30
30
@named decay1 = decay()
31
31
@named decay2 = decay()
32
32
33
-
@parameters t
34
-
D = Differential(t)
35
33
connected = compose(
36
34
ODESystem([decay2.f ~ decay1.x
37
35
D(decay1.f) ~ 0], t; name = :connected), decay1, decay2)
@@ -137,7 +135,7 @@ sys.y = u * 1.1
137
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.
138
136
139
137
```julia
140
-
@parameterst a b c d e f
138
+
@parameters a b c d e f
141
139
142
140
# a is a local variable
143
141
b =ParentScope(b) # b is a variable that belongs to one level up in the hierarchy
@@ -197,19 +195,16 @@ higher level system:
197
195
198
196
```@example compose
199
197
using ModelingToolkit, OrdinaryDiffEq, Plots
198
+
using ModelingToolkit: t_nounits as t, D_nounits as D
200
199
201
200
## Library code
202
-
203
-
@parameters t
204
-
D = Differential(t)
205
-
206
201
@variables S(t), I(t), R(t)
207
202
N = S + I + R
208
203
@parameters β, γ
209
204
210
-
@named seqn = ODESystem([D(S) ~ -β * S * I / N])
211
-
@named ieqn = ODESystem([D(I) ~ β * S * I / N - γ * I])
212
-
@named reqn = ODESystem([D(R) ~ γ * I])
205
+
@named seqn = ODESystem([D(S) ~ -β * S * I / N], t)
206
+
@named ieqn = ODESystem([D(I) ~ β * S * I / N - γ * I], t)
Copy file name to clipboardExpand all lines: docs/src/basics/FAQ.md
+5-4Lines changed: 5 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -102,9 +102,10 @@ end
102
102
This error can come up after running `structural_simplify` on a system that generates dummy derivatives (i.e. variables with `ˍt`). For example, here even though all the variables are defined with initial values, the `ODEProblem` generation will throw an error that defaults are missing from the variable map.
103
103
104
104
```
105
-
@variables t
105
+
using ModelingToolkit
106
+
using ModelingToolkit: t_nounits as t, D_nounits as D
0 commit comments