1
0
Fork 0
mirror of https://gitlab.rlp.net/mobitar/ReCo.jl.git synced 2024-11-08 22:21:08 +00:00
ReCo.jl/test/runtests.jl

77 lines
2.4 KiB
Julia
Raw Normal View History

2021-12-15 03:45:15 +00:00
using Test
using ReCo
using StaticArrays: SVector
2021-12-16 13:54:52 +00:00
@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
2021-12-15 03:45:15 +00:00
@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
2021-12-15 19:50:18 +00:00
@testset "Shape.jl" begin
2021-12-15 03:45:15 +00:00
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
2021-12-15 19:50:18 +00:00
@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)
2021-12-15 03:45:15 +00:00
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
2021-12-15 19:50:18 +00:00
@test ReCo.Shape.center_of_mass(particles, half_box_len) SVector(0.0, 0.0)
2021-12-15 03:45:15 +00:00
end
@testset "gyration_tensor" begin
2021-12-15 19:50:18 +00:00
@test ReCo.Shape.gyration_tensor_eigvals_ratio(particles, half_box_len) == 1.0
2021-12-15 03:45:15 +00:00
end
2022-03-19 22:11:03 +00:00
end