32
32
33
33
@parameters t
34
34
D = Differential (t)
35
- @named connected = ODESystem ([
35
+ @named connected = compose ( ODESystem ([
36
36
decay2. f ~ decay1. x
37
37
D (decay1. f) ~ 0
38
- ], t, systems = [ decay1, decay2] )
38
+ ], t), decay1, decay2)
39
39
40
40
equations (connected)
41
41
@@ -81,7 +81,7 @@ subsystems. A model is the composition of itself and its subsystems.
81
81
For example, if we have:
82
82
83
83
``` julia
84
- @named sys = ODESystem (eqs,indepvar,states,ps,system = [ subsys] )
84
+ @named sys = compose ( ODESystem (eqs,indepvar,states,ps), subsys)
85
85
```
86
86
87
87
the ` equations ` of ` sys ` is the concatenation of ` get_eqs(sys) ` and
@@ -191,7 +191,7 @@ N = S + I + R
191
191
@named ieqn = ODESystem ([D (I) ~ β* S* I/ N- γ* I])
192
192
@named reqn = ODESystem ([D (R) ~ γ* I])
193
193
194
- @named sir = ODESystem ([
194
+ @named sir = compose ( ODESystem ([
195
195
S ~ ieqn. S,
196
196
I ~ seqn. I,
197
197
R ~ ieqn. R,
@@ -200,13 +200,12 @@ N = S + I + R
200
200
seqn. R ~ reqn. R,
201
201
ieqn. R ~ reqn. R,
202
202
reqn. I ~ ieqn. I], t, [S,I,R], [β,γ],
203
- systems= [seqn,ieqn,reqn],
204
- default_p = [
203
+ defaults = [
205
204
seqn. β => β
206
205
ieqn. β => β
207
206
ieqn. γ => γ
208
207
reqn. γ => γ
209
- ])
208
+ ]), seqn, ieqn, reqn)
210
209
```
211
210
212
211
Note that the states are forwarded by an equality relationship, while
@@ -241,14 +240,6 @@ sol = solve(prob,Tsit5())
241
240
sol[reqn. R]
242
241
```
243
242
244
- However, one can similarly simplify this process of inheritance by
245
- using ` combine ` which concatenates all of the vectors within the
246
- systems. For example, we could equivalently have done:
247
-
248
- ``` julia
249
- @named sir = combine ([seqn,ieqn,reqn])
250
- ```
251
-
252
243
## Tearing Problem Construction
253
244
254
245
Some system types, specifically ` ODESystem ` and ` NonlinearSystem ` , can be further
@@ -259,12 +250,3 @@ strongly connected components calculated during the process of simplification
259
250
as the basis for building pre-simplified nonlinear systems in the implicit
260
251
solving. In summary: these problems are structurally modified, but could be
261
252
more efficient and more stable.
262
-
263
- ## Automatic Model Promotion (TODO)
264
-
265
- In many cases one might want to compose models of different types. For example,
266
- one may want to include a ` NonlinearSystem ` as a set of algebraic equations
267
- within an ` ODESystem ` , or one may want to use an ` ODESystem ` as a subsystem of
268
- an ` SDESystem ` . In these cases, the compostion works automatically by promoting
269
- the model via ` promote_system ` . System promotions exist in the cases where a
270
- mathematically-trivial definition of the promotion exists.
0 commit comments