Ejemplo n.º 1
0
 def test_mo_map(self):
     mol1 = gto.M(atom = '''O 0 0 0; O 0 0 1''', basis='6-31g')
     mol2 = gto.M(atom = '''O 0 0 0; O 0 0 1''', basis='ccpvdz')
     numpy.random.seed(1)
     mo1 = numpy.random.random((mol1.nao_nr(), 10))*.2
     mo2 = numpy.random.random((mol2.nao_nr(), 15))*.2
     idx,s = mo_mapping.mo_map(mol1, mo1, mol2, mo2)
     self.assertTrue(numpy.allclose(idx,
         [[1,11], [2,11], [7,11], [8,11], [9,11],]))
     self.assertAlmostEqual(abs(s).sum(), 54.5514791873481, 9)
Ejemplo n.º 2
0
 def test_mo_map(self):
     mol1 = gto.M(atom = '''O 0 0 0; O 0 0 1''', basis='6-31g')
     mol2 = gto.M(atom = '''O 0 0 0; O 0 0 1''', basis='ccpvdz')
     numpy.random.seed(1)
     mo1 = numpy.random.random((mol1.nao_nr(), 10))*.2
     mo2 = numpy.random.random((mol2.nao_nr(), 15))*.2
     idx,s = mo_mapping.mo_map(mol1, mo1, mol2, mo2)
     self.assertTrue(numpy.allclose(idx,
         [[1,11], [2,11], [7,11], [8,11], [9,11],]))
     self.assertAlmostEqual(abs(s).sum(), 54.5514791873481, 9)
Ejemplo n.º 3
0
def ovp_check(mol1: gto.mole.Mole,
              mol2: gto.mole.Mole,
              mo1: np.ndarray,
              mo2: np.ndarray,
              tol: float = 0.35,
              mo_range: list = None) -> list:
    r"""Compare two sets of orbitals then return the list of orbital indices
        where orbitals of the same index match whith each other.

        Args:
            mol1 (object):      mol of system 1.
            mol2 (object):      mol of system 2.
            mo1 (np.ndarray):   molecular orbitals of system 1.
            mo2 (np.ndarray):   molecular orbitals of system 2.
            tol (float):        tolerance.
            mo_range (list):    range of orbitals to check.

        Returns:
            match (list):              List of matched orbital indices.

        raises:
            TypeError: MO both should be of the same size.
    """
    from pyscf.tools import mo_mapping
    if not mo1.shape[0] == mo2.shape[0]:
        raise TypeError('Both MOs should be of the same dimensions')
    if mo_range is None:
        mo_range = list(range(mo1.shape[0]))

    match = []
    idx = np.array(mo_mapping.mo_map(mol1, mo1, mol2, mo2, tol=tol)[0])
    for i in mo_range:
        idxi = idx[idx[:, 0] == i]
        for j in idxi:
            if set(j) == set([i, i]):
                match.append(i)
    return match