Implementation of the method of Lagrangian Descriptors to highlight singular features (e.g. stable or unstable invariant manifolds) of the dynamics of an evolutionary system (such as ordinary or partial differential equations, random equations, or stochastic differential equations).
Here in an example on a periodically forced Duffing system.
using OrdinaryDiffEq, Plots
using LinearAlgebra: norm
using LagrangianDescriptors
function f!(du, u, p, t)
x, y = u
A, ω = p
du[1] = y
du[2] = x - x^3 + A * sin(ω * t)
end
u0 = [0.5, 2.2]
tspan = (0.0, 13.0)
A = 0.3; ω = π
p = (A, ω)
prob = ODEProblem(f!, u0, tspan, p)
M(du, u, p, t) = norm(du)
uu0 = [[x, y] for y in range(-1.0, 1.0, length=301), x in range(-1.8, 1.8, length=301)]
lagprob = LagrangianDescriptorProblem(prob, M, uu0)
With all setup, we may solve it as follows:
julia> @time lagsol = solve(lagprob, Tsit5())
4.241800 seconds (204.88 M allocations: 9.173 GiB, 23.40% gc time, 24.99% compilation time)
Then we use the built-in plot recipe to get the heatmap of the Lagrangian descriptors:
plot(lagsol)
And here is a painting of a random Duffing oscillator, detailed in the Tutorials part of the documentation:
- Painting the Phase Portrait of a Dynamical System with the Computational Tool of Lagrangian Descriptors
- Lagrangian descriptors: A method for revealing phase space structures of general time dependent dynamical systems
- Lagrangian Descriptors - Discovery and Quantification of Phase Space Structure and Transport
- Frequently Asked Questions about Lagrangian Descriptors