Skip to content

Commit d40d63e

Browse files
Merge pull request #736 from NonDairyNeutrino/fix_vars_warning
fix warning: update vars to idxs
2 parents 0d18b66 + da1361c commit d40d63e

File tree

4 files changed

+21
-24
lines changed

4 files changed

+21
-24
lines changed

docs/Project.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ ModelingToolkit = "8"
6262
ODEProblemLibrary = "0.1"
6363
Optimization = "3"
6464
OptimizationNLopt = "0.1, 0.2"
65-
OrdinaryDiffEq = "6.31"
65+
OrdinaryDiffEq = "6.76"
6666
Plots = "1"
6767
RecursiveArrayTools = "2, 3"
6868
SDEProblemLibrary = "0.1"

docs/src/examples/classical_physics.md

+11-11
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ prob = SecondOrderODEProblem(harmonicoscillator, dx₀, x₀, tspan, ω)
8585
sol = solve(prob, DPRKN6())
8686
8787
#Plot
88-
plot(sol, vars = [2, 1], linewidth = 2, title = "Simple Harmonic Oscillator",
88+
plot(sol, idxs = [2, 1], linewidth = 2, title = "Simple Harmonic Oscillator",
8989
xaxis = "Time", yaxis = "Elongation", label = ["x" "dx"])
9090
plot!(t -> A * cos(ω * t - ϕ), lw = 3, ls = :dash, label = "Analytical Solution x")
9191
plot!(t -> -A * ω * sin(ω * t - ϕ), lw = 3, ls = :dash, label = "Analytical Solution dx")
@@ -147,12 +147,12 @@ plot(sol, linewidth = 2, title = "Simple Pendulum Problem", xaxis = "Time",
147147
So now we know that behaviour of the position versus time. However, it will be useful to us to look at the phase space of the pendulum, i.e., and representation of all possible states of the system in question (the pendulum) by looking at its velocity and position. Phase space analysis is ubiquitous in the analysis of dynamical systems, and thus we will provide a few facilities for it.
148148

149149
```@example physics
150-
p = plot(sol, vars = (1, 2), xlims = (-9, 9), title = "Phase Space Plot",
150+
p = plot(sol, idxs = (1, 2), xlims = (-9, 9), title = "Phase Space Plot",
151151
xaxis = "Velocity", yaxis = "Position", leg = false)
152152
function phase_plot(prob, u0, p, tspan = 2pi)
153153
_prob = ODEProblem(prob.f, u0, (0.0, tspan))
154154
sol = solve(_prob, Vern9()) # Use Vern9 solver for higher accuracy
155-
plot!(p, sol, vars = (1, 2), xlims = nothing, ylims = nothing)
155+
plot!(p, sol, idxs = (1, 2), xlims = nothing, ylims = nothing)
156156
end
157157
for i in (-4pi):(pi / 2):(4π)
158158
for j in (-4pi):(pi / 2):(4π)
@@ -267,13 +267,13 @@ function poincare_map(prob, u₀, p; callback = cb)
267267
_prob = ODEProblem(prob.f, u₀, prob.tspan)
268268
sol = solve(_prob, Vern9(), save_everystep = false, save_start = false,
269269
save_end = false, callback = cb, abstol = 1e-16, reltol = 1e-16)
270-
scatter!(p, sol, vars = (3, 4), markersize = 3, msw = 0)
270+
scatter!(p, sol, idxs = (3, 4), markersize = 3, msw = 0)
271271
end
272272
```
273273

274274
```@example physics
275275
lβrange = -0.02:0.0025:0.02
276-
p = scatter(sol2, vars = (3, 4), leg = false, markersize = 3, msw = 0)
276+
p = scatter(sol2, idxs = (3, 4), leg = false, markersize = 3, msw = 0)
277277
for lβ in lβrange
278278
poincare_map(poincare, [0.01, 0.01, 0.01, lβ], p)
279279
end
@@ -334,7 +334,7 @@ sol = solve(prob, Vern9(), abstol = 1e-16, reltol = 1e-16);
334334

335335
```@example physics
336336
# Plot the orbit
337-
plot(sol, vars = (1, 2), title = "The orbit of the Hénon-Heiles system", xaxis = "x",
337+
plot(sol, idxs = (1, 2), title = "The orbit of the Hénon-Heiles system", xaxis = "x",
338338
yaxis = "y", leg = false)
339339
```
340340

@@ -343,9 +343,9 @@ plot(sol, vars = (1, 2), title = "The orbit of the Hénon-Heiles system", xaxis
343343
@show sol.retcode
344344
345345
#Plot -
346-
plot(sol, vars = (1, 3), title = "Phase space for the Hénon-Heiles system",
346+
plot(sol, idxs = (1, 3), title = "Phase space for the Hénon-Heiles system",
347347
xaxis = "Position", yaxis = "Velocity")
348-
plot!(sol, vars = (2, 4), leg = false)
348+
plot!(sol, idxs = (2, 4), leg = false)
349349
```
350350

351351
```@example physics
@@ -382,14 +382,14 @@ Notice that we get the same results:
382382

383383
```@example physics
384384
# Plot the orbit
385-
plot(sol2, vars = (3, 4), title = "The orbit of the Hénon-Heiles system", xaxis = "x",
385+
plot(sol2, idxs = (3, 4), title = "The orbit of the Hénon-Heiles system", xaxis = "x",
386386
yaxis = "y", leg = false)
387387
```
388388

389389
```@example physics
390-
plot(sol2, vars = (3, 1), title = "Phase space for the Hénon-Heiles system",
390+
plot(sol2, idxs = (3, 1), title = "Phase space for the Hénon-Heiles system",
391391
xaxis = "Position", yaxis = "Velocity")
392-
plot!(sol2, vars = (4, 2), leg = false)
392+
plot!(sol2, idxs = (4, 2), leg = false)
393393
```
394394

395395
but now the energy change is essentially zero:

docs/src/examples/kepler_problem.md

+4-5
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,7 @@ Also, we know that
1010
$${\displaystyle {\frac {\mathrm {d} {\boldsymbol {p}}}{\mathrm {d} t}}=-{\frac {\partial {\mathcal {H}}}{\partial {\boldsymbol {q}}}}\quad ,\quad {\frac {\mathrm {d} {\boldsymbol {q}}}{\mathrm {d} t}}=+{\frac {\partial {\mathcal {H}}}{\partial {\boldsymbol {p}}}}}$$
1111

1212
```@example kepler
13-
using OrdinaryDiffEq, LinearAlgebra, ForwardDiff, Plots;
14-
gr();
13+
using OrdinaryDiffEq, LinearAlgebra, ForwardDiff, Plots
1514
H(q, p) = norm(p)^2 / 2 - inv(norm(q))
1615
L(q, p) = q[1] * p[2] - p[1] * q[2]
1716
@@ -30,12 +29,12 @@ sol = solve(prob, KahanLi6(), dt = 1 // 10);
3029
Let's plot the orbit and check the energy and angular momentum variation. We know that energy and angular momentum should be constant, and they are also called first integrals.
3130

3231
```@example kepler
33-
plot_orbit(sol) = plot(sol, vars = (3, 4), lab = "Orbit", title = "Kepler Problem Solution")
32+
plot_orbit(sol) = plot(sol, idxs = (3, 4), lab = "Orbit", title = "Kepler Problem Solution")
3433
3534
function plot_first_integrals(sol, H, L)
36-
plot(initial_first_integrals[1] .- map(u -> H(u[2, :], u[1, :]), sol.u),
35+
plot(initial_first_integrals[1] .- map(u -> H(u.x[2], u.x[1]), sol.u),
3736
lab = "Energy variation", title = "First Integrals")
38-
plot!(initial_first_integrals[2] .- map(u -> L(u[2, :], u[1, :]), sol.u),
37+
plot!(initial_first_integrals[2] .- map(u -> L(u.x[2], u.x[1]), sol.u),
3938
lab = "Angular momentum variation")
4039
end
4140
analysis_plot(sol, H, L) = plot(plot_orbit(sol), plot_first_integrals(sol, H, L))

docs/src/solvers/ode_solve.md

+5-7
Original file line numberDiff line numberDiff line change
@@ -556,20 +556,18 @@ to be thread safe. It parallelizes the `nlsolve` calls inside the method.
556556
- `ROS2PR` - A 2nd order stiffly accurate Rosenbrock-Wanner method with 3 internal stages with Rinf=0.
557557
For problems with medium stiffness the convergence behaviour is very poor
558558
and it is recommended to use `ROS2S` instead.
559-
- `ROS3PR` - A 3nd order stiffly accurate Rosenbrock-Wanner method
559+
- `ROS3PR` - A 3nd order stiffly accurate Rosenbrock-Wanner method
560560
with 3 internal stages and B_PR consistent of order 3, which is strongly A-stable with Rinf~=-0.73.
561-
- `Scholz47` - A 3nd order stiffly accurate Rosenbrock-Wanner method
561+
- `Scholz47` - A 3nd order stiffly accurate Rosenbrock-Wanner method
562562
with 3 internal stages and B_PR consistent of order 3, which is strongly A-stable with Rinf~=-0.73.
563563
Convergence with order 4 for the stiff case, but has a poor accuracy.
564564
- `ROS3PRL` - A 3nd order stiffly accurate Rosenbrock-Wanner method with 4 internal stages
565565
with B_PR consistent of order 2 with Rinf=0. The order of convergence decreases if medium stiff problems
566566
are considered, but it has good results for very stiff cases.
567567
- `ROS3PRL2` - A 3nd order stiffly accurate Rosenbrock-Wanner method with 4 internal stages
568-
with B_PR consistent of order 3. The order of convergence does NOT decreases if
568+
with B_PR consistent of order 3. The order of convergence does NOT decreases if
569569
medium stiff problems are considered as it does for ROS3PRL.
570570

571-
572-
573571
#### Rosenbrock-W Methods
574572

575573
- `Rosenbrock23` - An Order 2/3 L-Stable Rosenbrock-W method which is good for very
@@ -588,9 +586,9 @@ to be thread safe. It parallelizes the `nlsolve` calls inside the method.
588586
- `ROS34PW2` - A 4th order stiffy accurate Rosenbrock-W method for PDAEs.
589587
- `ROS34PW3` - A 4th order strongly A-stable (Rinf~0.63) Rosenbrock-W method.
590588
- `ROS34PRw` - A 3nd order stiffly accurate Rosenbrock-Wanner W-method with 4 internal stages with B_PR consistent of order 2
591-
- `ROS2S` - A 2nd order stiffly accurate Rosenbrock-Wanner W-method
589+
- `ROS2S` - A 2nd order stiffly accurate Rosenbrock-Wanner W-method
592590
with 3 internal stages with B_PR consistent of order 2 with Rinf=0.
593-
591+
594592
#### Stabilized Explicit Methods
595593

596594
- `ROCK2` - Second order stabilized Runge-Kutta method. Exhibits high stability

0 commit comments

Comments
 (0)