1
0
Fork 0
mirror of https://gitlab.rlp.net/mobitar/ReCo.jl.git synced 2024-12-21 00:51:21 +00:00

activate! GLMakie

This commit is contained in:
Mo8it 2022-01-23 03:04:10 +01:00
parent 6e1a177d64
commit fded0888cf
5 changed files with 35 additions and 29 deletions

View file

@ -115,24 +115,6 @@ function animate_bundle!(args, sim_consts::ReCo.SimConsts)
return nothing
end
function sort_bundle_paths(bundle_paths::Vector{String})
n_bundles = length(bundle_paths)
bundle_nums = Vector{Int64}(undef, n_bundles)
extension_length = 5 # == length(".jld2")
for i in 1:n_bundles
bundle_path = bundle_paths[i]
bundle_num_string = bundle_path[(findfirst("bundle_", bundle_path).stop + 1):(end - extension_length)]
bundle_nums[i] = parse(Int64, bundle_num_string)
end
sort_perm = sortperm(bundle_nums)
return bundle_paths[sort_perm]
end
function animate_with_sim_consts(
dir::String,
sim_consts::ReCo.SimConsts,
@ -142,6 +124,7 @@ function animate_with_sim_consts(
show_skin_circle::Bool,
show_frame_diff::Bool,
)
GLMakie.activate!()
set_theme!(theme_black())
fig = Figure(; resolution=(1080, 1080))
@ -199,9 +182,7 @@ function animate_with_sim_consts(
segments_y = Observable(zeros(2 * n_particles))
end
bundle_paths = readdir("$dir/bundles"; join=true, sort=false)
bundle_paths = sort_bundle_paths(bundle_paths)
bundle_paths = ReCo.sorted_bundle_paths(dir)
@showprogress 1 for (n_bundle, bundle_path) in enumerate(bundle_paths)
bundle::ReCo.Bundle = JLD2.load_object(bundle_path)

View file

@ -6,7 +6,7 @@ using StaticArrays: SVector
using JLD2: JLD2
using Distributions: Uniform, Normal
using ProgressMeter: @showprogress
using CellListMap: Box, CellList, map_pairwise!, UpdateCellList!
using CellListMap: CellListMap
using Random: Random
using Dates: Dates

View file

@ -76,4 +76,24 @@ function save_bundle(dir::String, bundle::Bundle, n_bundle::Int64, T::Float64)
JLD2.save_object("$dir/sim_state.jld2", SimState(n_bundle, round(T; digits=3)))
return nothing
end
function sorted_bundle_paths(dir::String)
bundle_paths = readdir("$dir/bundles"; join=true, sort=false)
n_bundles = length(bundle_paths)
bundle_nums = Vector{Int64}(undef, n_bundles)
extension_length = 5 # == length(".jld2")
for i in 1:n_bundles
bundle_path = bundle_paths[i]
bundle_num_string = bundle_path[(findfirst("bundle_", bundle_path).stop + 1):(end - extension_length)]
bundle_nums[i] = parse(Int64, bundle_num_string)
end
sort_perm = sortperm(bundle_nums)
return bundle_paths[sort_perm]
end

View file

@ -2,6 +2,10 @@ function empty_hook(args...)
return nothing
end
function gen_cell_list_box(half_box_len::Float64, skin_r::Float64)
return CellListMap.Box(SVector(2 * half_box_len, 2 * half_box_len), skin_r)
end
function run_sim(
dir::String;
duration::Float64,
@ -97,10 +101,7 @@ function run_sim(
],
n_bundle_snapshots=n_bundle_snapshots,
bundle=Bundle(sim_consts.n_particles, n_bundle_snapshots),
box=Box(
SVector(2 * sim_consts.half_box_len, 2 * sim_consts.half_box_len),
sim_consts.skin_r,
),
box=gen_cell_list_box(sim_consts.half_box_len, sim_consts.skin_r),
)
simulate!(

View file

@ -21,9 +21,9 @@ function update_verlet_lists!(args, cl)
args.particles_c[i] = args.particles[i].c
end
cl = UpdateCellList!(args.particles_c, args.box, cl; parallel=false)
cl = CellListMap.UpdateCellList!(args.particles_c, args.box, cl; parallel=false)
map_pairwise!(
CellListMap.map_pairwise!(
(x, y, i, j, d2, output) -> push_to_verlet_list!(args.verlet_lists, i, j),
nothing,
args.box,
@ -102,6 +102,10 @@ function gen_run_additional_hooks(env_helper::RL.EnvHelper, integration_step::In
(integration_step == 1)
end
function gen_cell_list(particles_c::Vector{SVector{2,Float64}}, box::CellListMap.Box)
return CellListMap.CellList(particles_c, box; parallel=false)
end
function simulate!(
args,
T0::Float64,
@ -117,7 +121,7 @@ function simulate!(
task::Union{Task,Nothing} = nothing
cl = CellList(args.particles_c, args.box; parallel=false)
cl = gen_cell_list(args.particles_c, args.box)
cl = update_verlet_lists!(args, cl)
first_integration_step = true