2022-01-26 22:37:51 +00:00
|
|
|
|
using Luxor
|
|
|
|
|
using Random: Random
|
|
|
|
|
using StaticArrays: SVector
|
|
|
|
|
|
|
|
|
|
using ReCo: ReCo
|
|
|
|
|
|
|
|
|
|
function gen_verlet_and_cell_lists_graphics()
|
2022-01-27 00:23:21 +00:00
|
|
|
|
Random.seed!(23)
|
2022-01-26 22:37:51 +00:00
|
|
|
|
|
|
|
|
|
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
|
2022-01-27 00:23:21 +00:00
|
|
|
|
σ = 2 * R_particle * 2^(-1 / 6)
|
2022-01-26 22:37:51 +00:00
|
|
|
|
R_interaction = 2^(1 / 6) * σ
|
|
|
|
|
R_skin = 2 * 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)
|
|
|
|
|
|
2022-01-27 00:23:21 +00:00
|
|
|
|
N = 91
|
2022-01-26 22:37:51 +00:00
|
|
|
|
|
|
|
|
|
particle_cs = Vector{SVector{2,Float64}}(undef, N)
|
|
|
|
|
|
2022-01-27 02:17:51 +00:00
|
|
|
|
distance_limit = 0.99 * 2 * particle_radius
|
|
|
|
|
|
2022-01-26 22:37:51 +00:00
|
|
|
|
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
|
|
|
|
|
|
2022-01-27 02:17:51 +00:00
|
|
|
|
if distance >= distance_limit
|
2022-01-26 22:37:51 +00:00
|
|
|
|
for p2_ind in 1:(p1_ind - 1)
|
2022-01-27 02:17:51 +00:00
|
|
|
|
if ReCo.norm2d(p1_c - particle_cs[p2_ind]) < distance_limit
|
2022-01-26 22:37:51 +00:00
|
|
|
|
no_collision = false
|
|
|
|
|
|
|
|
|
|
break
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
if no_collision
|
|
|
|
|
particle_cs[p1_ind] = p1_c
|
|
|
|
|
break
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
2022-01-27 00:23:21 +00:00
|
|
|
|
if distance < R_interaction
|
2022-01-26 22:37:51 +00:00
|
|
|
|
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
|
2022-01-27 00:23:21 +00:00
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
# TODO: Deduplicate with radial_distribution.jl
|