mirror of
https://gitlab.rlp.net/mobitar/ReCo.jl.git
synced 2024-11-08 22:21:08 +00:00
98 lines
No EOL
2.6 KiB
Julia
98 lines
No EOL
2.6 KiB
Julia
using Luxor
|
||
using Random: Random
|
||
using StaticArrays: SVector
|
||
|
||
using ReCo: ReCo
|
||
|
||
function gen_verlet_and_cell_lists_graphics()
|
||
Random.seed!(23)
|
||
|
||
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 = 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)
|
||
|
||
N = 91
|
||
|
||
particle_cs = Vector{SVector{2,Float64}}(undef, N)
|
||
|
||
distance_limit = 0.99 * 2 * particle_radius
|
||
|
||
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
|
||
|
||
# TODO: Deduplicate with radial_distribution.jl |