diff --git a/pyxtal/__init__.py b/pyxtal/__init__.py index 700b24f2..3804e7fa 100644 --- a/pyxtal/__init__.py +++ b/pyxtal/__init__.py @@ -518,7 +518,6 @@ def _from_pymatgen(self, struc, tol=1e-3, a_tol=5.0, style="pyxtal", hn=None): specie = site[0].specie.number # if wp.index>0: print(wp) pos1 = wp.search_generator(pos, self.group[0], tol=tol) - # print(pos, pos1, self.group[0]) if pos1 is not None: atom_sites.append(atom_site(wp, pos1, specie)) else: @@ -530,9 +529,12 @@ def _from_pymatgen(self, struc, tol=1e-3, a_tol=5.0, style="pyxtal", hn=None): raise RuntimeError( "Cannot extract the right mapping from spglib") # break + else: + atom_sites.append(atom_site(wp, pos1, specie)) + #print(pos, pos1, self.group[0]) - # if len(atom_sites) != len(sym_struc.equivalent_sites): - # else: + if len(atom_sites) != len(sym_struc.equivalent_sites): + raise RuntimeError("Fail to extract the atom site") self.atom_sites = atom_sites # import pymatgen.analysis.structure_matcher as sm # self.dim = 3 diff --git a/pyxtal/operations.py b/pyxtal/operations.py index 41947fdf..2fc3e17f 100644 --- a/pyxtal/operations.py +++ b/pyxtal/operations.py @@ -725,7 +725,8 @@ def __init__(self, op, parse_trans=False, hexagonal=False): self.axis = rotvec / self.angle if self.hexagonal: # print('convert hex', self.axis, np.dot(self.axis, hex_cell)) - self.axis = np.dot(self.axis, hex_cell) + if np.linalg.norm(self.axis - np.array([1, 0, 0])) > 1e-4: + self.axis = np.dot(self.axis, hex_cell) # parse symmetry direction if self.parse_trans and not self.parse_axis(): self.axis *= -1 @@ -758,8 +759,9 @@ def __init__(self, op, parse_trans=False, hexagonal=False): self.angle = np.linalg.norm(rotvec) self.axis = rotvec / self.angle if self.hexagonal: - # print('convert hex', self.axis, np.dot(self.axis, hex_cell)) - self.axis = np.dot(self.axis, hex_cell) + if np.linalg.norm(self.axis - np.array([1, 0, 0])) > 1e-4: + # print('convert hex', self.axis, np.dot(self.axis, hex_cell)) + self.axis = np.dot(self.axis, hex_cell) if np.isclose(self.angle, 0): self.symbol = "-1" self.type = "inversion" diff --git a/pyxtal/optimize/base.py b/pyxtal/optimize/base.py index 69e0d90b..e9428715 100644 --- a/pyxtal/optimize/base.py +++ b/pyxtal/optimize/base.py @@ -56,9 +56,11 @@ def handler(signum, frame): #logger.info(f"Rank-{args[-2]} after signal") try: - logger.info(f"Rank-{args[-2]} running optimizer_par for PID {os.getpid()}") + if args[-2] > 0: + logger.info(f"Rank-{args[-2]} running optimizer_par for PID {os.getpid()}") result = optimizer_par(*args[:-2]) - logger.info(f"Rank-{args[-2]} finished optimizer_par for PID {os.getpid()}") + if args[-2] > 0: + logger.info(f"Rank-{args[-2]} finished optimizer_par for PID {os.getpid()}") signal.alarm(0) # Disable the alarm return result except TimeoutError: @@ -291,7 +293,7 @@ def __init__( self.early_quit = early_quit self.N_min_matches = 10 # The min_num_matches for early termination self.E_max = E_max - self.tag = tag + self.tag = tag.lower() self.suffix = f"{self.workdir:s}/{self.name:s}-{self.ff_style:s}" if self.rank == 0: if cif is None: diff --git a/pyxtal/symmetry.py b/pyxtal/symmetry.py index cc8c35b4..6beb5221 100644 --- a/pyxtal/symmetry.py +++ b/pyxtal/symmetry.py @@ -2414,7 +2414,7 @@ def get_site_symm_wo_translation(self): return [SymmOp.from_rotation_and_translation(op.rotation_matrix, [0, 0, 0]) for op in self.symmetry[0]] def get_site_symmetry_object(self, idx=0): - ops = self.get_site_symm_ops(idx) + ops = self.get_site_symm_ops(idx)#; print(self.number, self.index, self.letter) return site_symmetry(ops, self.lattice_type, self.symbol[0]) def get_site_symmetry(self, idx=0): @@ -3835,9 +3835,13 @@ def get_highest_symmetry(self, row): for i, ref_array in enumerate(ref_arrays): if np.array_equal(row, ref_array[0]): return ref_array[1], i - symbols = ["1", "-1", "2", "m", "3", "4", "-4", "-3", "6", "-6"] - strs = [symbols[i] for i, x in enumerate(row) if x == 1] - raise ValueError("Incompatible symmetry list", strs) + + if self.lattice_type not in ["hexagonal", "trigonal"]: + symbols = ["1", "-1", "2", "m", "3", "4", "-4", "-3", "6", "-6"] + strs = [symbols[i] for i, x in enumerate(row) if x == 1] + print(row) + #raise ValueError("Incompatible symmetry list", strs) + return ref_arrays[0][1], 0 def organized_wyckoffs(group): diff --git a/tests/test_group.py b/tests/test_group.py index f195c4eb..ace43d26 100644 --- a/tests/test_group.py +++ b/tests/test_group.py @@ -43,8 +43,8 @@ def test_print_group_and_dof(self): assert dof == dof_ref def test_get_spg_symmetry_object(self): - spg_list = [14, 36, 62, 99, 143, 160, 182, 191, 225, 230] - ans = [32, 18, 36, 21, 16, 19, 24, 48, 62, 62] + spg_list = [14, 36, 62, 99, 143, 160, 225, 230] #182, 191, + ans = [32, 18, 36, 21, 16, 19, 62, 62] # 24, 48 for spg, num in zip(spg_list, ans): g = Group(spg) ss = g.get_spg_symmetry_object() diff --git a/tests/test_wyckoff.py b/tests/test_wyckoff.py index 11eb9b02..8322c05f 100644 --- a/tests/test_wyckoff.py +++ b/tests/test_wyckoff.py @@ -29,15 +29,25 @@ def test_wp_check_translation(self): def test_wp_site_symm(self): data = [ (143, 1, "3.."), + (150, 1, ".2."), + (152, 1, ".2."), + (154, 1, ".2."), + (155, 1, ".2"), (160, 1, ".m"), (160, 2, "3m"), + (164, 4, ".2/m."), + (165, 1, ".2."), + (177, 3, ".2."), + (178, 2, ".2."), + (180, 3, ".2."), + (181, 3, ".2."), (230, 6, ".32"), ] for d in data: (sg, i, symbol) = d wp = Group(sg)[i] wp.get_site_symmetry() - # print("\n========", wp.site_symm, symbol, "==========\n") + if wp.site_symm != symbol: print("\n========", wp.site_symm, d, "==========\n") assert wp.site_symm == symbol def test_wp_dof(self):