Skip to content

Commit 2c9fe4d

Browse files
authored
Remove collinear spin c-interface, which is now native in spglib (#924)
1 parent c830fdf commit 2c9fe4d

File tree

2 files changed

+2
-34
lines changed

2 files changed

+2
-34
lines changed

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ Requires = "1"
9696
Roots = "2"
9797
SparseArrays = "1"
9898
SpecialFunctions = "2"
99-
Spglib = "0.8.5"
99+
Spglib = "0.9"
100100
StaticArrays = "1"
101101
Statistics = "1"
102102
TimerOutputs = "0.5.12"

src/symmetry.jl

Lines changed: 1 addition & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -64,36 +64,6 @@ function symmetry_operations(hall_number::Integer)
6464
[SymOp(W, w) for (W, w) in zip(Ws, ws)]
6565
end
6666

67-
# Temporary workaround until Spglib.jl exports this function
68-
function spglib_get_symmetry_with_collinear_spin(cell::Spglib.SpglibCell, symprec=1e-5)
69-
lattice, positions, atoms, spins = Spglib._unwrap_convert(cell)
70-
num_atom = length(cell.magmoms)
71-
# See https://github.com/spglib/spglib/blob/42527b0/python/spglib/spglib.py#L270
72-
max_size = 96num_atom # 96 = 48 × 2 since we have spins
73-
rotations = Array{Cint,3}(undef, 3, 3, max_size)
74-
translations = Matrix{Cdouble}(undef, 3, max_size)
75-
equivalent_atoms = Vector{Cint}(undef, num_atom)
76-
num_sym = @ccall Spglib.libsymspg.spg_get_symmetry_with_collinear_spin(
77-
rotations::Ptr{Cint},
78-
translations::Ptr{Cdouble},
79-
equivalent_atoms::Ptr{Cint},
80-
max_size::Cint,
81-
lattice::Ptr{Cdouble},
82-
positions::Ptr{Cdouble},
83-
atoms::Ptr{Cint},
84-
spins::Ptr{Cdouble},
85-
num_atom::Cint,
86-
symprec::Cdouble,
87-
)::Cint
88-
Spglib.check_error()
89-
rotations = map(
90-
SMatrix{3,3,Int32,9} transpose, eachslice(rotations[:, :, 1:num_sym]; dims=3)
91-
) # Remember to transpose, see https://github.com/singularitti/Spglib.jl/blob/8aed6e0/src/core.jl#L195-L198
92-
translations = map(SVector{3,Float64}, eachcol(translations[:, 1:num_sym]))
93-
return rotations, translations, equivalent_atoms
94-
end
95-
96-
9767
@doc raw"""
9868
Return the symmetries given an atomic structure with optionally designated magnetic moments
9969
on each of the atoms. The symmetries are determined using spglib.
@@ -119,9 +89,7 @@ on each of the atoms. The symmetries are determined using spglib.
11989
if spin_polarization == :none
12090
Spglib.get_symmetry(cell, tol_symmetry)
12191
elseif spin_polarization == :collinear
122-
# rotations, translations, _ = Spglib.get_symmetry_with_collinear_spin(cell, tol_symmetry)
123-
rotations, translations, _ = spglib_get_symmetry_with_collinear_spin(cell, tol_symmetry)
124-
rotations, translations
92+
Spglib.get_symmetry_with_collinear_spin(cell, tol_symmetry)
12593
end
12694
catch e
12795
if e isa Spglib.SpglibError

0 commit comments

Comments
 (0)