qzhu2017 / PyXtal

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

A function to search the match of lattice parameters #183

Closed qzhu2017 closed 2 years ago

qzhu2017 commented 2 years ago

When comparing two structures, sometimes lattice can be represented a different setting

monoclinic:   6.0282   3.4196   6.0282  90.0000 146.9247  90.0000
monoclinic:   3.4543   3.4099   5.9081  90.0000 105.8004  90.0000

There will be two steps to get the consistent lattice representation

Mainly used for finding the symmetry mapping

qzhu2017 commented 2 years ago
from pyxtal.lattice import Lattice
import numpy as np

paras = [(3.454, 3.401, 5.908, 90.00, 105.80, 90.00, 'monoclinic'),
         (6.028, 3.419, 6.028, 90.00, 146.92, 90.00, 'monoclinic'),
         (5.148, 6.121, 6.234, 108.8, 91.710, 113.4, 'triclinic'),
         (5.163, 6.119, 6.256, 108.6, 91.778, 113.4, 'triclinic'),
        ]

for i in range(int(len(paras)/2)):
    (a1, b1, c1, alpha1, beta1, gamma1, type1) = paras[i*2]
    (a2, b2, c2, alpha2, beta2, gamma2, type2) = paras[i*2+1]
    l1 = Lattice.from_para(a1, b1, c1, alpha1, beta1, gamma1, ltype=type1)
    l2 = Lattice.from_para(a2, b2, c2, alpha2, beta2, gamma2, ltype=type2)
    l1, _ = l1.optimize_multi()
    l2, _ = l2.optimize_multi()
    print(l1)
    print(l2)
    trans, diff = l2.search_transformation(l1)
    l2 = l2.transform_multi(trans)
    diff = l1.matrix-l2.matrix
    print(l2)
    if np.abs(diff).sum() > 0.25:
        print("Problem")
        break