Last active
September 19, 2022 15:43
-
-
Save rkube/45d799970fd2e7a0b93cc2991e48facf to your computer and use it in GitHub Desktop.
kinetic_anim.jl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Try animation of particle trajectories | |
tail = 200 | |
num_ptl = 1000 | |
trg = 1:100*tail | |
# size(phase_rs) = [2, 8_000, 20_000] | |
anim_step(tidx, ptl) = GLMakie.Point2f(phase_rs[:, ptl, tidx]) | |
traj_list = Any[] | |
for p ∈ 1:num_ptl | |
traj = CircularBuffer{GLMakie.Point2f}(tail) | |
fill!(traj, anim_step(1, p)) | |
traj = Observable(traj) | |
push!(traj_list, traj) | |
end | |
# Color is green for Ψₙ(t=0)<1 particles, red for Ψₙ(t=0)≥1 particles | |
c_inside = to_color(:green); | |
tailcol_inside = [RGBAf(c_inside.r, c_inside.g, c_inside.b, (i/tail)^2) for i in 1:tail]; | |
c_outside = to_color(:red); | |
tailcol_outside = [RGBAf(c_outside.r, c_outside.g, c_outside.b, (i/tail)^2) for i in 1:tail]; | |
f_anim, ax_anim, plt_anim = viz(sim_mesh, showfacets=true, facetcolor=:gray, alpha=0.2) | |
GLMakie.xlims!(ax_anim, [1.45, 1.465]) | |
GLMakie.ylims!(ax_anim, [-1.155, -1.145]) | |
for (psi, traj) in zip(psi_vals[1:num_ptl, 1], traj_list) | |
tailcol = psi < 1.0 ? tailcol_inside : tailcol_outside | |
lines!(ax_anim, traj, color=tailcol) | |
end | |
# Animation loop | |
record(f_anim, "pe459_v8.mp4", trg; framerate=tail) do t | |
mod(t, 100) == 0 && @show t | |
for (idx, traj) in enumerate(traj_list) | |
traj[] = push!(traj[], anim_step(t, idx)) | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment