1
0
Fork 0
mirror of https://gitlab.rlp.net/mobitar/ReCo.jl.git synced 2024-09-17 18:51:17 +00:00
ReCo.jl/graphics/Luxor_graphics/verlet_and_cell_lists.jl

96 lines
2.6 KiB
Julia
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

using Luxor
using Random: Random
using StaticArrays: SVector
using ReCo: ReCo
function gen_verlet_and_cell_lists_graphics()
Random.seed!(3)
box_length = 100
graphics_export_dir = "../../exports/graphics"
mkpath(graphics_export_dir)
Drawing(box_length, box_length, "$graphics_export_dir/verlet_and_cell_lists.pdf")
origin()
R_particle = 4.2
σ = 2 * R_particle * 2^(-1 / 6)
R_interaction = 2^(1 / 6) * σ
R_skin = ReCo.DEFAULT_SKIN_TO_INTERACTION_RADIUS_RATIO * R_interaction
setcolor("blue")
reference_particle_x = 0.25 * R_skin
reference_particle_y = -0.1 * R_skin
circle(Point(reference_particle_x, reference_particle_y), R_particle, :fill)
reference_particle_c = SVector(reference_particle_x, reference_particle_y)
N = 107
particle_cs = Vector{SVector{2,Float64}}(undef, N)
distance_limit = 0.98 * 2 * R_particle
x = y = distance = 0.0
for p1_ind in 1:N
while true
x = (rand() - 0.5) * box_length
y = (rand() - 0.5) * box_length
p1_c = SVector(x, y)
distance = ReCo.norm2d(p1_c - reference_particle_c)
no_collision = true
if distance >= distance_limit
for p2_ind in 1:(p1_ind - 1)
if ReCo.norm2d(p1_c - particle_cs[p2_ind]) < distance_limit
no_collision = false
break
end
end
if no_collision
particle_cs[p1_ind] = p1_c
break
end
end
end
if distance < R_interaction
setcolor("red")
elseif R_interaction <= distance < R_skin
setcolor("green")
else
setcolor("orange")
end
circle(x, y, R_particle, :fill)
end
setcolor("black")
setline(0.28)
for R in (R_interaction, R_skin)
circle(Point(reference_particle_x, reference_particle_y), R, :stroke)
end
half_n_lines = floor(Int64, box_length / (2 * R_skin) + 0.5)
for i in 1:half_n_lines
coordinate = (i - 0.5) * R_skin
line(Point(coordinate, -box_length), Point(coordinate, box_length), :stroke)
line(Point(-coordinate, -box_length), Point(-coordinate, box_length), :stroke)
line(Point(-box_length, coordinate), Point(box_length, coordinate), :stroke)
line(Point(-box_length, -coordinate), Point(box_length, -coordinate), :stroke)
end
setcolor((0.2, 0.0, 1.0, 0.3))
rect(-1.5 * R_skin, -1.5 * R_skin, 3 * R_skin, 3 * R_skin, :fill)
finish()
return nothing
end