Skip to content

Commit

Permalink
safer Kepler
Browse files Browse the repository at this point in the history
  • Loading branch information
ChrisRackauckas committed Oct 7, 2024
1 parent 8d1a060 commit f3a781a
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion docs/src/examples/kepler_problem.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +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
using OrdinaryDiffEq, LinearAlgebra, ForwardDiff, NonlinearSolve, Plots
H(q, p) = norm(p)^2 / 2 - inv(norm(q))
L(q, p) = q[1] * p[2] - p[1] * q[2]
Expand All @@ -26,6 +26,9 @@ prob = DynamicalODEProblem(pdot, qdot, initial_velocity, initial_position, tspan
sol = solve(prob, KahanLi6(), dt = 1 // 10);
```

!!! note
Note that NonlinearSolve.jl is required to be imported for ManifoldProjection

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
Expand Down

0 comments on commit f3a781a

Please sign in to comment.