Beispiel #1
0
 def get_ham_response(self,
                      iroot=None,
                      atmlst=None,
                      verbose=None,
                      mo=None,
                      ci=None,
                      eris=None,
                      mf_grad=None,
                      **kwargs):
     if iroot is None: iroot = self.iroot
     if atmlst is None: atmlst = self.atmlst
     if verbose is None: verbose = self.verbose
     if mo is None: mo = self.base.mo_coeff
     if ci is None: ci = self.base.ci
     if eris is None and self.eris is None:
         eris = self.eris = self.base.ao2mo(mo)
     elif eris is None:
         eris = self.eris
     fcasscf_grad = casscf_grad.Gradients(self.make_fcasscf())
     fcasscf_grad.mo_coeff = mo
     fcasscf_grad.ci = ci[iroot]
     return fcasscf_grad.kernel(mo_coeff=mo,
                                ci=ci[iroot],
                                atmlst=atmlst,
                                verbose=verbose)
Beispiel #2
0
    def test_casscf_grad(self):
        mc = mcscf.CASSCF(mf, 4, 4).run()
        g1 = casscf_grad.Gradients(mc).kernel()
        self.assertAlmostEqual(lib.finger(g1), -0.065094188906156134, 7)

        g1ref = grad_elec(mc, mf.nuc_grad_method())
        g1ref += rhf_grad.grad_nuc(mol)
        self.assertAlmostEqual(abs(g1-g1ref).max(), 0, 9)

        mcs = mc.as_scanner()
        pmol = mol.copy()
        e1 = mcs(pmol.set_geom_('N 0 0 0; N 0 0 1.201; H 1 1 0; H 1 1 1.2'))
        e2 = mcs(pmol.set_geom_('N 0 0 0; N 0 0 1.199; H 1 1 0; H 1 1 1.2'))
        self.assertAlmostEqual(g1[1,2], (e1-e2)/0.002*lib.param.BOHR, 4)
Beispiel #3
0
 def kernel (self, state=None, atmlst=None, verbose=None, mo=None, ci=None, eris=None, mf_grad=None, e_states=None, level_shift=None, **kwargs):
     if state is None: state = self.state
     if atmlst is None: atmlst = self.atmlst
     if verbose is None: verbose = self.verbose
     if mo is None: mo = self.base.mo_coeff
     if ci is None: ci = self.base.ci
     if eris is None:
         eris = self.eris = self.base.ao2mo (mo)
     if mf_grad is None: mf_grad = self.base._scf.nuc_grad_method ()
     if state is None:
         return casscf_grad.Gradients (self.base).kernel (mo_coeff=mo, ci=ci, atmlst=atmlst, verbose=verbose)
     if e_states is None:
         try:
             e_states = self.e_states = np.asarray (self.base.e_states)
         except AttributeError as e:
             e_states = self.e_states = np.asarray (self.base.e_tot)
     if level_shift is None: level_shift=self.level_shift
     return lagrange.Gradients.kernel (self, state=state, atmlst=atmlst, verbose=verbose, mo=mo, ci=ci, eris=eris, mf_grad=mf_grad, e_states=e_states, level_shift=level_shift, **kwargs)