From 464be6e7b289bcc7493ebd6efc04f5e8c8c92cc6 Mon Sep 17 00:00:00 2001 From: benedict-96 Date: Wed, 20 Nov 2024 13:03:18 +0100 Subject: [PATCH 1/8] Added gif. --- docs/src/tutorials/symplectic_autoencoder.md | 48 ++++++++++++++++++++ 1 file changed, 48 insertions(+) diff --git a/docs/src/tutorials/symplectic_autoencoder.md b/docs/src/tutorials/symplectic_autoencoder.md index b3d446f75..8c4b37d3b 100644 --- a/docs/src/tutorials/symplectic_autoencoder.md +++ b/docs/src/tutorials/symplectic_autoencoder.md @@ -372,6 +372,54 @@ Main.remark(raw"While training the symplectic autoencoder we completely ignore t ```@raw latex \begin{comment} ``` +We can also make an animation of the resulting solution using `Makie` [DanischKrumbiegel2021](@cite): + +```@setup toda_lattice +time_steps = 0:10:(length(sol.q) * 10) + +sol.q ############## !! +time_series = iterate(mtc(integrator_nn), ics; n_points = length(sol.t) * 10, prediction_window = seq_length) +time_steps = axes(time_series, 2) +function make_animation(; theme = :dark) +textcolor = theme == :dark ? :white : :black +fig = Figure() +ax = Axis(fig[1, 1], backgroundcolor = :transparent, + bottomspinecolor = textcolor, + topspinecolor = textcolor, + leftspinecolor = textcolor, + rightspinecolor = textcolor, + xtickcolor = textcolor, + ytickcolor = textcolor, + xticklabelcolor = textcolor, + yticklabelcolor = textcolor, + xlabel=L"\omega", + ylabel=L"q", + xlabelcolor = textcolor, + ylabelcolor = textcolor) +mblue = RGBf(31 / 256, 119 / 256, 180 / 256) +framerate = 30 +mblue = +record(fig, "toda_animation.mp4", time_steps; + framerate = framerate) do time_step + empty!(ax) + time_step ≤ size(time_series, 2) ? lines!(ax, sol.q[time_step, :], label = "t = $(sol.t[time_step])", color = mblue) : nothing + prediction = (q = time_series.q[:, time_step], p = time_series.p[:, time_step]) + sol_sae_t = decoder(sae_nn_cpu)(prediction) + lines!(ax, sol_sae_t.q, color = mpurple) + ylims!(ax, 0., 1.) + axislegend(ax; position = (1.01, 1.5), labelsize = 8) +end +nothing +end +make_animation(; theme = :dark) +make_animation(; theme = :light) +nothing # hide +``` + +```@example +Docs.HTML("""