Skip to content

Commit

Permalink
Merge pull request #177 from singularitti:singularitti/issue176
Browse files Browse the repository at this point in the history
Fix wyckoffs in dataset
  • Loading branch information
singularitti committed Dec 19, 2023
2 parents 180e984 + 0ede852 commit 7d98c74
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/core.jl
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ export Lattice,
atomtypes

const basis_vectors = basisvectors # For backward compatibility
const WYCKOFF_LETTERS = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ" # See https://github.com/spglib/spglib/blob/v2.2.0/python/spglib/spglib.py#L364

"""
SpglibCell(lattice, positions, atoms, magmoms=[])
Expand Down Expand Up @@ -349,7 +350,7 @@ function Dataset(dataset::SpglibDataset)
unsafe_load(dataset.translations, i) for i in Base.OneTo(dataset.n_operations)
)
wyckoffs = unsafe_wrap(Vector{Int32}, dataset.wyckoffs, dataset.n_atoms)
wyckoffs = [('a':'z')[w + 1] for w in wyckoffs] # Need to add 1 because of C-index starts from 0
wyckoffs = [WYCKOFF_LETTERS[w + 1] for w in wyckoffs] # Need to add 1 because of C-index starts from 0
site_symmetry_symbols = tostring.(
unsafe_load(dataset.site_symmetry_symbols, i) for i in Base.OneTo(dataset.n_atoms)
)
Expand Down
20 changes: 20 additions & 0 deletions test/symmetry.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1543,3 +1543,23 @@ end
@test get_dataset_with_hall_number(cell, dataset.hall_number) == dataset
@test get_schoenflies(cell, 1e-5) == "C6v^4"
end

@testset "Test issue 176" begin # See https://github.com/singularitti/Spglib.jl/issues/176
lattice = [6.42 0 0; 0.0 6.41 0; 0.0 0.0 6.44]
x = 0.79
y = 1 - x
positions = [
[y, y, x],
[y, x, y],
[x, y, y],
[x, x, x],
[x, x, y],
[x, y, x],
[y, x, x],
[y, y, y],
]
atoms = ["Ga", "Ga", "Ga", "Ga", "Ga", "Ga", "Ga", "Ga"]
cell = Cell(lattice, positions, atoms)
dataset = get_dataset(cell)
@test dataset.wyckoffs == ['A', 'A', 'A', 'A', 'A', 'A', 'A', 'A'] # Compared with Python results
end

0 comments on commit 7d98c74

Please sign in to comment.