Skip to content

Commit

Permalink
Add identify_symmetry stub
Browse files Browse the repository at this point in the history
  • Loading branch information
Liozou committed Jul 29, 2022
1 parent e7b5ff0 commit 799392d
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions src/symmetries.jl
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,7 @@ function get_spglib_dataset(pge::PeriodicGraphEmbedding3D{T}, vtypes=nothing) wh
ptr = ccall((:spg_get_dataset, libsymspg), Ptr{SpglibDataset},
(Ptr{Cdouble}, Ptr{Cdouble}, Ptr{Cint}, Cint, Cdouble),
lattice, positions, types, n, T <: Rational ? 10*eps(Cdouble) : 0.0001)
ptr == Ptr{PeriodicGraphEmbeddings.SpglibDataset}() && return nothing # failure
dataset = unsafe_load(ptr)
# if dataset.n_atoms != n
# error("The periodic graph is not minimal") # TODO: update pge?
Expand Down Expand Up @@ -409,3 +410,18 @@ function find_symmetries(pge::PeriodicGraphEmbedding3D{T}, vtypes=nothing, check
end
return SymmetryGroup3D{T}(vmaps, rots, transs, hasmirror, length(pge.pos))
end

function identify_symmetry(x::SymmetryGroup3D)
n = length(x.eqs)
rotations = Array{Cint}(undef, 3, 3, n+1)
translations = Array{Cdouble}(undef, 3, n+1)
rotations[:,:,1] .= [1 0 0; 0 1 0; 0 0 1]
translations[:,1] .= [0, 0, 0]
for (i, eq) in enumerate(x.eqs)
i > n && break
rotations[:,:,i+1] .= transpose(eq.mat)
translations[:,i+1] .= eq.ofs
end
return ccall((:spg_get_hall_number_from_symmetry, libsymspg), Cint,
(Ptr{Cint}, Ptr{Cdouble}, Cint, Cdouble), rotations, translations, n, 1e-7)
end

0 comments on commit 799392d

Please sign in to comment.