mirror of
https://gitlab.rlp.net/mobitar/ReCo.jl.git
synced 2024-09-19 19:01:17 +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
|
module Animation
|
||||||
|
|
||||||
export animate_with_gl, animate_with_cairo
|
export animate, plot_snapshot
|
||||||
|
|
||||||
using CairoMakie
|
using CairoMakie
|
||||||
using GLMakie
|
using GLMakie
|
||||||
|
@ -153,7 +153,7 @@ function gen_axis_and_colorbar(fig, sim_consts::ReCo.SimConsts)
|
||||||
return (ax, color_scheme)
|
return (ax, color_scheme)
|
||||||
end
|
end
|
||||||
|
|
||||||
function animate_with_gl(
|
function animate(
|
||||||
sim_dir::String;
|
sim_dir::String;
|
||||||
framerate::Int64=1,
|
framerate::Int64=1,
|
||||||
show_center_of_mass::Bool=false,
|
show_center_of_mass::Bool=false,
|
||||||
|
@ -265,16 +265,19 @@ function get_wanted_snapshot_number(n_snapshots::Int64)
|
||||||
return snapshot
|
return snapshot
|
||||||
end
|
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)
|
bundles_info = ReCo.BundlesInfo(sim_dir)
|
||||||
snapshot = get_wanted_snapshot_number(bundles_info.total_n_snapshots)
|
snapshot = get_wanted_snapshot_number(bundles_info.total_n_snapshots)
|
||||||
|
|
||||||
bundle_path = ""
|
bundle_path = ""
|
||||||
snapshot_counter = 1
|
snapshot_counter = 0
|
||||||
|
bundle_snapshot = 0
|
||||||
|
|
||||||
for bundle_ind in bundles_info.n_bundles
|
for bundle_ind in 1:(bundles_info.n_bundles)
|
||||||
snapshot_counter += bundles_info.bundle_n_snapshots[bundle_ind]
|
bundle_n_snapshots = bundles_info.bundle_n_snapshots[bundle_ind]
|
||||||
|
snapshot_counter += bundle_n_snapshots
|
||||||
if snapshot_counter >= snapshot
|
if snapshot_counter >= snapshot
|
||||||
|
bundle_snapshot = bundle_n_snapshots - snapshot_counter + snapshot
|
||||||
bundle_path = bundles_info.sorted_bundle_paths[bundle_ind]
|
bundle_path = bundles_info.sorted_bundle_paths[bundle_ind]
|
||||||
break
|
break
|
||||||
end
|
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)
|
ax, color_scheme = gen_axis_and_colorbar(fig, sim_consts)
|
||||||
|
|
||||||
@simd for particle_ind in 1:(sim_consts.n_particles)
|
@simd for particle_ind in 1:(sim_consts.n_particles)
|
||||||
c = bundle.c[particle_ind, snapshot]
|
c = bundle.c[particle_ind, bundle_snapshot]
|
||||||
φ = bundle.φ[particle_ind, snapshot]
|
φ = bundle.φ[particle_ind, bundle_snapshot]
|
||||||
|
|
||||||
color = angle_color(φ, color_scheme)
|
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
|
if show_center_of_mass
|
||||||
center_of_mass = ReCo.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(
|
circle = Circle(
|
||||||
Point2(center_of_mass[1], center_of_mass[2]), 3 * sim_consts.particle_radius
|
Point2(center_of_mass[1], center_of_mass[2]), 3 * sim_consts.particle_radius
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
module ReCo
|
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 StaticArrays: SVector
|
||||||
using JLD2: JLD2
|
using JLD2: JLD2
|
||||||
|
|
Loading…
Reference in a new issue