Skip to content

Commit 13badcc

Browse files
docs: fix various example block errors
1 parent 3953073 commit 13badcc

File tree

7 files changed

+16
-8
lines changed

7 files changed

+16
-8
lines changed

docs/Project.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ OptimizationOptimJL = "36348300-93cb-4f02-beb5-3c3902f8871e"
1414
OrdinaryDiffEq = "1dea7af3-3e70-54e6-95c3-0bf5283fa5ed"
1515
Plots = "91a5bcdd-55d7-5caf-9e0b-520d859cae80"
1616
StochasticDiffEq = "789caeaf-c7a9-5a7d-9973-96adeb23e2a0"
17+
SymbolicIndexingInterface = "2efcf032-c050-4f8e-a9bb-153293bab1f5"
1718
SymbolicUtils = "d1185830-fcd6-423d-90d6-eec64667417b"
1819
Symbolics = "0c5d862f-8b57-4792-8d23-62f2024744c7"
1920
Unitful = "1986cc42-f94f-5a68-af5c-568840ba703d"
@@ -33,6 +34,7 @@ OptimizationOptimJL = "0.1"
3334
OrdinaryDiffEq = "6.31"
3435
Plots = "1.36"
3536
StochasticDiffEq = "6"
37+
SymbolicIndexingInterface = "0.3.1"
3638
SymbolicUtils = "1"
3739
Symbolics = "5"
3840
Unitful = "1.12"

docs/src/basics/Validation.md

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,11 @@ ModelingToolkit.validate(eqs[1])
5959
```
6060

6161
```@example validation
62-
ModelingToolkit.get_unit(eqs[1].rhs)
62+
try
63+
ModelingToolkit.get_unit(eqs[1].rhs)
64+
catch e
65+
showerror(e)
66+
end
6367
```
6468

6569
An example of an inconsistent system: at present, `ModelingToolkit` requires that the units of all terms in an equation or sum to be equal-valued (`ModelingToolkit.equivalent(u1,u2)`), rather than simply dimensionally consistent. In the future, the validation stage may be upgraded to support the insertion of conversion factors into the equations.
@@ -100,7 +104,8 @@ end
100104
sts = @variables a(t)=0 [unit = u"cm"]
101105
ps = @parameters s=-1 [unit = u"cm"] c=c [unit = u"cm"]
102106
eqs = [D(a) ~ dummycomplex(c, s);]
103-
sys = ODESystem(eqs, t, [sts...;], [ps...;], name = :sys)
107+
sys = ODESystem(
108+
eqs, t, [sts...;], [ps...;], name = :sys, checks = ~ModelingToolkit.CheckUnits)
104109
sys_simple = structural_simplify(sys)
105110
```
106111

docs/src/basics/Variable_metadata.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ In the example below, we define a system with tunable parameters and extract bou
142142
@variables x(t)=0 u(t)=0 [input = true] y(t)=0 [output = true]
143143
@parameters T [tunable = true, bounds = (0, Inf)]
144144
@parameters k [tunable = true, bounds = (0, Inf)]
145-
eqs = [Dₜ(x) ~ (-x + k * u) / T # A first-order system with time constant T and gain k
145+
eqs = [D(x) ~ (-x + k * u) / T # A first-order system with time constant T and gain k
146146
y ~ x]
147147
sys = ODESystem(eqs, t, name = :tunable_first_order)
148148
```

docs/src/examples/parsing.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,11 @@ From there, we can use ModelingToolkit to transform the symbolic equations into
2323
nonlinear solve:
2424

2525
```@example parsing
26-
using ModelingToolkit, NonlinearSolve
26+
using ModelingToolkit, SymbolicIndexingInterface, NonlinearSolve
2727
vars = union(ModelingToolkit.vars.(eqs)...)
2828
@mtkbuild ns = NonlinearSystem(eqs, vars, [])
2929
30-
prob = NonlinearProblem(ns, [1.0, 1.0, 1.0])
30+
varmap = Dict(SymbolicIndexingInterface.getname.(vars) .=> vars)
31+
prob = NonlinearProblem(ns, [varmap[:x] => 1.0, varmap[:y] => 1.0, varmap[:z] => 1.0])
3132
sol = solve(prob, NewtonRaphson())
3233
```

docs/src/tutorials/ode_modeling.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -338,7 +338,7 @@ While defining the model `UnitstepFOLFactory`, an initial guess of 0.0 is assign
338338
Additionally, these initial guesses can be modified while creating instances of `UnitstepFOLFactory` by passing arguments.
339339

340340
```@example ode2
341-
@named fol = UnitstepFOLFactory(; x = 0.1)
341+
@mtkbuild fol = UnitstepFOLFactory(; x = 0.1)
342342
sol = ODEProblem(fol, [], (0.0, 5.0), []) |> solve
343343
```
344344

docs/src/tutorials/programmatically_generating.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ using ModelingToolkit: t_nounits as t, D_nounits as D
4141
eqs = [D(x) ~ (h - x) / τ] # create an array of equations
4242
4343
# your first ODE, consisting of a single equation, indicated by ~
44-
@named fol_model = ODESystem(eqs, t)
44+
@named model = ODESystem(eqs, t)
4545
4646
# Perform the standard transformations and mark the model complete
4747
# Note: Complete models cannot be subsystems of other models!

docs/src/tutorials/stochastic_diffeq.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,5 +34,5 @@ parammap = [
3434
]
3535
3636
prob = SDEProblem(de, u0map, (0.0, 100.0), parammap)
37-
sol = solve(prob, LambdaEulerHeun())
37+
sol = solve(prob, LambaEulerHeun())
3838
```

0 commit comments

Comments
 (0)