Skip to content

Commit

Permalink
resolve #153
Browse files Browse the repository at this point in the history
  • Loading branch information
qzhu2017 committed Jul 25, 2021
1 parent 4bdbec1 commit fb778d2
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 9 deletions.
2 changes: 1 addition & 1 deletion pyxtal/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -918,7 +918,7 @@ def get_zprime(self, integer=False):
mult = len(self.group[0])
comp = [c/mult for c in self.numMols]
if integer:
comp = [int(c) for c in comp]
comp = [int(np.ceil(c)) for c in comp]
return comp

def get_num_torsions(self):
Expand Down
9 changes: 4 additions & 5 deletions pyxtal/io.py
Original file line number Diff line number Diff line change
Expand Up @@ -281,21 +281,20 @@ def resort(self, molecules):
self.p_mols = []
self.wps = []
ids_done = []
for j, mol2 in enumerate(self.ref_mols):
if self.add_H:
mol2.mol.remove_species("H")
for j, mol2_ref in enumerate(self.ref_mols):
mol2 = mol2_ref.copy()
if self.add_H: mol2.mol.remove_species("H")

for i, id in enumerate(ids):
p_mol = mol2.copy() # create p_mol
mol1 = molecules[id]
if id not in ids_done and len(mol2.mol) == len(mol1):
p_mol = mol2_ref.copy() # create p_mol
match, mapping = compare_mol_connectivity(mol2.mol, mol1)
if match:
self.numMols[j] += mults[i]
if len(mol1) > 1:
# rearrange the order
order = [mapping[at] for at in range(len(mol1))]

xyz = mol1.cart_coords[order]
# add hydrogen positions here
if self.add_H: xyz = self.add_Hydrogens(mol2.smile, xyz)
Expand Down
6 changes: 5 additions & 1 deletion pyxtal/representation.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ def from_string(cls, inputs, smiles, composition=None):

x = [cell]
n_site = int(inputs[n_cell])
if n_site != sum(composition) :
if n_site != sum(composition):
msg = "Composition is inconsistent: {:d}/{:d}\n".format(sum(composition), n_site)
msg += str(inputs)
raise ValueError(msg)
Expand Down Expand Up @@ -126,6 +126,10 @@ def to_pyxtal(self, smiles=None, composition=None):
a, b, c, alpha, beta, gamma = v[2], v[3], v[4], 90, 90, 90
elif ltype == 'tetragonal':
a, b, c, alpha, beta, gamma = v[2], v[2], v[3], 90, 90, 90
elif ltype == 'hexagonal':
a, b, c, alpha, beta, gamma = v[2], v[2], v[3], 90, 90, 120
else:
a, b, c, alpha, beta, gamma = v[2], v[2], v[2], 90, 90, 90
struc.lattice = Lattice.from_para(a, b, c, alpha, beta, gamma, ltype=ltype)

# sites
Expand Down
5 changes: 3 additions & 2 deletions pyxtal/wyckoff_site.py
Original file line number Diff line number Diff line change
Expand Up @@ -182,8 +182,8 @@ def from_1D_dicts(cls, dicts):
#print(conf.GetPositions()[:3]); print(dicts["rotor"])
if dicts['reflect']:
mol.set_torsion_angles(conf, dicts["rotor"], False)
# print(mol.set_torsion_angles(conf, dicts["rotor"], True))
# #import sys; sys.exit()
#print(mol.set_torsion_angles(conf, dicts["rotor"], True))
#import sys; sys.exit()
xyz = mol.set_torsion_angles(conf, dicts["rotor"], dicts['reflect'])
mol.reset_positions(xyz)
g = dicts["number"]
Expand All @@ -199,6 +199,7 @@ def from_1D_dicts(cls, dicts):
diag = dicts["diag"]
lattice = Lattice.from_matrix(dicts["lattice"], ltype=dicts["lattice_type"])
position = dicts["center"] #np.dot(dicts["center"], lattice.inv_matrix)
position, wp, _ = WP_merge(position, lattice.matrix, wp, 0.01)

return cls(mol, position, orientation, wp, lattice, diag)

Expand Down

0 comments on commit fb778d2

Please sign in to comment.