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

Fixed generating particles in run_sim

This commit is contained in:
MoBit 2021-12-03 00:37:43 +01:00
parent d7ad9c3354
commit 8e1d274473
7 changed files with 35 additions and 12 deletions

View file

@ -5,14 +5,16 @@ end
if splitdir(pwd())[2] != "ReCo"
error("You have to be in the main directeory ReCo!")
else
include("src/ReCo.jl")
includet("src/analysis/pair_correlation_function.jl")
include("src/analysis/pair_correlation_function.jl")
end
##
using JLD2
using CairoMakie
CairoMakie.activate!()
set_theme!(theme_black())
##

View file

@ -10,7 +10,7 @@ mutable struct Particle
φ::Float64 # Angle
function Particle(; id::Int64, c::Vector{Float64}, φ::Float64)
return new(id, c, copy(c), φ)
return new(id, c, zeros(2), φ)
end
end

View file

@ -1,3 +1,5 @@
import Base: push!, iterate
mutable struct PreVector{T}
last_ind::UInt64
v::Vector{T}

View file

@ -1,3 +1,9 @@
using CairoMakie, LaTeXStrings
using StaticArrays
using LoopVectorization: @tturbo
using ReCo: minimum_image
function plot_g(radius, g, variables)
fig = Figure()
ax = Axis(

View file

@ -4,6 +4,8 @@ using LaTeXStrings: @L_str
function animate(dir::String; framerate=0)
println("Generating animation...")
set_theme!(theme_black())
fig = Figure(; resolution=(1080, 1080))
ax = Axis(
fig[1, 1];

View file

@ -1,5 +1,6 @@
using Random: Random
using JSON3: JSON3
using JLD2: JLD2
function run_sim(
dir::String;
@ -33,6 +34,12 @@ function run_sim(
n_bundle_snapshots = min(n_snapshots, n_bundle_snapshots)
status = JSON3.read(read("$dir/status.json", String))
n_bundles = status.n_bundles
bundles_dir = "$dir/bundles"
bundle = JLD2.load_object("$bundles_dir/bundle_$n_bundles.jld2")
args = (
v=sim_consts.v,
skin_r=skin_r,
@ -49,17 +56,13 @@ function run_sim(
N=sim_consts.N,
l=sim_consts.l,
particle_diameter=sim_consts.particle_diameter,
particles=generate_particles(
sim_consts.grid_n, sim_consts.grid_box_width, sim_consts.l
),
particles=generate_particles(bundle, sim_consts.N),
verlet_list=[PreVector{Int64}(sim_consts.N - 1) for i in 1:(sim_consts.N - 1)],
n_bundle_snapshots=n_bundle_snapshots,
bundle=Bundle(sim_consts.N, n_bundle_snapshots),
)
status = JSON3.read(read("$dir/status.json", String))
T0::Float64 = status.T
T = T0 + duration
start_datetime = now()
@ -82,10 +85,7 @@ function run_sim(
start_datetime,
)
n_bundles::Int64 = status.n_bundles
next_bundle = n_bundles + 1
bundles_dir = "$dir/bundles"
mkpath(bundles_dir)
if n_bundle_snapshots > 0
save_data = true

View file

@ -1,13 +1,14 @@
using Distributions: Uniform
using Dates: now
using JSON3: JSON3
using ReCo: Bundle, Particle
function initial_particle_grid_pos(i, j; grid_box_width, l)
term = -0.5 * grid_box_width - l
return [k * grid_box_width + term for k in (i, j)]
end
function generate_particles(grid_n, grid_box_width, l)
function generate_particles(grid_n::Int64, grid_box_width::Float64, l::Float64)
particles = Vector{Particle}(undef, grid_n^2)
id = 1
@ -27,6 +28,16 @@ function generate_particles(grid_n, grid_box_width, l)
return particles
end
function generate_particles(bundle::Bundle, N::Int64)
particles = Vector{Particle}(undef, N)
for id in 1:N
particles[id] = Particle(; id=id, c=bundle.c[id, end], φ=bundle.φ[id, end])
end
return particles
end
function init_sim(;
N::Int64, v::Float64, δt::Float64=1e-5, packing_ratio::Float64=0.5, comment::String=""
)