mirror of
https://gitlab.rlp.net/mobitar/ReCo.jl.git
synced 2024-12-21 00:51:21 +00:00
radial distribution shells
This commit is contained in:
parent
d9c8d65e73
commit
64b48b2046
2 changed files with 90 additions and 3 deletions
|
@ -33,10 +33,10 @@ function gen_COM_graphics()
|
||||||
|
|
||||||
##
|
##
|
||||||
|
|
||||||
graphics_export_dir = "exports/graphics"
|
graphics_export_dir = "exports/graphics/COM"
|
||||||
mkpath(graphics_export_dir)
|
mkpath(graphics_export_dir)
|
||||||
|
|
||||||
Drawing(box_length, box_height, "$graphics_export_dir/line.pdf")
|
Drawing(box_length, box_height, "$graphics_export_dir/linear.pdf")
|
||||||
origin()
|
origin()
|
||||||
|
|
||||||
setcolor("black")
|
setcolor("black")
|
||||||
|
@ -82,7 +82,7 @@ function gen_COM_graphics()
|
||||||
|
|
||||||
##
|
##
|
||||||
|
|
||||||
Drawing(box_length, box_height, "$graphics_export_dir/circle.pdf")
|
Drawing(box_length, box_height, "$graphics_export_dir/circular_projectiong.pdf")
|
||||||
origin()
|
origin()
|
||||||
|
|
||||||
arrow(Point(-1.2 * R, 0), Point(1.2 * R, 0); arrowheadlength=0.1 * R, linewidth=0.8)
|
arrow(Point(-1.2 * R, 0), Point(1.2 * R, 0); arrowheadlength=0.1 * R, linewidth=0.8)
|
||||||
|
|
87
graphics/radial_distribution.jl
Normal file
87
graphics/radial_distribution.jl
Normal file
|
@ -0,0 +1,87 @@
|
||||||
|
using Luxor
|
||||||
|
using Random: Random
|
||||||
|
using StaticArrays: SVector
|
||||||
|
|
||||||
|
using ReCo: ReCo
|
||||||
|
|
||||||
|
function gen_rdf_graphics()
|
||||||
|
Random.seed!(42)
|
||||||
|
|
||||||
|
box_length = 100
|
||||||
|
box_height = 100
|
||||||
|
|
||||||
|
graphics_export_dir = "exports/graphics"
|
||||||
|
mkpath(graphics_export_dir)
|
||||||
|
|
||||||
|
Drawing(box_length, box_height, "$graphics_export_dir/rdf_shells.pdf")
|
||||||
|
origin()
|
||||||
|
|
||||||
|
particle_radius = 5
|
||||||
|
Δr = 3 * particle_radius
|
||||||
|
|
||||||
|
setcolor("blue")
|
||||||
|
circle(Point(0, 0), particle_radius, :fill)
|
||||||
|
|
||||||
|
N = 50
|
||||||
|
twice_max_particle_coordinate = box_length
|
||||||
|
|
||||||
|
selected_shell_ind = 2
|
||||||
|
selected_lower_radius = selected_shell_ind * Δr
|
||||||
|
|
||||||
|
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) * twice_max_particle_coordinate
|
||||||
|
y = (rand() - 0.5) * twice_max_particle_coordinate
|
||||||
|
|
||||||
|
p1_c = SVector(x, y)
|
||||||
|
|
||||||
|
distance = ReCo.norm2d(p1_c)
|
||||||
|
|
||||||
|
no_collision = true
|
||||||
|
|
||||||
|
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
|
||||||
|
|
||||||
|
break
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
if no_collision
|
||||||
|
particle_cs[p1_ind] = p1_c
|
||||||
|
break
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
if selected_lower_radius <= distance < selected_lower_radius + Δr
|
||||||
|
setcolor("green")
|
||||||
|
else
|
||||||
|
setcolor("orange")
|
||||||
|
end
|
||||||
|
|
||||||
|
circle(x, y, particle_radius, :fill)
|
||||||
|
end
|
||||||
|
|
||||||
|
setcolor("black")
|
||||||
|
setline(0.2)
|
||||||
|
for shell_ind in 1:ceil(Int64, (box_length - 1) / 2 / Δr)
|
||||||
|
circle(Point(0, 0), shell_ind * Δr, :stroke)
|
||||||
|
end
|
||||||
|
|
||||||
|
setcolor("red")
|
||||||
|
setline(0.3)
|
||||||
|
line(Point(0, 0), Point(Δr, 0), :stroke)
|
||||||
|
|
||||||
|
fontsize(4)
|
||||||
|
text("r", Point(0.4 * Δr, 0.3 * Δr))
|
||||||
|
|
||||||
|
finish()
|
||||||
|
|
||||||
|
return nothing
|
||||||
|
end
|
Loading…
Reference in a new issue