diff --git a/pyxtal/__init__.py b/pyxtal/__init__.py index 0c0d80a1..17248535 100644 --- a/pyxtal/__init__.py +++ b/pyxtal/__init__.py @@ -3649,16 +3649,22 @@ def from_tabular_representation(self, rep, max_abc=50.0, max_angle=180, normaliz np.degrees(beta), np.degrees(gamma), ) - lattice = Lattice.from_para( - a, - b, - c, - alpha, - beta, - gamma, - ltype=group.lattice_type, - force_symmetry=True, - ) + try: + lattice = Lattice.from_para( + a, + b, + c, + alpha, + beta, + gamma, + ltype=group.lattice_type, + force_symmetry=True, + ) + except ValueError: + print('Input lattice from rep is incorrect', number, a, b, c, alpha, beta, gamma) + self.valid = False + return + sites_info = np.reshape(rep[7:], (int((len(rep) - 7) / 4), 4)) sites = [] numIons = 0 diff --git a/tests/test_crystal.py b/tests/test_crystal.py index e4929643..a251b229 100644 --- a/tests/test_crystal.py +++ b/tests/test_crystal.py @@ -93,6 +93,15 @@ def test_read_by_HN(self): pmg_struc = struc.to_pymatgen() assert sm.StructureMatcher().fit(pmg_struc, pmg1) + def test_from_tabular(self): + xtal = pyxtal() + rep = [116,10.5754,10.7203,4.47208,1.5705,2.6561,2.0943,1,0.4447,0.3762,0.7526] + xtal.from_tabular_representation(rep, normalize=False) + assert xtal.valid == False + rep = [116,10.5754,10.7203,4.47208,1.5705,1.5705,1.5705,0,0.4447,0.3762,0.7526] + xtal.from_tabular_representation(rep, normalize=False) + assert xtal.valid == True + class TestAtomic2D(unittest.TestCase): def test_single_specie(self):