Skip to content

Commit f3513d4

Browse files
committed
update the subgroup func
1 parent a8e5c55 commit f3513d4

3 files changed

Lines changed: 26 additions & 27 deletions

File tree

pyxtal/__init__.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1992,7 +1992,7 @@ def has_special_site(self, species=None):
19921992
break
19931993
return special
19941994

1995-
def to_subgroup(self, path=None, t_only=True, iterate=False, species=None):
1995+
def to_subgroup(self, path=None, t_only=True, iterate=False, species=None, verbose=False):
19961996
"""
19971997
Transform a crystal with special sites to a subgroup representation with general sites.
19981998
@@ -2001,6 +2001,7 @@ def to_subgroup(self, path=None, t_only=True, iterate=False, species=None):
20012001
t_only (bool): Whether to use only translationengleiche (t) transitions. Defaults to True.
20022002
iterate (bool): Whether to transform iteratively until all sites are general. Defaults to False.
20032003
species (list, optional): List of atomic species to transform. Defaults to None.
2004+
verbose (bool): Whether to print detailed information during transformation. Defaults to False.
20042005
20052006
Returns:
20062007
pyxtal: A new pyxtal structure in the subgroup setting with general Wyckoff positions
@@ -2025,11 +2026,9 @@ def to_subgroup(self, path=None, t_only=True, iterate=False, species=None):
20252026
max_index = max(
20262027
[site.wp.index for site in sites if site.specie in species])
20272028
# print([site.wp.index for site in sites])
2028-
if self.molecular:
2029-
path = self.group.short_path_to_general_wp(max_index, t_only)
2030-
else:
2031-
path = self.group.short_path_to_general_wp(max_index, t_only)
2032-
# print(max_index, path)
2029+
2030+
path = self.group.short_path_to_general_wp(max_index, t_only)
2031+
if verbose: print("Identified path", path)
20332032

20342033
if path is not None:
20352034
gtypes, ids = [], []

pyxtal/molecule.py

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -248,11 +248,11 @@ class pyxtal_molecule:
248248
mol (str or pymatgen.Molecule): The molecule representation, either as a string
249249
(SMILES or filename) or as a pymatgen `Molecule` object.
250250
tm (Tol_matrix, optional): A tolerance matrix object, used for molecular tolerances.
251-
symmetrize (bool, optional): Whether to symmetrize the molecule using its point group.
251+
symmetrize (bool, optional): Whether to symmetrize the molecule by point group.
252252
fix (bool, optional): Fix torsions in the molecule.
253253
torsions (list, optional): List of torsions to analyze or fix.
254254
seed (int, optional): Random seed for internal processes. Defaults to a hex seed.
255-
random_state (int or numpy.Generator, optional): Numpy random state for random number generation.
255+
random_state (int or numpy.Generator, optional): state for random number generation.
256256
symtol (float, optional): Symmetry tolerance. Default is 0.3.
257257
active_sites (list, optional): List of active sites within the molecule.
258258
"""
@@ -432,7 +432,7 @@ def get_box_coordinates(self, xyz, padding=0, resolution=1.0):
432432
Returns:
433433
tuple:
434434
- cell (ndarray): Box axis vectors
435-
- vertices (ndarray): [N,3] array of box vertices in Cartesian coordinates
435+
- vertices (ndarray): [N,3] array of box vertices in Cartesian coordinates
436436
- center (ndarray): Box center coordinates
437437
"""
438438
cell = self.get_principle_axes(xyz).T
@@ -664,21 +664,21 @@ def search_H(pairs, ref, pos_H):
664664
def get_coefs_matrix(self, mol2=None, ignore_error=True):
665665
"""
666666
Get the Atom-Atom potential parameters between two molecules.
667-
667+
668668
Calculates coefficients A, B, C for the potential energy equation:
669-
669+
670670
E = A*exp(-B*R) - C*R^(-6)
671-
671+
672672
Parameters are from Gavezotti, Acc. Chem. Res., 27, 1994.
673-
673+
674674
Args:
675675
mol2 (pyxtal_molecule, optional): Second molecule to calculate interaction with.
676676
If None, uses same molecule.
677-
ignore_error (bool): Whether to ignore errors for unsupported atoms.
677+
ignore_error (bool): Whether to ignore errors for unsupported atoms.
678678
Defaults to True.
679-
679+
680680
Returns:
681-
ndarray: Array of shape (n_atoms1, n_atoms2, 3) containing A, B, C
681+
ndarray: Array of shape (n_atoms1, n_atoms2, 3) containing A, B, C
682682
coefficients for each atom pair. These are used to compute the
683683
intermolecular energy. Units are Kcal/mol and angstrom.
684684
"""
@@ -1014,7 +1014,7 @@ def get_torsion_angles(self, xyz=None, torsionlist=None):
10141014
Get the torsion angles for the molecule.
10151015
10161016
Args:
1017-
xyz (ndarray, optional): Coordinates to compute angles for.
1017+
xyz (ndarray, optional): Coordinates to compute angles for.
10181018
If None, uses current molecular coordinates.
10191019
torsionlist (list, optional): List of torsion definitions.
10201020
If None, uses molecule's torsionlist.
@@ -1177,7 +1177,7 @@ def get_orientation(self, xyz, rtol=0.15):
11771177
11781178
Returns:
11791179
tuple:
1180-
- array: Euler angles in degrees [alpha, beta, gamma]
1180+
- array: Euler angles in degrees [alpha, beta, gamma]
11811181
- float: RMSD from reference orientation
11821182
- bool: Whether reflection was applied
11831183
"""
@@ -1273,15 +1273,15 @@ def apply_inversion(self):
12731273
def get_symmetry(self, xyz=None, symmetrize=False, rtol=0.30):
12741274
"""
12751275
Set the molecule's point symmetry.
1276-
1276+
12771277
Sets the following attributes:
1278-
- pga: Point group analyzer from pymatgen
1278+
- pga: Point group analyzer from pymatgen
12791279
- pg: Point group from pyxtal
12801280
- symops: List of symmetry operations
12811281
12821282
Args:
12831283
xyz (ndarray, optional): Coordinates to analyze. Defaults to current coordinates.
1284-
symmetrize (bool, optional): Whether to symmetrize coordinates. Defaults to False.
1284+
symmetrize (bool, optional): Whether to symmetrize coordinates. Defaults to False.
12851285
rtol (float, optional): Symmetry tolerance. Defaults to 0.30.
12861286
"""
12871287
mol = deepcopy(self.mol) if xyz is None else Molecule(self.symbols, xyz)
@@ -1602,11 +1602,11 @@ class Orientation:
16021602
generating orientations which differ only in their rotation about a given axis.
16031603
16041604
Args:
1605-
matrix (ndarray): A 3x3 rotation matrix describing the orientation
1605+
matrix (ndarray): A 3x3 rotation matrix describing the orientation
16061606
(and/or inversion) to store
16071607
degrees (int): The number of degrees of freedom:
16081608
- 0: The orientation refers to a single rotation matrix
1609-
- 1: The orientation can be rotated about a single axis
1609+
- 1: The orientation can be rotated about a single axis
16101610
- 2: The orientation can be any pure rotation matrix
16111611
axis (ndarray, optional): Axis about which the orientation can rotate.
16121612
Only used if degrees is equal to 1
@@ -1834,13 +1834,13 @@ def get_inertia_tensor(coords, weights=None):
18341834
def reoriented_molecule(mol):
18351835
"""
18361836
Align a molecule so that its principal axes are aligned with the coordinate axes.
1837-
1837+
18381838
Reorients the molecule by computing its inertia tensor and rotating it such that
18391839
the principal axes align with the x, y, z coordinate axes.
18401840
18411841
Args:
18421842
mol (Molecule): A pymatgen Molecule object to reorient.
1843-
1843+
18441844
Returns:
18451845
tuple:
18461846
- mol (Molecule): A reoriented copy of the input molecule
@@ -1934,4 +1934,4 @@ def compare_mol_connectivity(mol1, mol2, ignore_name=False):
19341934
print(ans2)
19351935
ans1 = [(0, 1, 2, 9), (6, 5, 4, 7)]
19361936
print(ans1)
1937-
assert ans1 == ans2
1937+
assert ans1 == ans2

pyxtal/util.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -717,7 +717,7 @@ def get_pmg_dist(pmg1, pmg2, ltol=0.3, stol=0.3, angle_tol=5.0, scale=True):
717717
"""
718718
from pymatgen.analysis.structure_matcher import StructureMatcher
719719
sm = StructureMatcher(ltol=ltol, stol=stol, angle_tol=angle_tol, scale=scale)
720-
are_match = sm.fit(pmg1, pmg2, bool=True)
720+
are_match = sm.fit(pmg1, pmg2)#, symmetric==True)
721721
if are_match:
722722
return sm.get_rms_dist(pmg1, pmg2)[0]
723723
else:

0 commit comments

Comments
 (0)