From 3ff5e35e519639bc54e7d2c958fe21680e428873 Mon Sep 17 00:00:00 2001 From: nondairyneutrino Date: Sat, 18 May 2024 14:12:48 -0700 Subject: [PATCH 1/3] fix warning: update vars to idxs --- docs/src/examples/classical_physics.md | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/docs/src/examples/classical_physics.md b/docs/src/examples/classical_physics.md index e9e37f33d..b3fc850f0 100644 --- a/docs/src/examples/classical_physics.md +++ b/docs/src/examples/classical_physics.md @@ -85,7 +85,7 @@ prob = SecondOrderODEProblem(harmonicoscillator, dx₀, x₀, tspan, ω) sol = solve(prob, DPRKN6()) #Plot -plot(sol, vars = [2, 1], linewidth = 2, title = "Simple Harmonic Oscillator", +plot(sol, idxs = [2, 1], linewidth = 2, title = "Simple Harmonic Oscillator", xaxis = "Time", yaxis = "Elongation", label = ["x" "dx"]) plot!(t -> A * cos(ω * t - ϕ), lw = 3, ls = :dash, label = "Analytical Solution x") 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", 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. ```@example physics -p = plot(sol, vars = (1, 2), xlims = (-9, 9), title = "Phase Space Plot", +p = plot(sol, idxs = (1, 2), xlims = (-9, 9), title = "Phase Space Plot", xaxis = "Velocity", yaxis = "Position", leg = false) function phase_plot(prob, u0, p, tspan = 2pi) _prob = ODEProblem(prob.f, u0, (0.0, tspan)) sol = solve(_prob, Vern9()) # Use Vern9 solver for higher accuracy - plot!(p, sol, vars = (1, 2), xlims = nothing, ylims = nothing) + plot!(p, sol, idxs = (1, 2), xlims = nothing, ylims = nothing) end for i in (-4pi):(pi / 2):(4π) for j in (-4pi):(pi / 2):(4π) @@ -267,13 +267,13 @@ function poincare_map(prob, u₀, p; callback = cb) _prob = ODEProblem(prob.f, u₀, prob.tspan) sol = solve(_prob, Vern9(), save_everystep = false, save_start = false, save_end = false, callback = cb, abstol = 1e-16, reltol = 1e-16) - scatter!(p, sol, vars = (3, 4), markersize = 3, msw = 0) + scatter!(p, sol, idxs = (3, 4), markersize = 3, msw = 0) end ``` ```@example physics lβrange = -0.02:0.0025:0.02 -p = scatter(sol2, vars = (3, 4), leg = false, markersize = 3, msw = 0) +p = scatter(sol2, idxs = (3, 4), leg = false, markersize = 3, msw = 0) for lβ in lβrange poincare_map(poincare, [0.01, 0.01, 0.01, lβ], p) end @@ -334,7 +334,7 @@ sol = solve(prob, Vern9(), abstol = 1e-16, reltol = 1e-16); ```@example physics # Plot the orbit -plot(sol, vars = (1, 2), title = "The orbit of the Hénon-Heiles system", xaxis = "x", +plot(sol, idxs = (1, 2), title = "The orbit of the Hénon-Heiles system", xaxis = "x", yaxis = "y", leg = false) ``` @@ -343,9 +343,9 @@ plot(sol, vars = (1, 2), title = "The orbit of the Hénon-Heiles system", xaxis @show sol.retcode #Plot - -plot(sol, vars = (1, 3), title = "Phase space for the Hénon-Heiles system", +plot(sol, idxs = (1, 3), title = "Phase space for the Hénon-Heiles system", xaxis = "Position", yaxis = "Velocity") -plot!(sol, vars = (2, 4), leg = false) +plot!(sol, idxs = (2, 4), leg = false) ``` ```@example physics @@ -382,14 +382,14 @@ Notice that we get the same results: ```@example physics # Plot the orbit -plot(sol2, vars = (3, 4), title = "The orbit of the Hénon-Heiles system", xaxis = "x", +plot(sol2, idxs = (3, 4), title = "The orbit of the Hénon-Heiles system", xaxis = "x", yaxis = "y", leg = false) ``` ```@example physics -plot(sol2, vars = (3, 1), title = "Phase space for the Hénon-Heiles system", +plot(sol2, idxs = (3, 1), title = "Phase space for the Hénon-Heiles system", xaxis = "Position", yaxis = "Velocity") -plot!(sol2, vars = (4, 2), leg = false) +plot!(sol2, idxs = (4, 2), leg = false) ``` but now the energy change is essentially zero: From b64455ef4c5d73a4a6bd797ebdc8592237cb70d6 Mon Sep 17 00:00:00 2001 From: Christopher Rackauckas Date: Sun, 19 May 2024 12:13:25 -0400 Subject: [PATCH 2/3] Fixes to Kepler --- docs/Project.toml | 2 +- docs/src/examples/kepler_problem.md | 9 ++++----- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/docs/Project.toml b/docs/Project.toml index fa8663361..9d2ea8cf8 100644 --- a/docs/Project.toml +++ b/docs/Project.toml @@ -62,7 +62,7 @@ ModelingToolkit = "8" ODEProblemLibrary = "0.1" Optimization = "3" OptimizationNLopt = "0.1, 0.2" -OrdinaryDiffEq = "6.31" +OrdinaryDiffEq = "6.76" Plots = "1" RecursiveArrayTools = "2, 3" SDEProblemLibrary = "0.1" diff --git a/docs/src/examples/kepler_problem.md b/docs/src/examples/kepler_problem.md index 053c0a559..0a6008b40 100644 --- a/docs/src/examples/kepler_problem.md +++ b/docs/src/examples/kepler_problem.md @@ -10,8 +10,7 @@ Also, we know that $${\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}}}}}$$ ```@example kepler -using OrdinaryDiffEq, LinearAlgebra, ForwardDiff, Plots; -gr(); +using OrdinaryDiffEq, LinearAlgebra, ForwardDiff, Plots H(q, p) = norm(p)^2 / 2 - inv(norm(q)) L(q, p) = q[1] * p[2] - p[1] * q[2] @@ -30,12 +29,12 @@ sol = solve(prob, KahanLi6(), dt = 1 // 10); 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. ```@example kepler -plot_orbit(sol) = plot(sol, vars = (3, 4), lab = "Orbit", title = "Kepler Problem Solution") +plot_orbit(sol) = plot(sol, idxs = (3, 4), lab = "Orbit", title = "Kepler Problem Solution") function plot_first_integrals(sol, H, L) - plot(initial_first_integrals[1] .- map(u -> H(u[2, :], u[1, :]), sol.u), + plot(initial_first_integrals[1] .- map(u -> H(u.x[2], u.x[1]), sol.u), lab = "Energy variation", title = "First Integrals") - plot!(initial_first_integrals[2] .- map(u -> L(u[2, :], u[1, :]), sol.u), + plot!(initial_first_integrals[2] .- map(u -> L(u.x[2], u.x[1]), sol.u), lab = "Angular momentum variation") end analysis_plot(sol, H, L) = plot(plot_orbit(sol), plot_first_integrals(sol, H, L)) From da1361c68b6f52530e08d237507a88d5f100e52d Mon Sep 17 00:00:00 2001 From: Christopher Rackauckas Date: Sun, 19 May 2024 12:18:55 -0400 Subject: [PATCH 3/3] format --- docs/src/solvers/ode_solve.md | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/docs/src/solvers/ode_solve.md b/docs/src/solvers/ode_solve.md index 48d2a02e8..b2dd1aff6 100644 --- a/docs/src/solvers/ode_solve.md +++ b/docs/src/solvers/ode_solve.md @@ -556,20 +556,18 @@ to be thread safe. It parallelizes the `nlsolve` calls inside the method. - `ROS2PR` - A 2nd order stiffly accurate Rosenbrock-Wanner method with 3 internal stages with Rinf=0. For problems with medium stiffness the convergence behaviour is very poor and it is recommended to use `ROS2S` instead. - - `ROS3PR` - A 3nd order stiffly accurate Rosenbrock-Wanner method + - `ROS3PR` - A 3nd order stiffly accurate Rosenbrock-Wanner method with 3 internal stages and B_PR consistent of order 3, which is strongly A-stable with Rinf~=-0.73. - - `Scholz47` - A 3nd order stiffly accurate Rosenbrock-Wanner method + - `Scholz47` - A 3nd order stiffly accurate Rosenbrock-Wanner method with 3 internal stages and B_PR consistent of order 3, which is strongly A-stable with Rinf~=-0.73. Convergence with order 4 for the stiff case, but has a poor accuracy. - `ROS3PRL` - A 3nd order stiffly accurate Rosenbrock-Wanner method with 4 internal stages with B_PR consistent of order 2 with Rinf=0. The order of convergence decreases if medium stiff problems are considered, but it has good results for very stiff cases. - `ROS3PRL2` - A 3nd order stiffly accurate Rosenbrock-Wanner method with 4 internal stages - with B_PR consistent of order 3. The order of convergence does NOT decreases if + with B_PR consistent of order 3. The order of convergence does NOT decreases if medium stiff problems are considered as it does for ROS3PRL. - - #### Rosenbrock-W Methods - `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. - `ROS34PW2` - A 4th order stiffy accurate Rosenbrock-W method for PDAEs. - `ROS34PW3` - A 4th order strongly A-stable (Rinf~0.63) Rosenbrock-W method. - `ROS34PRw` - A 3nd order stiffly accurate Rosenbrock-Wanner W-method with 4 internal stages with B_PR consistent of order 2 - - `ROS2S` - A 2nd order stiffly accurate Rosenbrock-Wanner W-method + - `ROS2S` - A 2nd order stiffly accurate Rosenbrock-Wanner W-method with 3 internal stages with B_PR consistent of order 2 with Rinf=0. - + #### Stabilized Explicit Methods - `ROCK2` - Second order stabilized Runge-Kutta method. Exhibits high stability