-
Notifications
You must be signed in to change notification settings - Fork 83
/
spglib.jl
73 lines (63 loc) · 3 KB
/
spglib.jl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
using DFTK: spglib_spacegroup_number, spglib_standardize_cell
using LinearAlgebra
using Test
@testset "spglib" begin
a = 10.3
Si = ElementPsp(:Si, psp=load_psp("hgh/lda/Si-q4"))
Ge = ElementPsp(:Ge, psp=load_psp("hgh/lda/Ge-q4"))
# silicon
lattice = a / 2 * [[0 1 1.]; [1 0 1.]; [1 1 0.]]
atoms = [Si => [ones(3)/8, -ones(3)/8]]
model = model_LDA(lattice, atoms)
@test spglib_spacegroup_number(model) == 227
@test spglib_standardize_cell(model).lattice ≈ a * I(3)
# silicon with Cartesian x coordinates flipped
lattice = a / 2 * [[0 -1 -1.]; [1 0 1.]; [1 1 0.]]
atoms = [Si => [ones(3)/8, -ones(3)/8]]
model = model_LDA(lattice, atoms)
@test spglib_spacegroup_number(model) == 227
@test spglib_standardize_cell(model).lattice ≈ a * I(3)
# silicon with different lattice vectors
lattice = a / 2 * [[0 1 1.]; [-1 0 1.]; [-1 1 0.]]
atoms = [Si => [[-1, 1, 1]/8, -[-1, 1, 1]/8]]
model = model_LDA(lattice, atoms)
@test spglib_spacegroup_number(model) == 227
@test spglib_standardize_cell(model).lattice ≈ a * I(3)
# Zincblende structure
lattice = a / 2 * [[0 1 1.]; [1 0 1.]; [1 1 0.]]
atoms = [Si => [ones(3)/8], Ge => [-ones(3)/8]]
model = model_LDA(lattice, atoms)
@test spglib_spacegroup_number(model) == 216
@test spglib_standardize_cell(model).lattice ≈ a * I(3)
# Zincblende structure with Cartesian x coordinates flipped
lattice = a / 2 * [[0 -1 -1.]; [1 0 1.]; [1 1 0.]]
atoms = [Si => [ones(3)/8], Ge => [-ones(3)/8]]
model = model_LDA(lattice, atoms)
@test spglib_spacegroup_number(model) == 216
@test spglib_standardize_cell(model).lattice ≈ a * I(3)
# Zincblende structure with different lattice vectors
lattice = a / 2 * [[0 1 1.]; [-1 0 1.]; [-1 1 0.]]
atoms = [Si => [[-1, 1, 1]/8], Ge => [-[-1, 1, 1]/8]]
model = model_LDA(lattice, atoms)
@test spglib_spacegroup_number(model) == 216
@test spglib_standardize_cell(model).lattice ≈ a * I(3)
# Hexagonal close packed lattice
lattice = a * [[1. -1/2 0.]; [0. sqrt(3)/2 0.]; [0. 0. sqrt(8/3)]]
atoms = [Si => [[0, 0, 0], [1/3, 2/3, 1/2]]]
model = model_LDA(lattice, atoms)
@test spglib_spacegroup_number(model) == 194
@test spglib_standardize_cell(model).lattice ≈ lattice
# Hexagonal close packed lattice with x coordinates flipped
lattice = a * [[-1. 1/2 0.]; [0. sqrt(3)/2 0.]; [0. 0. sqrt(8/3)]]
atoms = [Si => [[0, 0, 0], [1/3, 2/3, 1/2]]]
model = model_LDA(lattice, atoms)
@test spglib_spacegroup_number(model) == 194
@test !(spglib_standardize_cell(model).lattice ≈ lattice)
# Hexagonal close packed lattice with different lattice vectors
lattice = a * [[-1. -1/2 0.]; [0. sqrt(3)/2 0.]; [0. 0. sqrt(8/3)]]
atoms = [Si => [[0, 0, 0], [-1/3, 2/3, 1/2]]]
model = model_LDA(lattice, atoms)
@test spglib_spacegroup_number(model) == 194
@test ( spglib_standardize_cell(model).lattice
≈ a * [[1. -1/2 0.]; [0. sqrt(3)/2 0.]; [0. 0. sqrt(8/3)]])
end