mirror of
https://gitlab.rlp.net/mobitar/ReCo.jl.git
synced 2024-11-08 22:21:08 +00:00
76 lines
No EOL
2.4 KiB
Julia
76 lines
No EOL
2.4 KiB
Julia
using Test
|
|
using ReCo
|
|
|
|
using StaticArrays: SVector
|
|
|
|
@testset "Geometry.jl" begin
|
|
@test ReCo.Geometry.angle2(SVector(1.0, 0.0), SVector(0.0, 1.0)) / π ≈ 0.5
|
|
@test ReCo.Geometry.angle2(SVector(0.0, 1.0), SVector(1.0, 0.0)) / π ≈ -0.5
|
|
@test ReCo.Geometry.angle2(SVector(1.0, 0.0), SVector(1.0, 0.0)) / π ≈ 0.0
|
|
end
|
|
|
|
@testset "Particle.jl" begin
|
|
half_box_len = 1.0
|
|
|
|
@testset "restrict_coordinates" begin
|
|
@test ReCo.restrict_coordinates(SVector(1.5, -0.8), half_box_len) ≈
|
|
SVector(-0.5, -0.8)
|
|
end
|
|
|
|
@testset "are_overlapping" begin
|
|
overlapping_r2 = 1.0
|
|
|
|
overlapping, r⃗₁₂, distance2 = ReCo.are_overlapping(
|
|
SVector(-0.4, 0.0), SVector(0.4, 0.0), overlapping_r2, half_box_len
|
|
)
|
|
@test overlapping == true
|
|
@test r⃗₁₂ ≈ SVector(0.8, 0.0)
|
|
@test distance2 ≈ 0.8^2
|
|
|
|
overlapping, r⃗₁₂, distance2 = ReCo.are_overlapping(
|
|
SVector(-0.6, 0.0), SVector(0.6, 0.0), overlapping_r2, half_box_len
|
|
)
|
|
@test overlapping == true
|
|
@test r⃗₁₂ ≈ SVector(-0.8, 0.0)
|
|
@test distance2 ≈ 0.8^2
|
|
|
|
overlapping_r2 = 0.5^2
|
|
overlapping, r⃗₁₂, distance2 = ReCo.are_overlapping(
|
|
SVector(-0.3, 0.0), SVector(0.3, 0.0), overlapping_r2, half_box_len
|
|
)
|
|
@test overlapping == false
|
|
@test r⃗₁₂ ≈ SVector(0.6, 0.0)
|
|
@test distance2 ≈ 0.6^2
|
|
end
|
|
end
|
|
|
|
@testset "Shape.jl" begin
|
|
n_particles = 10
|
|
v₀ = 0.0
|
|
sim_consts = ReCo.gen_sim_consts(n_particles, v₀)
|
|
|
|
@testset "gen_sim_consts" begin
|
|
@test sim_consts.n_particles == 16
|
|
end
|
|
|
|
half_box_len = sim_consts.half_box_len
|
|
|
|
@testset "project_to_unit_circle" begin
|
|
@test ReCo.Shape.project_to_unit_circle(0.0, half_box_len) ≈ SVector(-1.0, 0.0)
|
|
@test ReCo.Shape.project_to_unit_circle(half_box_len, half_box_len) ≈
|
|
ReCo.Shape.project_to_unit_circle(-half_box_len, half_box_len) ≈
|
|
SVector(1.0, 0.0)
|
|
end
|
|
|
|
particles = ReCo.gen_particles(
|
|
sim_consts.grid_n, sim_consts.grid_box_width, half_box_len
|
|
)
|
|
|
|
@testset "center_of_mass" begin
|
|
@test ReCo.Shape.center_of_mass(particles, half_box_len) ≈ SVector(0.0, 0.0)
|
|
end
|
|
|
|
@testset "gyration_tensor" begin
|
|
@test ReCo.Shape.gyration_tensor_eigvals_ratio(particles, half_box_len) == 1.0
|
|
end
|
|
end |