def test_nao(self): c = nao.nao(mol, mf) s = mf.get_ovlp() self.assertTrue(numpy.allclose(reduce(numpy.dot, (c.T, s, c)), numpy.eye(s.shape[0]))) self.assertAlmostEqual(numpy.linalg.norm(c), 8.982385484322208, 9) self.assertAlmostEqual(abs(c).sum(), 90.443872916389637, 6) c = nao.nao(mol1, mf1) s = mf1.get_ovlp() self.assertTrue(numpy.allclose(reduce(numpy.dot, (c.T, s, c)), numpy.eye(s.shape[0]))) self.assertAlmostEqual(numpy.linalg.norm(c), 9.4629575662640129, 9) self.assertAlmostEqual(abs(c).sum(), 100.24554485355642, 6)
def orth_ao(mol, method='meta_lowdin', pre_orth_ao=None, scf_method=None, s=None): '''Orthogonalize AOs Kwargs: method : str One of | lowdin : Symmetric orthogonalization | meta-lowdin : Lowdin orth within core, valence, virtual space separately (JCTC, 10, 3784) | NAO ''' from pyscf.lo import nao if s is None: s = mol.intor_symmetric('cint1e_ovlp_sph') if pre_orth_ao is None: # pre_orth_ao = numpy.eye(mol.nao_nr()) pre_orth_ao = project_to_atomic_orbitals(mol, 'ANO') if method.lower() == 'lowdin': s1 = reduce(numpy.dot, (pre_orth_ao.T, s, pre_orth_ao)) c_orth = numpy.dot(pre_orth_ao, lowdin(s1)) elif method.lower() == 'nao': c_orth = nao.nao(mol, scf_method, s) else: # meta_lowdin: divide ao into core, valence and Rydberg sets, # orthogonalizing within each set weight = numpy.ones(pre_orth_ao.shape[0]) c_orth = nao._nao_sub(mol, weight, pre_orth_ao, s) # adjust phase for i in range(c_orth.shape[1]): if c_orth[i,i] < 0: c_orth[:,i] *= -1 return c_orth
def test_nao(self): c = nao.nao(mol, mf) s = mf.get_ovlp() self.assertTrue(numpy.allclose(reduce(numpy.dot, (c.T, s, c)), numpy.eye(s.shape[0]))) self.assertAlmostEqual(numpy.linalg.norm(c), 10.967144073462256, 9) self.assertAlmostEqual(abs(c).sum(), 110.03099712555559, 7)
def orth_ao(mol, method='meta_lowdin', pre_orth_ao=None, scf_method=None, s=None): '''Orthogonalize AOs Kwargs: method : str One of | lowdin : Symmetric orthogonalization | meta-lowdin : Lowdin orth within core, valence, virtual space separately (JCTC, 10, 3784) | NAO ''' from pyscf.lo import nao if s is None: s = mol.intor_symmetric('int1e_ovlp') if pre_orth_ao is None: # pre_orth_ao = numpy.eye(mol.nao_nr()) pre_orth_ao = project_to_atomic_orbitals(mol, 'ANO') if method.lower() == 'lowdin': s1 = reduce(numpy.dot, (pre_orth_ao.T, s, pre_orth_ao)) c_orth = numpy.dot(pre_orth_ao, lowdin(s1)) elif method.lower() == 'nao': c_orth = nao.nao(mol, scf_method, s) else: # meta_lowdin: divide ao into core, valence and Rydberg sets, # orthogonalizing within each set weight = numpy.ones(pre_orth_ao.shape[0]) c_orth = nao._nao_sub(mol, weight, pre_orth_ao, s) # adjust phase for i in range(c_orth.shape[1]): if c_orth[i,i] < 0: c_orth[:,i] *= -1 return c_orth
def orth_ao(mf_or_mol, method=ORTH_METHOD, pre_orth_ao=None, scf_method=None, s=None): '''Orthogonalize AOs Kwargs: method : str One of | lowdin : Symmetric orthogonalization | meta-lowdin : Lowdin orth within core, valence, virtual space separately (JCTC, 10, 3784) | NAO pre_orth_ao: numpy.ndarray Coefficients to restore AO characters for arbitrary basis. If not given, the coefficients are generated based on ANO basis. You can skip this by setting pre_orth_ao to identity matrix, e.g. np.eye(mol.nao). ''' from pyscf.lo import nao mf = scf_method if isinstance(mf_or_mol, gto.Mole): mol = mf_or_mol else: mol = mf_or_mol.mol if mf is None: mf = mf_or_mol if s is None: if getattr(mol, 'pbc_intor', None): # whether mol object is a cell s = mol.pbc_intor('int1e_ovlp', hermi=1) else: s = mol.intor_symmetric('int1e_ovlp') if pre_orth_ao is None: pre_orth_ao = project_to_atomic_orbitals(mol, REF_BASIS) if method.lower() == 'lowdin': s1 = reduce(numpy.dot, (pre_orth_ao.conj().T, s, pre_orth_ao)) c_orth = numpy.dot(pre_orth_ao, lowdin(s1)) elif method.lower() == 'nao': assert(mf is not None) c_orth = nao.nao(mol, mf, s) else: # meta_lowdin: partition AOs into core, valence and Rydberg sets, # orthogonalizing within each set weight = numpy.ones(pre_orth_ao.shape[0]) c_orth = nao._nao_sub(mol, weight, pre_orth_ao, s) # adjust phase for i in range(c_orth.shape[1]): if c_orth[i,i] < 0: c_orth[:,i] *= -1 return c_orth
def orth_ao(mf_or_mol, method=ORTH_METHOD, pre_orth_ao=None, scf_method=None, s=None): '''Orthogonalize AOs Kwargs: method : str One of | lowdin : Symmetric orthogonalization | meta-lowdin : Lowdin orth within core, valence, virtual space separately (JCTC, 10, 3784) | NAO ''' from pyscf.lo import nao mf = scf_method if isinstance(mf_or_mol, gto.Mole): mol = mf_or_mol else: mol = mf_or_mol.mol if mf is None: mf = mf_or_mol if s is None: if getattr(mol, 'pbc_intor', None): # whether mol object is a cell s = mol.pbc_intor('int1e_ovlp', hermi=1) else: s = mol.intor_symmetric('int1e_ovlp') if pre_orth_ao is None: # pre_orth_ao = numpy.eye(mol.nao_nr()) pre_orth_ao = project_to_atomic_orbitals(mol, REF_BASIS) if method.lower() == 'lowdin': s1 = reduce(numpy.dot, (pre_orth_ao.conj().T, s, pre_orth_ao)) c_orth = numpy.dot(pre_orth_ao, lowdin(s1)) elif method.lower() == 'nao': assert (mf is not None) c_orth = nao.nao(mol, mf, s) else: # meta_lowdin: divide ao into core, valence and Rydberg sets, # orthogonalizing within each set weight = numpy.ones(pre_orth_ao.shape[0]) c_orth = nao._nao_sub(mol, weight, pre_orth_ao, s) # adjust phase for i in range(c_orth.shape[1]): if c_orth[i, i] < 0: c_orth[:, i] *= -1 return c_orth
def orth_ao(mf_or_mol, method=ORTH_METHOD, pre_orth_ao=None, scf_method=None, s=None): '''Orthogonalize AOs Kwargs: method : str One of | lowdin : Symmetric orthogonalization | meta-lowdin : Lowdin orth within core, valence, virtual space separately (JCTC, 10, 3784) | NAO ''' from pyscf.lo import nao mf = scf_method if isinstance(mf_or_mol, gto.Mole): mol = mf_or_mol else: mol = mf_or_mol.mol if mf is None: mf = mf_or_mol if s is None: if getattr(mol, 'pbc_intor', None): # whether mol object is a cell s = mol.pbc_intor('int1e_ovlp', hermi=1) else: s = mol.intor_symmetric('int1e_ovlp') if pre_orth_ao is None: # pre_orth_ao = numpy.eye(mol.nao_nr()) pre_orth_ao = project_to_atomic_orbitals(mol, REF_BASIS) if method.lower() == 'lowdin': s1 = reduce(numpy.dot, (pre_orth_ao.conj().T, s, pre_orth_ao)) c_orth = numpy.dot(pre_orth_ao, lowdin(s1)) elif method.lower() == 'nao': assert(mf is not None) c_orth = nao.nao(mol, mf, s) else: # meta_lowdin: divide ao into core, valence and Rydberg sets, # orthogonalizing within each set weight = numpy.ones(pre_orth_ao.shape[0]) c_orth = nao._nao_sub(mol, weight, pre_orth_ao, s) # adjust phase for i in range(c_orth.shape[1]): if c_orth[i,i] < 0: c_orth[:,i] *= -1 return c_orth
def orth_ao(mol, method='meta_lowdin', pre_orth_ao=None, scf_method=None, s=None): from pyscf.lo import nao if s is None: s = mol.intor_symmetric('cint1e_ovlp_sph') if pre_orth_ao is None: # pre_orth_ao = numpy.eye(mol.nao_nr()) pre_orth_ao = pre_orth_project_ano(mol, 'ANO') if method == 'lowdin': s1 = reduce(numpy.dot, (pre_orth_ao.T, s, pre_orth_ao)) c_orth = numpy.dot(pre_orth_ao, lowdin(s1)) elif method == 'nao': c_orth = nao.nao(mol, scf_method) else: # meta_lowdin: divide ao into core, valence and Rydberg sets, # orthogonalizing within each set weight = numpy.ones(pre_orth_ao.shape[0]) c_orth = nao._nao_sub(mol, weight, pre_orth_ao) # adjust phase for i in range(c_orth.shape[1]): if c_orth[i,i] < 0: c_orth[:,i] *= -1 return c_orth
def orth_ao(mf_or_mol, method=ORTH_METHOD, pre_orth_ao=REF_BASIS, s=None): '''Orthogonalize AOs Kwargs: method : str One of | lowdin : Symmetric orthogonalization | meta-lowdin : Lowdin orth within core, valence, virtual space separately (JCTC, 10, 3784) | NAO pre_orth_ao: numpy.ndarray or basis str or basis dict Basis functions may not have AO characters. This variable is the coefficients to restore AO characters for arbitrary basis. If a string of basis name (can be the filename of a basis set) or a dict of basis sets are given, they are interpreted as the reference basis (by default ANO basis) that the projection coefficients are generated based on. Skip this projection step by setting this variable to None. ''' from pyscf import scf from pyscf.lo import nao if isinstance(mf_or_mol, gto.Mole): mol = mf_or_mol mf = None else: assert (isinstance(mf_or_mol, scf.hf.SCF)) mol = mf_or_mol.mol mf = mf_or_mol if s is None: if getattr(mol, 'pbc_intor', None): # whether mol object is a cell s = mol.pbc_intor('int1e_ovlp', hermi=1) else: s = mol.intor_symmetric('int1e_ovlp') if method.lower() == 'lowdin': if pre_orth_ao is None: c_orth = lowdin(s1) else: if not isinstance(pre_orth_ao, numpy.ndarray): pre_orth_ao = restore_ao_character(mol, pre_orth_ao) s1 = reduce(numpy.dot, (pre_orth_ao.conj().T, s, pre_orth_ao)) c_orth = numpy.dot(pre_orth_ao, lowdin(s1)) elif method.lower() == 'nao': assert (mf is not None) c_orth = nao.nao(mol, mf, s) else: # meta_lowdin: partition AOs into core, valence and Rydberg sets, # orthogonalizing within each set if pre_orth_ao is None: pre_orth_ao = numpy.eye(mol.nao) elif not isinstance(pre_orth_ao, numpy.ndarray): pre_orth_ao = restore_ao_character(mol, pre_orth_ao) weight = numpy.ones(pre_orth_ao.shape[0]) c_orth = nao._nao_sub(mol, weight, pre_orth_ao, s) # adjust phase for i in range(c_orth.shape[1]): if c_orth[i, i] < 0: c_orth[:, i] *= -1 return c_orth