Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes to BrillouinSpglibExt as suggested in #26 #27

Merged
merged 5 commits into from
Oct 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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