Skip to content

Commit fa2eda4

Browse files
committed
Update docs
1 parent 237d4a3 commit fa2eda4

File tree

6 files changed

+21
-13
lines changed

6 files changed

+21
-13
lines changed

docs/src/highlevel.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ methods.
1010
```@docs
1111
@parameters
1212
@variables
13-
@derivatives
13+
Differential
1414
Base.:~(::Num, ::Num)
1515
modelingtoolkitize
1616
```

docs/src/tutorials/higher_order.md

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ using ModelingToolkit, OrdinaryDiffEq
1515

1616
@parameters t σ ρ β
1717
@variables x(t) y(t) z(t)
18-
@derivatives D'~t
18+
D = Differential(t)
1919

2020
eqs = [D(D(x)) ~ σ*(y-x),
2121
D(y) ~ x*-z)-y,
@@ -25,10 +25,11 @@ sys = ODESystem(eqs)
2525
```
2626

2727
Note that we could've used an alternative syntax for 2nd order, i.e.
28-
`@derivatives E''~t` and then `E(x)` would be the second derivative,
29-
and this syntax extends to Nth order.
28+
`D = Differential(t)^2` and then `E(x)` would be the second derivative,
29+
and this syntax extends to `N`-th order. Also, we can use `*` or `` to compose
30+
`Differential`s, like `Differential(t) * Differential(x)`.
3031

31-
Now let's transform this into the ODESystem of first order components.
32+
Now let's transform this into the `ODESystem` of first order components.
3233
We do this by simply calling `ode_order_lowering`:
3334

3435
```julia

docs/src/tutorials/ode_modeling.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ using ModelingToolkit, OrdinaryDiffEq
99

1010
@parameters t σ ρ β
1111
@variables x(t) y(t) z(t)
12-
@derivatives D'~t
12+
D = Differential(t)
1313

1414
eqs = [D(x) ~ σ*(y-x),
1515
D(y) ~ x*-z)-y,
@@ -58,7 +58,7 @@ using ModelingToolkit
5858

5959
@parameters t σ ρ β
6060
@variables x(t) y(t) z(t)
61-
@derivatives D'~t
61+
D = Differential(t)
6262
```
6363

6464
Then we build the system:

docs/src/tutorials/symbolic_functions.md

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -282,11 +282,11 @@ sufficiently large!)
282282
One common thing to compute in a symbolic system is derivatives. In
283283
ModelingToolkit.jl, derivatives are represented lazily via operations,
284284
just like any other function. To build a differential operator, use
285-
`@derivatives` like:
285+
`Differential` like:
286286

287287
```julia
288288
@variables t
289-
@derivatives D'~t
289+
Differential(t)
290290
```
291291

292292
This is the differential operator ``D = \frac{\partial}{\partial t}``: the number of
@@ -450,7 +450,7 @@ z = g(x) + g(y)
450450

451451
One of the benefits of a one-language Julia symbolic stack is that the
452452
primitives are all written in Julia, and therefore it's trivially
453-
extendable from Julia itself. By default, new functions are traced
453+
extendible from Julia itself. By default, new functions are traced
454454
to the primitives and the symbolic expressions are written on the
455455
primitives. However, we can expand the allowed primitives by registering
456456
new functions. For example, let's register a new function `h`:
@@ -479,7 +479,8 @@ ModelingToolkit.derivative(::typeof(h), args::NTuple{2,Any}, ::Val{2}) = 1
479479
and now it works with the rest of the system:
480480

481481
```julia
482-
@derivatives Dx'~x Dy'~y
482+
Dx = Differential(x)
483+
Dy = Differential(y)
483484
expand_derivatives(Dx(h(x,y) + y^2)) # 2x
484485
expand_derivatives(Dy(h(x,y) + y^2)) # 1 + 2y
485486
```

src/differentials.jl

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,14 @@ julia> @variables x y;
1818
julia> D = Differential(x)
1919
(D'~x)
2020
21-
julia> D(y) # Differentiate y wrt. x
21+
julia> D(y) # Differentiate y wrt. x
2222
(D'~x)(y)
23+
24+
julia> Dx = Differential(x) * Differential(y) # d^2/dxy operator
25+
(D'~x(t)) ∘ (D'~y(t))
26+
27+
julia> D3 = Differential(x)^3 # 3rd order differential operator
28+
(D'~x(t)) ∘ (D'~x(t)) ∘ (D'~x(t))
2329
```
2430
"""
2531
struct Differential <: Function

src/systems/diffeqs/odesystem.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ using ModelingToolkit
1313
1414
@parameters t σ ρ β
1515
@variables x(t) y(t) z(t)
16-
@derivatives D'~t
16+
D = Differential(t)
1717
1818
eqs = [D(x) ~ σ*(y-x),
1919
D(y) ~ x*(ρ-z)-y,

0 commit comments

Comments
 (0)