Skip to content

Commit 1879a08

Browse files
committed
allow mutliple sites with the same label #310
1 parent 62080b7 commit 1879a08

File tree

3 files changed

+29
-6
lines changed

3 files changed

+29
-6
lines changed

doc/Usage.rst

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -887,7 +887,7 @@ O atoms.
887887
"4g": [0.1294, 0.6392, 0.0000],
888888
},
889889
{"4g": [0.2458, 0.2522, 0.0000]},
890-
{"4g": [0.4241, 0.3636, 0.0000]}, #partial information on O sites
890+
{"4g": [[0.4241, 0.3636, 0.0000], [0.5538, 0.2648, 0.0000]]}, #partial information on O sites
891891
]
892892
893893
s = pyxtal()
@@ -903,10 +903,11 @@ O atoms.
903903
Al @ [ 0.0000 0.0000 0.2418], WP [4e] Site [..2]
904904
Al @ [ 0.1294 0.6392 0.0000], WP [4g] Site [..m]
905905
Si @ [ 0.2458 0.2522 0.0000], WP [4g] Site [..m]
906-
O @ [ 0.4241 0.3636 0.0000], WP [4g] Site [..m]
907-
O @ [ 0.5538 0.2648 0.0000], WP [4g] Site [..m]
908-
O @ [ 0.0000 0.5000 0.6057], WP [4f] Site [..2]
909-
O @ [ 0.8809 0.5970 0.0786], WP [8h] Site [1]
906+
O @ [ 0.4241 0.3636 0.0000], WP [4g] Site [..m]
907+
O @ [ 0.5538 0.2648 0.0000], WP [4g] Site [..m]
908+
O @ [ 0.0000 0.0000 0.5000], WP [2b] Site [..2/m]
909+
O @ [ 0.0000 0.5000 0.0000], WP [2c] Site [..2/m]
910+
O @ [ 0.4348 0.6979 0.2566], WP [8h] Site [1]
910911
911912
912913
Similarly, PyXtal allows the user to pre-assign the partial information (e.g.,

pyxtal/crystal.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,11 @@ def set_sites(self, sites):
161161
for item in sites[i].items():
162162
# keep the record of wp index
163163
id = self.group.get_index_by_letter(item[0])
164-
self.sites[specie].append((id, item[1]))
164+
if isinstance(item[1][0], list):
165+
for it in range(len(item[1])):
166+
self.sites[specie].append((id, item[1][it]))
167+
else:
168+
self.sites[specie].append((id, item[1]))
165169
elif isinstance(sites[i], (list, tuple)):
166170
for site in sites[i]:
167171
if type(site) is tuple:

tests/test_crystal.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,24 @@ def test_atomic(self):
3333

3434

3535
class TestAtomic3D(unittest.TestCase):
36+
37+
def test_partial(self):
38+
cell = Lattice.from_para(7.8758, 7.9794, 5.6139, 90, 90, 90, ltype='orthorhombic')
39+
spg = 58
40+
elements = ['Al', 'Si', 'O']
41+
composition = [8, 4, 20]
42+
43+
sites = [{"4e": [0.0000, 0.0000, 0.2418],
44+
"4g": [0.1294, 0.6392, 0.0000],
45+
},
46+
{"4g": [0.2458, 0.2522, 0.0000]},
47+
{"4g": [[0.4241, 0.3636, 0.0000], [0.5538, 0.2648, 0.0000]]},
48+
]
49+
50+
s = pyxtal()
51+
s.from_random(3, spg, elements, composition, lattice=cell, sites=sites)
52+
assert s.valid
53+
3654
def test_single_specie(self):
3755
struc = pyxtal()
3856
struc.from_random(3, 225, ["C"], [4], 1.2, conventional=False)

0 commit comments

Comments
 (0)