Skip to content

Commit ba81c92

Browse files
committed
add test for in_wignerseitz
1 parent 49b32d9 commit ba81c92

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

test/wignerseitz.jl

+27
Original file line numberDiff line numberDiff line change
@@ -171,4 +171,31 @@ end
171171
@test reduce_to_wignerseitz(r′′, Rs) r
172172
@test_throws DimensionMismatch reduce_to_wignerseitz(r′′[1:2], Rs)
173173
@test_throws DimensionMismatch reduce_to_wignerseitz(r′′, [Rs[1][1:3], Rs[2][1:3], Rs[3][1:2]])
174+
end
175+
176+
@testset "in_wignerseitz" begin
177+
Rs = convert(SVector{3,SVector{3,Float64}}, [[1.0,0,0], [-.5,3/2,0], [0,0,1.25]])
178+
cell = wignerseitz(Rs)
179+
vs = vertices(cell)
180+
181+
vs_inside = 0.9 * vs
182+
@test all(v->in_wignerseitz(v, cell), vs_inside) == true
183+
@test all(in_wignerseitz(vs_inside, cell)) == true
184+
185+
vs_outside = 1.1 * vs
186+
@test all(v->in_wignerseitz(v, cell), vs_outside) == false
187+
@test all(in_wignerseitz(vs_outside, cell)) == false
188+
189+
# points that are not simply related to a vertex points
190+
@test in_wignerseitz((@SVector [0.0,0.0,0.0]), cell) == true
191+
@test in_wignerseitz(([0.0,0.0,0.0]), cell) == true
192+
193+
vs_face = [0.3*vs[f[1]] + 0.2*vs[f[2]] + 0.5*vs[f[3]] for f in faces(cell)] # random points on each face
194+
@test all(v->in_wignerseitz(0.9 * v, cell), vs_face) == true
195+
@test all(in_wignerseitz(0.9 .* vs_face, cell)) == true
196+
@test all(v->in_wignerseitz(1.1 * v, cell), vs_face) == false
197+
@test all(in_wignerseitz(1.1 .* vs_face, cell)) == false
198+
199+
# we don't make guarantees about points on the boundary (face, edge, or vertex) of the
200+
# Wigner-Seitz cell, since this can't be done robustly without a tolerance
174201
end

0 commit comments

Comments
 (0)