mirror of
https://gitlab.rlp.net/mobitar/ReCo.jl.git
synced 2025-03-07 20:02:22 +00:00
Fixed plot_snapshot
This commit is contained in:
parent
70abd1d4c7
commit
e8faf811f1
2 changed files with 13 additions and 10 deletions
|
@ -1,6 +1,6 @@
|
|||
module Animation
|
||||
|
||||
export animate_with_gl, animate_with_cairo
|
||||
export animate, plot_snapshot
|
||||
|
||||
using CairoMakie
|
||||
using GLMakie
|
||||
|
@ -153,7 +153,7 @@ function gen_axis_and_colorbar(fig, sim_consts::ReCo.SimConsts)
|
|||
return (ax, color_scheme)
|
||||
end
|
||||
|
||||
function animate_with_gl(
|
||||
function animate(
|
||||
sim_dir::String;
|
||||
framerate::Int64=1,
|
||||
show_center_of_mass::Bool=false,
|
||||
|
@ -265,16 +265,19 @@ function get_wanted_snapshot_number(n_snapshots::Int64)
|
|||
return snapshot
|
||||
end
|
||||
|
||||
function animate_with_cairo(sim_dir::String; show_center_of_mass::Bool=false)
|
||||
function plot_snapshot(sim_dir::String; show_center_of_mass::Bool=false)
|
||||
bundles_info = ReCo.BundlesInfo(sim_dir)
|
||||
snapshot = get_wanted_snapshot_number(bundles_info.total_n_snapshots)
|
||||
|
||||
bundle_path = ""
|
||||
snapshot_counter = 1
|
||||
snapshot_counter = 0
|
||||
bundle_snapshot = 0
|
||||
|
||||
for bundle_ind in bundles_info.n_bundles
|
||||
snapshot_counter += bundles_info.bundle_n_snapshots[bundle_ind]
|
||||
for bundle_ind in 1:(bundles_info.n_bundles)
|
||||
bundle_n_snapshots = bundles_info.bundle_n_snapshots[bundle_ind]
|
||||
snapshot_counter += bundle_n_snapshots
|
||||
if snapshot_counter >= snapshot
|
||||
bundle_snapshot = bundle_n_snapshots - snapshot_counter + snapshot
|
||||
bundle_path = bundles_info.sorted_bundle_paths[bundle_ind]
|
||||
break
|
||||
end
|
||||
|
@ -291,8 +294,8 @@ function animate_with_cairo(sim_dir::String; show_center_of_mass::Bool=false)
|
|||
ax, color_scheme = gen_axis_and_colorbar(fig, sim_consts)
|
||||
|
||||
@simd for particle_ind in 1:(sim_consts.n_particles)
|
||||
c = bundle.c[particle_ind, snapshot]
|
||||
φ = bundle.φ[particle_ind, snapshot]
|
||||
c = bundle.c[particle_ind, bundle_snapshot]
|
||||
φ = bundle.φ[particle_ind, bundle_snapshot]
|
||||
|
||||
color = angle_color(φ, color_scheme)
|
||||
|
||||
|
@ -301,7 +304,7 @@ function animate_with_cairo(sim_dir::String; show_center_of_mass::Bool=false)
|
|||
|
||||
if show_center_of_mass
|
||||
center_of_mass = ReCo.center_of_mass(
|
||||
view(bundle.c, :, snapshot), sim_consts.half_box_len
|
||||
view(bundle.c, :, bundle_snapshot), sim_consts.half_box_len
|
||||
)
|
||||
circle = Circle(
|
||||
Point2(center_of_mass[1], center_of_mass[2]), 3 * sim_consts.particle_radius
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
module ReCo
|
||||
|
||||
export init_sim, run_sim, run_rl, animate_with_gl, animate_with_cairo, LocalCOMEnv
|
||||
export init_sim, run_sim, run_rl, animate, plot_snapshot, LocalCOMEnv
|
||||
|
||||
using StaticArrays: SVector
|
||||
using JLD2: JLD2
|
||||
|
|
Loading…
Add table
Reference in a new issue