From 01e989c6bb7fc1b1de0460da9875590a0fa3771a Mon Sep 17 00:00:00 2001 From: Mo8it Date: Thu, 27 Jan 2022 18:48:25 +0100 Subject: [PATCH] Removed minimum_image --- analysis/mean_squared_displacement.jl | 2 -- .../radial_distribution_function.jl | 2 +- graphics/center_of_mass.jl | 12 ++++++------ graphics/periodic_boundary_conditions.jl | 12 ++++++------ src/Particle.jl | 19 +------------------ src/Shape.jl | 2 +- 6 files changed, 15 insertions(+), 34 deletions(-) diff --git a/analysis/mean_squared_displacement.jl b/analysis/mean_squared_displacement.jl index 98bec6a..04834ac 100644 --- a/analysis/mean_squared_displacement.jl +++ b/analysis/mean_squared_displacement.jl @@ -22,8 +22,6 @@ ReCo.gen_cell_list_box(::Float64, ::Float64) = nothing ReCo.restrict_coordinate(value::Float64, ::Float64) = value ReCo.restrict_coordinates(v::SVector{2,Float64}, ::Float64) = v ReCo.restrict_coordinates!(::ReCo.Particle, ::Float64) = nothing -ReCo.minimum_image_coordinate(value::Float64, ::Float64) = value -ReCo.minimum_image(v::SVector{2,Float64}, ::Float64) = v const δt = 1e-4 const Dₜ = ReCo.DEFAULT_Dₜ diff --git a/analysis/radial_distribution_function/radial_distribution_function.jl b/analysis/radial_distribution_function/radial_distribution_function.jl index 4b2aea4..d8166f1 100644 --- a/analysis/radial_distribution_function/radial_distribution_function.jl +++ b/analysis/radial_distribution_function/radial_distribution_function.jl @@ -111,7 +111,7 @@ function radial_distribution(; c2 = cs[p2_ind, snapshot_ind] r⃗₁₂ = c2 - c1 - r⃗₁₂ = ReCo.minimum_image(r⃗₁₂, sim_consts.half_box_len) + r⃗₁₂ = ReCo.restrict_coordinates(r⃗₁₂, sim_consts.half_box_len) distance = ReCo.norm2d(r⃗₁₂) diff --git a/graphics/center_of_mass.jl b/graphics/center_of_mass.jl index f17f7ae..2a95643 100644 --- a/graphics/center_of_mass.jl +++ b/graphics/center_of_mass.jl @@ -12,7 +12,7 @@ function gen_COM_graphics() A = -0.9 * L B = 0.65 * L - pr = 0.03 * L + particel_radius = 0.04 * L Ap_vec = Vector(ReCo.Shape.project_to_unit_circle(A, L)) Bp_vec = Vector(ReCo.Shape.project_to_unit_circle(B, L)) @@ -62,11 +62,11 @@ function gen_COM_graphics() setcolor("blue") for p in (A, B) - circle(Point(p, 0), pr, :fill) + circle(Point(p, 0), particel_radius, :fill) end setcolor("brown") - circle(Point(COM, 0), pr, :fill) + circle(Point(COM, 0), particel_radius, :fill) setcolor("black") fontsize(5) @@ -106,7 +106,7 @@ function gen_COM_graphics() setcolor("blue") for pp in (Ap, Bp) - circle(R * pp, pr, :fill) + circle(R * pp, particel_radius, :fill) end setcolor("black") @@ -115,10 +115,10 @@ function gen_COM_graphics() line(Point(0, 0), COMp, :stroke) setcolor("purple1") - circle(M, pr, :fill) + circle(M, particel_radius, :fill) setcolor("brown") - circle(COMp, pr, :fill) + circle(COMp, particel_radius, :fill) finish() diff --git a/graphics/periodic_boundary_conditions.jl b/graphics/periodic_boundary_conditions.jl index bf65a57..2a0e764 100644 --- a/graphics/periodic_boundary_conditions.jl +++ b/graphics/periodic_boundary_conditions.jl @@ -77,15 +77,15 @@ function gen_periodic_boundary_conditions_graphics() setcolor("black") setline(1.0) - for sign in (1, -1) + for line_factor in (-3, -1, 1, 3) line( - Point(sign * drwaing_box_length / 6, drwaing_box_length / 2), - Point(sign * drwaing_box_length / 6, -drwaing_box_length / 2), + Point(line_factor * drwaing_box_length / 6, drwaing_box_length / 2), + Point(line_factor * drwaing_box_length / 6, -drwaing_box_length / 2), :stroke, ) line( - Point(drwaing_box_length / 2, sign * drwaing_box_length / 6), - Point(-drwaing_box_length / 2, sign * drwaing_box_length / 6), + Point(drwaing_box_length / 2, line_factor * drwaing_box_length / 6), + Point(-drwaing_box_length / 2, line_factor * drwaing_box_length / 6), :stroke, ) end @@ -96,7 +96,7 @@ function gen_periodic_boundary_conditions_graphics() p1_c = particles[p1_ind].c p2_c = particles[p2_ind].c normal_vec_form_p1_to_p2 = p2_c - p1_c - min_image_vec = ReCo.minimum_image(normal_vec_form_p1_to_p2, half_box_len) + min_image_vec = ReCo.restrict_coordinates(normal_vec_form_p1_to_p2, half_box_len) min_image_vec_from_p1 = p1_c + min_image_vec setcolor("black") diff --git a/src/Particle.jl b/src/Particle.jl index 2947b53..cfcb3da 100644 --- a/src/Particle.jl +++ b/src/Particle.jl @@ -37,23 +37,6 @@ function restrict_coordinates!(p::Particle, half_box_len::Float64) return nothing end -function minimum_image_coordinate(value::Float64, half_box_len::Float64) - if value <= -half_box_len - value += 2 * half_box_len - elseif value > half_box_len - value -= 2 * half_box_len - end - - return value -end - -function minimum_image(v::SVector{2,Float64}, half_box_len::Float64) - return SVector( - minimum_image_coordinate(v[1], half_box_len), - minimum_image_coordinate(v[2], half_box_len), - ) -end - function are_overlapping( c1::SVector{2,Float64}, c2::SVector{2,Float64}, @@ -62,7 +45,7 @@ function are_overlapping( ) r⃗₁₂ = c2 - c1 # 1 -> 2 - r⃗₁₂ = minimum_image(r⃗₁₂, half_box_len) + r⃗₁₂ = restrict_coordinates(r⃗₁₂, half_box_len) distance² = sq_norm2d(r⃗₁₂) diff --git a/src/Shape.jl b/src/Shape.jl index 24fddff..a59e3f6 100644 --- a/src/Shape.jl +++ b/src/Shape.jl @@ -125,7 +125,7 @@ function elliptical_distance( elliptical_a_b_ratio::R, half_box_len::R, ) where {R<:Real} - v′ = ReCo.minimum_image(v - COM, half_box_len) + v′ = ReCo.restrict_coordinates(v - COM, half_box_len) x = LA.dot(v′, gyration_tensor_eigvec_to_bigger_eigval) y = LA.dot(v′, gyration_tensor_eigvec_to_smaller_eigval)