Skip to content

Commit 4983626

Browse files
docs: call complete where required in documentation before creating XProblems
1 parent 4941f47 commit 4983626

File tree

12 files changed

+18
-11
lines changed

12 files changed

+18
-11
lines changed

docs/src/basics/Events.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ function UnitMassWithFriction(k; name)
7373
ODESystem(eqs, t; continuous_events = [v ~ 0], name) # when v = 0 there is a discontinuity
7474
end
7575
@named m = UnitMassWithFriction(0.7)
76-
prob = ODEProblem(m, Pair[], (0, 10pi))
76+
prob = ODEProblem(complete(m), Pair[], (0, 10pi))
7777
sol = solve(prob, Tsit5())
7878
plot(sol)
7979
```
@@ -244,7 +244,7 @@ u0 = [N => 0.0]
244244
tspan = (0.0, 20.0)
245245
p = [α => 100.0, tinject => 10.0, M => 50]
246246
@named osys = ODESystem(eqs, t, [N], [α, M, tinject]; discrete_events = injection)
247-
oprob = ODEProblem(osys, u0, tspan, p)
247+
oprob = ODEProblem(complete(osys), u0, tspan, p)
248248
sol = solve(oprob, Tsit5(); tstops = 10.0)
249249
plot(sol)
250250
```

docs/src/examples/parsing.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,6 @@ using ModelingToolkit, NonlinearSolve
2727
vars = union(ModelingToolkit.vars.(eqs)...)
2828
@named ns = NonlinearSystem(eqs, vars, [])
2929
30-
prob = NonlinearProblem(ns, [1.0, 1.0, 1.0])
30+
prob = NonlinearProblem(complete(ns), [1.0, 1.0, 1.0])
3131
sol = solve(prob, NewtonRaphson())
3232
```

docs/src/examples/sparse_jacobians.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ Now let's use `modelingtoolkitize` to generate the symbolic version:
5555

5656
```@example sparsejac
5757
sys = modelingtoolkitize(prob);
58+
sys = complete(sys);
5859
nothing # hide
5960
```
6061

docs/src/tutorials/bifurcation_diagram_computation.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ using ModelingToolkit
1313
eqs = [0 ~ μ * x - x^3 + α * y,
1414
0 ~ -y]
1515
@named nsys = NonlinearSystem(eqs, [x, y], [μ, α])
16+
nsys = complete(nsys)
1617
```
1718

1819
we wish to compute a bifurcation diagram for this system as we vary the parameter `μ`. For this, we need to provide the following information:
@@ -97,6 +98,7 @@ D = Differential(t)
9798
eqs = [D(x) ~ μ * x - y - x * (x^2 + y^2),
9899
D(y) ~ x + μ * y - y * (x^2 + y^2)]
99100
@named osys = ODESystem(eqs, t)
101+
osys = complete(osys)
100102
101103
bif_par = μ
102104
plot_var = x

docs/src/tutorials/modelingtoolkitize.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,5 +58,5 @@ sys = modelingtoolkitize(prob)
5858
Using this, we can symbolically build the Jacobian and then rebuild the ODEProblem:
5959

6060
```@example mtkize
61-
prob_jac = ODEProblem(sys, [], (0.0, 1e5), jac = true)
61+
prob_jac = ODEProblem(complete(sys), [], (0.0, 1e5), jac = true)
6262
```

docs/src/tutorials/nonlinear.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ eqs = [0 ~ σ * (y - x),
1717
0 ~ x * (ρ - z) - y,
1818
0 ~ x * y - β * z]
1919
@named ns = NonlinearSystem(eqs, [x, y, z], [σ, ρ, β])
20+
ns = complete(ns)
2021
2122
guess = [x => 1.0,
2223
y => 0.0,

docs/src/tutorials/optimization.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ u0 = [x => 1.0
5050
p = [a => 1.0
5151
b => 100.0]
5252
53-
prob = OptimizationProblem(sys, u0, p, grad = true, hess = true)
53+
prob = OptimizationProblem(complete(sys), u0, p, grad = true, hess = true)
5454
solve(prob, GradientDescent())
5555
```
5656

@@ -71,7 +71,7 @@ cons = [
7171
@named sys = OptimizationSystem(loss, [x, y], [a, b], constraints = cons)
7272
u0 = [x => 0.14
7373
y => 0.14]
74-
prob = OptimizationProblem(sys, u0, grad = true, hess = true, cons_j = true, cons_h = true)
74+
prob = OptimizationProblem(complete(sys), u0, grad = true, hess = true, cons_j = true, cons_h = true)
7575
solve(prob, IPNewton())
7676
```
7777

docs/src/tutorials/stochastic_diffeq.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ noiseeqs = [0.1 * x,
2424
0.1 * z]
2525
2626
@named de = SDESystem(eqs, noiseeqs, t, [x, y, z], [σ, ρ, β])
27+
de = complete(de)
2728
2829
u0map = [
2930
x => 1.0,

src/systems/abstractsystem.jl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1330,6 +1330,8 @@ information. E.g.
13301330
```julia-repl
13311331
julia> sys = debug_system(sys);
13321332
1333+
julia> sys = complete(sys);
1334+
13331335
julia> prob = ODEProblem(sys, [], (0, 1.0));
13341336
13351337
julia> du = zero(prob.u0);

src/systems/diffeqs/basic_transformations.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ u0 = [x => 1.0,
3131
y => 1.0,
3232
trJ => 1.0]
3333
34-
prob = ODEProblem(sys2,u0,tspan,p)
34+
prob = ODEProblem(complete(sys2),u0,tspan,p)
3535
sol = solve(prob,Tsit5())
3636
```
3737

0 commit comments

Comments
 (0)