Skip to content

Commit 45ab32d

Browse files
authored
Merge pull request #1096 from SciML/myb/inh
Namespacing change & default variable syntax
2 parents 5dc53f0 + ca12cb6 commit 45ab32d

24 files changed

+382
-241
lines changed

Project.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ Distributions = "31c24e10-a181-5473-b8eb-7969acd0382f"
1616
DocStringExtensions = "ffbed154-4ef7-542d-bbb7-c09d3a79fcae"
1717
DomainSets = "5b8099bc-c8ec-5219-889f-1d9e522a28bf"
1818
IfElse = "615f187c-cbe4-4ef1-ba3b-2fcf58d6d173"
19+
InteractiveUtils = "b77e0a4c-d291-57a0-90e8-8db25a27a240"
1920
JuliaFormatter = "98e50ef6-434e-11e9-1051-2b60c6c9e899"
2021
LabelledArrays = "2ee39098-c373-598a-b85f-a56591580800"
2122
Latexify = "23fbe1c1-3f47-55db-b15f-69d7ec21a316"

docs/src/basics/Composition.md

Lines changed: 6 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,10 @@ end
3232

3333
@parameters t
3434
D = Differential(t)
35-
@named connected = ODESystem([
35+
@named connected = compose(ODESystem([
3636
decay2.f ~ decay1.x
3737
D(decay1.f) ~ 0
38-
], t, systems=[decay1, decay2])
38+
], t), decay1, decay2)
3939

4040
equations(connected)
4141

@@ -81,7 +81,7 @@ subsystems. A model is the composition of itself and its subsystems.
8181
For example, if we have:
8282

8383
```julia
84-
@named sys = ODESystem(eqs,indepvar,states,ps,system=[subsys])
84+
@named sys = compose(ODESystem(eqs,indepvar,states,ps),subsys)
8585
```
8686

8787
the `equations` of `sys` is the concatenation of `get_eqs(sys)` and
@@ -191,7 +191,7 @@ N = S + I + R
191191
@named ieqn = ODESystem([D(I) ~ β*S*I/N-γ*I])
192192
@named reqn = ODESystem([D(R) ~ γ*I])
193193

194-
@named sir = ODESystem([
194+
@named sir = compose(ODESystem([
195195
S ~ ieqn.S,
196196
I ~ seqn.I,
197197
R ~ ieqn.R,
@@ -200,13 +200,12 @@ N = S + I + R
200200
seqn.R ~ reqn.R,
201201
ieqn.R ~ reqn.R,
202202
reqn.I ~ ieqn.I], t, [S,I,R], [β,γ],
203-
systems=[seqn,ieqn,reqn],
204-
default_p = [
203+
defaults = [
205204
seqn.β => β
206205
ieqn.β => β
207206
ieqn.γ => γ
208207
reqn.γ => γ
209-
])
208+
]), seqn, ieqn, reqn)
210209
```
211210

212211
Note that the states are forwarded by an equality relationship, while
@@ -241,14 +240,6 @@ sol = solve(prob,Tsit5())
241240
sol[reqn.R]
242241
```
243242

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-
252243
## Tearing Problem Construction
253244

254245
Some system types, specifically `ODESystem` and `NonlinearSystem`, can be further
@@ -259,12 +250,3 @@ strongly connected components calculated during the process of simplification
259250
as the basis for building pre-simplified nonlinear systems in the implicit
260251
solving. In summary: these problems are structurally modified, but could be
261252
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.

docs/src/systems/SDESystem.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ SDESystem
1010

1111
- `get_eqs(sys)` or `equations(sys)`: The equations that define the SDE.
1212
- `get_states(sys)` or `states(sys)`: The set of states in the SDE.
13-
- `get_ps(sys)s` or `parameters(sys)`: The parameters of the SDE.
13+
- `get_ps(sys)` or `parameters(sys)`: The parameters of the SDE.
1414
- `independent_variable(sys)`: The independent variable of the SDE.
1515

1616
## Transformations

0 commit comments

Comments
 (0)