You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
148
148
149
149
```@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",
151
151
xaxis = "Velocity", yaxis = "Position", leg = false)
152
152
function phase_plot(prob, u0, p, tspan = 2pi)
153
153
_prob = ODEProblem(prob.f, u0, (0.0, tspan))
154
154
sol = solve(_prob, Vern9()) # Use Vern9 solver for higher accuracy
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.
31
30
32
31
```@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")
0 commit comments