Skip to content

Commit

Permalink
Fixes to BrillouinSpglibExt as suggested in #26 (#27)
Browse files Browse the repository at this point in the history
Update Spglib.jl and adjust to new API conventions in Spglib.jl.
  • Loading branch information
mfherbst authored Oct 18, 2023
1 parent 1aa1e32 commit e9821cb
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ PlotlyJS = "0.18"
Reexport = "1"
Requires = "1.1"
PrecompileTools = "1"
Spglib = "0.6"
Spglib = "0.8"
StaticArrays = "1.2"
julia = "1.6"

Expand Down
14 changes: 7 additions & 7 deletions ext/BrillouinSpglibExt.jl
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@ associated primitive cell is returned (in the basis of supercell reciprocal latt
function Brillouin.KPaths.irrfbz_path(cell::Spglib.Cell)
# extract a standardized primitive basis `pRs` assoc. w/ `cell` via Spglib
dset = Spglib.get_dataset(cell)
sgnum = dset.spacegroup_number
pRs = SVector{3}(SVector{3,Float64}(col) for col in eachcol(dset.std_lattice))
sgnum = Int(dset.spacegroup_number)
pRs = SVector{3}(Spglib.basisvectors(dset.std_lattice))

# print warning if the input cell is a supercell (without any distortion)
if !isapprox(det(cell.lattice), det(dset.primitive_lattice)) # check volumes agree
if !isapprox(det(parent(cell.lattice)), det(parent(dset.primitive_lattice))) # check volumes agree
@warn "The provided cell is a supercell: the returned k-path is the standard k-path " *
"of the associated primitive cell in the basis of the supercell reciprocal lattice." cell
end
Expand All @@ -40,17 +40,17 @@ function Brillouin.KPaths.irrfbz_path(cell::Spglib.Cell)
# of the lattice basis vectors.
# `transformation` is not used, but is commented here just for information. It can be
# obtained via
# `transformation = inv(primitivebasismatrix(centering(sgnum, 3))) * dset.transformation_matrix'`
# `transformation = inv(primitivebasismatrix(centering(sgnum, 3))) * dset.transformation_matrix`
rotation = dset.std_rotation_matrix

# Rotate k-points in Cartesian space by `rotation`
pRs_original = SVector{3}(SVector{3,Float64}(col) for col in eachcol(cell.lattice))
pRs_original = SVector{3}(Spglib.basisvectors(cell.lattice))
pGs_original = reciprocalbasis(pRs_original)
cartesianize!(kp)
for (lab, kv) in points(kp)
points(kp)[lab] = rotation * kv
points(kp)[lab] = rotation' * kv # transpose because k coords are in reciprocal space
end
return latticize(kp, pGs_original)
end

end # module BrillouinSpglibExt
end # module BrillouinSpglibExt

0 comments on commit e9821cb

Please sign in to comment.