1
0
Fork 0
mirror of https://gitlab.rlp.net/mobitar/ReCo.jl.git synced 2025-09-04 09:12:35 +00:00

Added verlet_and_cell_lists.jl

This commit is contained in:
Mo8it 2022-01-26 23:37:51 +01:00
parent 574cb561c3
commit cef9d37728
4 changed files with 110 additions and 18 deletions

View file

@ -8,12 +8,12 @@ function gen_rdf_graphics()
Random.seed!(1)
box_length = 100
box_height = 100
box_length = 100
graphics_export_dir = "exports/graphics"
mkpath(graphics_export_dir)
Drawing(box_length, box_height, "$graphics_export_dir/rdf_shells.pdf")
Drawing(box_length, box_length, "$graphics_export_dir/rdf_shells.pdf")
origin()
particle_radius = 6
@ -23,7 +23,6 @@ function gen_rdf_graphics()
circle(Point(0, 0), particle_radius, :fill)
N = 50
twice_max_particle_coordinate = box_length
selected_shell_ind = 3
selected_lower_radius = (selected_shell_ind - 1) * Δr
@ -34,8 +33,8 @@ function gen_rdf_graphics()
for p1_ind in 1:N
while true
x = (rand() - 0.5) * twice_max_particle_coordinate
y = (rand() - 0.5) * twice_max_particle_coordinate
x = (rand() - 0.5) * box_length
y = (rand() - 0.5) * box_length
p1_c = SVector(x, y)
@ -43,7 +42,7 @@ function gen_rdf_graphics()
no_collision = true
if distance > 2 * particle_radius
if distance >= 2 * particle_radius
for p2_ind in 1:(p1_ind - 1)
if ReCo.norm2d(p1_c - particle_cs[p2_ind]) < 2 * particle_radius
no_collision = false

View file

@ -0,0 +1,94 @@
using Luxor
using Random: Random
using StaticArrays: SVector
using ReCo: ReCo
function gen_verlet_and_cell_lists_graphics()
Random.seed!(2)
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
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 = 92
particle_cs = Vector{SVector{2,Float64}}(undef, N)
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 >= 2 * R_particle
for p2_ind in 1:(p1_ind - 1)
if ReCo.norm2d(p1_c - particle_cs[p2_ind]) < 2 * R_particle
no_collision = false
break
end
end
if no_collision
particle_cs[p1_ind] = p1_c
break
end
end
end
if 2 * R_particle <= 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