From 99c593c3279a130db2d95276fc0cc57eeecfc987 Mon Sep 17 00:00:00 2001 From: qzhu Date: Fri, 14 Jan 2022 18:54:40 -0800 Subject: [PATCH] fix lattice bug --- pyxtal/__init__.py | 9 +++++---- pyxtal/lattice.py | 11 +++++++---- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/pyxtal/__init__.py b/pyxtal/__init__.py index a57635f2..e60dd642 100644 --- a/pyxtal/__init__.py +++ b/pyxtal/__init__.py @@ -1506,9 +1506,10 @@ def _get_alternative(self, wyc_sets, index, ref_cell=None): if pos1 is not None: new_struc.atom_sites[i] = atom_site(wp, pos1, site.specie) else: - print(pos) - print(wp) - raise RuntimeError("Cannot find the right pos") + return None + #print(pos) + #print(wp) + #raise RuntimeError("Cannot find the right pos") new_struc.source = "Alt. Wyckoff Set [{:d}]: {:s}".format(index, xyz_string) new_struc.wyc_set_id = index @@ -2035,7 +2036,7 @@ def get_transition_by_path(self, ref_struc, path, d_tol, d_tol2=0.5, N_images=2) for label in site: try: index = string.ascii_lowercase.index(label[-1]) - except ValueError: #8A + except ValueError: #'8A' index = 26 _site.extend(relation[index]) _sites0.append(_site) diff --git a/pyxtal/lattice.py b/pyxtal/lattice.py index 86746d6b..993fb2f5 100644 --- a/pyxtal/lattice.py +++ b/pyxtal/lattice.py @@ -223,10 +223,13 @@ def search_transformation(self, lat_ref, d_tol=1.0, f_tol=0.1): for j, tran2 in enumerate(trans2): tmp = np.dot(tran2, lat0.matrix) - cell2 = Lattice.from_matrix(tmp, l_type=self.ltype).matrix - diff = np.abs(cell1-cell2).flatten() - id = np.argmax(diff) - d_tol1, f_tol1 = diff[id], diff[id]/abs(cell1.flatten()[id]) + try: + cell2 = Lattice.from_matrix(tmp, l_type=self.ltype).matrix + diff = np.abs(cell1-cell2).flatten() + id = np.argmax(diff) + d_tol1, f_tol1 = diff[id], diff[id]/abs(cell1.flatten()[id]) + except: + d_tol1, f_tol1 = 10, 1.0 tols[j, :] = [d_tol1, f_tol1] #print([d_tol1, f_tol1]) #print(tols)