diff --git a/Project.toml b/Project.toml index 583ad9e577..5eb97432bc 100644 --- a/Project.toml +++ b/Project.toml @@ -81,13 +81,14 @@ PseudoPotentialIO = "0.1" Requires = "1" Roots = "2" SpecialFunctions = "2" -Spglib = "0.6, 0.7, 0.8" +Spglib = "0.8" StaticArrays = "1" +Statistics = "1" TimerOutputs = "0.5.12" Unitful = "1" UnitfulAtomic = "1" julia = "1.7" -spglib_jll = "1.15" +spglib_jll = "2" [extras] ASEconvert = "3da9722f-58c2-4165-81be-b4d7253e8fd2" diff --git a/src/external/spglib.jl b/src/external/spglib.jl index f13054d5a3..a92d988dc5 100644 --- a/src/external/spglib.jl +++ b/src/external/spglib.jl @@ -48,13 +48,14 @@ function spglib_atoms(atom_groups, end end + @assert !arbitrary_spin # Not yet supported collinear = !arbitrary_spin && !all(iszero, spg_spins) (; positions=spg_positions, numbers=spg_numbers, spins=spg_spins, collinear) end function spglib_cell(lattice, atom_groups, positions, magnetic_moments) spg = spglib_atoms(atom_groups, positions, magnetic_moments) - (; cell=Spglib.Cell(lattice, spg.positions, spg.numbers, spg.spins), spg.collinear) + Spglib.SpglibCell(lattice, spg.positions, spg.numbers, spg.spins) end function spglib_cell(model::Model, magnetic_moments) spglib_cell(model.lattice, model.atom_groups, model.positions, magnetic_moments) @@ -165,8 +166,8 @@ function spglib_standardize_cell(lattice::AbstractArray{T}, atom_groups, positio # https://github.com/JuliaMolSim/DFTK.jl/pull/496/files#r725203554 # Essentially this does not influence the standardisation, # but it only influences the kpath. - cell, _ = spglib_cell(lattice, atom_groups, positions, magnetic_moments) - std_cell = Spglib.standardize_cell(cell; to_primitive=primitive, symprec=tol_symmetry, + cell = spglib_cell(lattice, atom_groups, positions, magnetic_moments) + std_cell = Spglib.standardize_cell(cell, tol_symmetry; to_primitive=primitive, no_idealize=!correct_symmetry) lattice = Matrix{T}(std_cell.lattice) @@ -180,9 +181,12 @@ function spglib_standardize_cell(model::Model, magnetic_moments=[]; kwargs...) end -function spglib_spacegroup_number(model, magnetic_moments=[]; tol_symmetry=SYMMETRY_TOLERANCE) +function spglib_spacegroup_number(model::Model, magnetic_moments=[]; tol_symmetry=SYMMETRY_TOLERANCE) # Get spacegroup number according to International Tables for Crystallography (ITA) # TODO Time-reversal symmetry disabled? (not yet available in DFTK) - cell, _ = spglib_cell(model, magnetic_moments) - Spglib.get_spacegroup_number(cell, tol_symmetry) + spglib_dataset(model, magnetic_moments; tol_symmetry).spacegroup_number +end + +function spglib_dataset(model::Model, magnetic_moments=[]; tol_symmetry=SYMMETRY_TOLERANCE) + Spglib.get_dataset(spglib_cell(model, magnetic_moments), tol_symmetry) end diff --git a/test/external/spglib.jl b/test/external/spglib.jl index dab2fde89d..61c39fb87d 100644 --- a/test/external/spglib.jl +++ b/test/external/spglib.jl @@ -1,3 +1,4 @@ +using DFTK using DFTK: spglib_spacegroup_number, spglib_standardize_cell using LinearAlgebra using Test