示例#1
0
文件: test_rhf.py 项目: zzy2014/pyscf
    def test_ecp_hess(self):
        mol = gto.M(atom='Cu 0 0 0; H 0 0 1.5', basis='lanl2dz',
                    ecp={'Cu':'lanl2dz'}, verbose=0)
        mf = scf.RHF(mol).run(conv_tol=1e-14)
        hess = hessian.RHF(mf).kernel()
        self.assertAlmostEqual(lib.finger(hess), -0.20927804440983355, 6)

        mfs = mf.nuc_grad_method().as_scanner()
        e1 = mfs(mol.set_geom_('Cu 0 0  0.001; H 0 0 1.5'))[1]
        e2 = mfs(mol.set_geom_('Cu 0 0 -0.001; H 0 0 1.5'))[1]
        self.assertAlmostEqual(abs(hess[0,:,2] - (e1-e2)/0.002*lib.param.BOHR).max(), 0, 5)
示例#2
0
 def initialization_pyscf(self):
     self.scf_eng = scf.RHF(self.mol)
     self.scf_eng.conv_tol = 1e-11
     self.scf_eng.conv_tol_grad = 1e-9
     self.scf_eng.max_cycle = 100
     if self.init_scf:
         self.eng = self.scf_eng.kernel()
         if not self.scf_eng.converged:
             warnings.warn("SCF not converged!")
     self.scf_grad = grad.RHF(self.scf_eng)
     self.scf_hess = hessian.RHF(self.scf_eng)
     return
示例#3
0
文件: test_rhf.py 项目: zzy2014/pyscf
    def test_finite_diff_rhf_hess(self):
        mf = scf.RHF(mol)
        mf.conv_tol = 1e-14
        e0 = mf.kernel()
        hess = hessian.RHF(mf).kernel()
        self.assertAlmostEqual(lib.finger(hess), -0.7816353049729151, 6)

        g_scanner = mf.nuc_grad_method().as_scanner()
        pmol = mol.copy()
        e1 = g_scanner(pmol.set_geom_('O  0. 0. 0.0001; 1  0. -0.757 0.587; 1  0. 0.757 0.587'))[1]
        e2 = g_scanner(pmol.set_geom_('O  0. 0. -.0001; 1  0. -0.757 0.587; 1  0. 0.757 0.587'))[1]
        self.assertAlmostEqual(abs(hess[0,:,2] - (e1-e2)/2e-4*lib.param.BOHR).max(), 0, 4)
示例#4
0
 def initialization_pyscf(self):
     if (self.scf_eng.mo_coeff is NotImplemented or self.scf_eng.mo_coeff is None) and self.init_scf:
         self.scf_eng.kernel()
         if not self.scf_eng.converged:
             warnings.warn("SCF not converged!")
     if isinstance(self.scf_eng, dft.rks.RKS):
         self.xc = self.scf_eng.xc
         self.grids = self.scf_eng.grids
         self.xc_type = dft.libxc.xc_type(self.xc)
         self.cx = dft.numint.NumInt().hybrid_coeff(self.xc)
         self.scf_grad = grad.rks.Gradients(self.scf_eng)
         self.scf_hess = hessian.rks.Hessian(self.scf_eng)
     else:
         self.scf_grad = grad.RHF(self.scf_eng)
         self.scf_hess = hessian.RHF(self.scf_eng)
     return
示例#5
0
文件: test_rhf.py 项目: zzy2014/pyscf
    def test_finite_diff_x2c_rhf_hess(self):
        mf = scf.RHF(mol).x2c()
        mf.conv_tol = 1e-14
        e0 = mf.kernel()
        hess = hessian.RHF(mf).kernel()
        self.assertAlmostEqual(lib.finger(hess), -0.7800532318291435, 6)

        g_scanner = mf.nuc_grad_method().as_scanner()
        pmol = mol.copy()
        e1 = g_scanner(pmol.set_geom_('O  0. 0. 0.0001; 1  0. -0.757 0.587; 1  0. 0.757 0.587'))[1]
        e2 = g_scanner(pmol.set_geom_('O  0. 0. -.0001; 1  0. -0.757 0.587; 1  0. 0.757 0.587'))[1]
        self.assertAlmostEqual(abs(hess[0,:,2] - (e1-e2)/2e-4*lib.param.BOHR).max(), 0, 4)

