qzhu2017 / PyXtal

A code to generate atomic structure with symmetry
MIT License
234 stars 59 forks source link

Reorganize the supergroup function #181

Closed qzhu2017 closed 2 years ago

qzhu2017 commented 2 years ago

The current functions is a bit messy. Needs a better organization so that one can easily do 1, search for pseudo symmetry 2, find the mapping between two symmetry-related structures.

qzhu2017 commented 2 years ago
qzhu2017 commented 2 years ago
from pyxtal import pyxtal
import pymatgen.analysis.structure_matcher as sm

paras = [
         ('0-G62', '2-G71'),
         ('0-G62', '3-G139'),
         ('0-G62', '4-G225'),
        ]

for para in paras:
    (cif1, cif2) = para
    s1 = pyxtal()
    s2 = pyxtal()
    s1.from_seed('pyxtal/database/cifs/'+cif1+'.cif')
    s2.from_seed('pyxtal/database/cifs/'+cif2+'.cif')
    pmg_s2 = s2.to_pymatgen()

    strucs, _, _ = s2.get_transition(s1)

    if strucs is not None:
       # high symmetry structure in subgroup representation
        struc_G_in_H = strucs[-1]
        s3 = pyxtal()
        s3.from_seed(struc_G_in_H.to_pymatgen(), tol=1e-3)

        # Match in space group number 
        print("Space group", s3.group.number == s2.group.number)

        # Match in structure
        pmg_s3 = s3.to_pymatgen()
        print("Structure", sm.StructureMatcher().get_rms_dist(pmg_s2, pmg_s3))

    else:
        print("Problem in ", cif1, cif2)