Skip to content

Commit de20350

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

File tree

6 files changed

+10
-7
lines changed

6 files changed

+10
-7
lines changed

docs/src/basics/Validation.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ ModelingToolkit.validate(eqs[1])
6060

6161
```@example validation
6262
ModelingToolkit.get_unit(eqs[1].rhs)
63+
nothing # hide
6364
```
6465

6566
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 +101,8 @@ end
100101
sts = @variables a(t)=0 [unit = u"cm"]
101102
ps = @parameters s=-1 [unit = u"cm"] c=c [unit = u"cm"]
102103
eqs = [D(a) ~ dummycomplex(c, s);]
103-
sys = ODESystem(eqs, t, [sts...;], [ps...;], name = :sys)
104+
sys = ODESystem(
105+
eqs, t, [sts...;], [ps...;], name = :sys, check = ~ModelingToolkit.CheckUnits)
104106
sys_simple = structural_simplify(sys)
105107
```
106108

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)