#        e1 = g_scanner(pmol.set_geom_('O  0. 0.0001 0.; 1  0. -0.757 0.587; 1  0. 0.757 0.587'))[1]
#        e2 = g_scanner(pmol.set_geom_('O  0. -.0001 0.; 1  0. -0.757 0.587; 1  0. 0.757 0.587'))[1]
#        self.assertAlmostEqual(abs(hess[0,:,1] - (e1-e2)/2e-4*lib.param.BOHR).max(), 0, 4)
#
#        e1 = g_scanner(pmol.set_geom_('O  0. 0. 0.; 1  0. -0.7571 0.587; 1  0. 0.757 0.587'))[1]
#        e2 = g_scanner(pmol.set_geom_('O  0. 0. 0.; 1  0. -0.7569 0.587; 1  0. 0.757 0.587'))[1]
#        self.assertAlmostEqual(abs(hess[1,:,1] - (e2-e1)/2e-4*lib.param.BOHR).max(), 0, 4)

        e1 = g_scanner(pmol.set_geom_('O  0. 0. 0.; 1  0. -0.757 0.5871; 1  0. 0.757 0.587'))[1]
        e2 = g_scanner(pmol.set_geom_('O  0. 0. 0.; 1  0. -0.757 0.5869; 1  0. 0.757 0.587'))[1]
        self.assertAlmostEqual(abs(hess[1,:,2] - (e1-e2)/2e-4*lib.param.BOHR).max(), 0, 4)
示例#6
0
        dump('Reduced mass [au]     %s\n' % inline(r_mass, col0, col1))
        dump('Force const [Dyne/A]  %s\n' % inline(force, col0, col1))
        dump('Char temp [K]         %s\n' % inline(vib_t, col0, col1))
        #dump('IR\n')
        #dump('Raman\n')
        dump('Normal mode            %s\n' % ('       x     y     z' *
                                              (col1 - col0)))
        for j, at in enumerate(symbols):
            dump('    %4d%4s               %s\n' %
                 (j, at, mode_inline(j, col0, col1)))


if __name__ == '__main__':
    from pyscf import gto
    from pyscf import hessian
    mol = gto.M(atom='O 0 0 0; H 0 .757 .587; H 0 -.757 .587')

    mass = mol.atom_mass_list(isotope_avg=True)
    r = mol.atom_coords() - numpy.random.random((1, 3))
    print(rotation_const(mass, r, 'GHz'))
    print(rotation_const(mass[1:], r[1:], 'GHz'))
    print(rotation_const(mass[2:], r[2:], 'GHz'))

    mf = mol.apply('HF').run()
    hess = hessian.RHF(mf).kernel()
    results = harmonic_analysis(mol, hess)
    dump_normal_mode(mol, results)

    results = thermo(mf, results['freq_au'], 298.15, 101325)
    dump_thermo(mol, results)
示例#7
0
    O  0.0  0.0  0.0
    O  0.0  0.0  1.5
    H  1.0  0.0  0.0
    H  0.0  1.0  1.5
    """
    mol.basis = "6-31G"
    mol.build()

    scf_eng = scf.RHF(mol)
    scf_eng.kernel()

    my_hess = my_hess_elec(scf_eng) + my_hess_nuc(scf_eng)

    from pyscf import hessian

    scf_hess = hessian.RHF(scf_eng)
    pyscf_hess = scf_hess.kernel()

    print("Hessian correct:                ", np.allclose(my_hess, pyscf_hess))

    import time

    time0 = time.time()
    [my_hess_elec(scf_eng) + my_hess_nuc(scf_eng) for i in range(5)]
    time1 = time.time()
    print("Average time for my_hess:       ", (time1 - time0) / 5)

    time0 = time.time()
    [scf_hess.kernel() for i in range(5)]
    time1 = time.time()
    print("Average time for pyscf.hessian: ", (time1 - time0) / 5)