コード例 #1
0
ファイル: rccsd.py プロジェクト: berquist/pyscf
 def eeccsd(self, nroots=1):
     cput0 = (time.clock(), time.time())
     log = logger.Logger(self.stdout, self.verbose)
     size = self.nee()
     nroots = min(nroots,size)
     self._eeconv, self.eee, evecs = eigs(self.eeccsd_matvec, size, nroots, verbose=log)
     if self._eeconv:
         logger.info(self, 'EE-CCSD converged')
     else:
         logger.info(self, 'EE-CCSD not converge')
     for n in range(nroots):
         logger.info(self, 'root %d E(EE-CCSD) = %.16g', n, self.eee.real[n])
     log.timer('EE-CCSD', *cput0)
     return self.eee.real[:nroots], evecs
コード例 #2
0
ファイル: rccsd.py プロジェクト: berquist/pyscf
 def ipccsd(self, nroots=1):
     cput0 = (time.clock(), time.time())
     log = logger.Logger(self.stdout, self.verbose)
     size = self.nip()
     nroots = min(nroots,size)
     self._ipconv, self.eip, evecs = eigs(self.ipccsd_matvec, size, nroots,
                                          Adiag=self.ipccsd_diag(), verbose=log)
     if self._ipconv:
         logger.info(self, 'IP-CCSD converged')
     else:
         logger.info(self, 'IP-CCSD not converge')
     for n in range(nroots):
         logger.info(self, 'root %d E(IP-CCSD) = %.16g', n, self.eip.real[n])
     log.timer('IP-CCSD', *cput0)
     return self.eip.real[:nroots], evecs
コード例 #3
0
 def eaccsd(self, nroots=2 * 4, kptlist=None):
     time0 = time.clock(), time.time()
     log = logger.Logger(self.stdout, self.verbose)
     nocc = self.nocc()
     nvir = self.nmo() - nocc
     nkpts = self.nkpts
     size = nvir + nkpts * nkpts * nocc * nvir * nvir
     if kptlist is None:
         kptlist = range(nkpts)
     evals = np.zeros((len(kptlist), nroots), np.complex)
     evecs = np.zeros((len(kptlist), size, nroots), np.complex)
     for k, kshift in enumerate(kptlist):
         self.kshift = kshift
         evals[k], evecs[k] = eigs(self.eaccsd_matvec, size, nroots, self.eaccsd_diag())
     time0 = log.timer_debug1("converge ea-ccsd", *time0)
     return evals.real, evecs
コード例 #4
0
def kernel(eom,
           nroots=1,
           koopmans=True,
           guess=None,
           left=False,
           eris=None,
           imds=None,
           partition=None,
           kptlist=None,
           dtype=None,
           **kwargs):

    cput0 = (time.clock(), time.time())
    log = Logger(eom.stdout, eom.verbose)
    eom.dump_flags()

    if imds is None:
        imds = eom.make_imds(eris)

    size = eom.vector_size()
    nroots = min(nroots, size)
    from pyscf.pbc.lib.linalg_helper import eigs

    matvec, diag = eom.gen_matvec(imds, left=left, **kwargs)
    user_guess = False
    if guess:
        user_guess = True
        assert len(guess) == nroots
        for g in guess:
            assert g.size == size
    else:
        user_guess = False
        guess = eom.get_init_guess(nroots, koopmans, diag)
    conv, evals, evecs = eigs(matvec,
                              size,
                              nroots,
                              x0=guess,
                              Adiag=diag,
                              verbose=eom.verbose)
    evals = evals.real
    for n, en, vn in zip(range(nroots), evals, evecs.T):
        r1, r2 = eom.vector_to_amplitudes(vn)
        qp_weight = r1.norm()**2
        log.info('EOM-CCSD root %d E = %.16g  qpwt = %0.6g', n, en, qp_weight)
    log.timer('EOM-CCSD', *cput0)
    return conv, evals, evecs
コード例 #5
0
 def eeccsd(self, nroots=1):
     cput0 = (time.clock(), time.time())
     log = logger.Logger(self.stdout, self.verbose)
     size = self.nee()
     nroots = min(nroots, size)
     self._eeconv, self.eee, evecs = eigs(self.eeccsd_matvec,
                                          size,
                                          nroots,
                                          verbose=log)
     if self._eeconv:
         logger.info(self, 'EE-CCSD converged')
     else:
         logger.info(self, 'EE-CCSD not converge')
     for n in range(nroots):
         logger.info(self, 'root %d E(EE-CCSD) = %.16g', n,
                     self.eee.real[n])
     log.timer('EE-CCSD', *cput0)
     return self.eee.real[:nroots], evecs
コード例 #6
0
 def ipccsd(self, nroots=1):
     cput0 = (time.clock(), time.time())
     log = logger.Logger(self.stdout, self.verbose)
     size = self.nip()
     nroots = min(nroots, size)
     self._ipconv, self.eip, evecs = eigs(self.ipccsd_matvec,
                                          size,
                                          nroots,
                                          Adiag=self.ipccsd_diag(),
                                          verbose=log)
     if self._ipconv:
         logger.info(self, 'IP-CCSD converged')
     else:
         logger.info(self, 'IP-CCSD not converge')
     for n in range(nroots):
         logger.info(self, 'root %d E(IP-CCSD) = %.16g', n,
                     self.eip.real[n])
     log.timer('IP-CCSD', *cput0)
     return self.eip.real[:nroots], evecs
コード例 #7
0
def kernel(eom,
           nroots=1,
           koopmans=True,
           guess=None,
           left=False,
           eris=None,
           imds=None,
           partition=None,
           kptlist=None,
           dtype=None,
           **kwargs):

    cput0 = (time.clock(), time.time())
    eom.dump_flags()

    log = Logger(eom.stdout, eom.verbose)
    if imds is None:
        imds = eom.make_imds(eris)

    size = eom.vector_size()
    nroots = min(nroots, size)
    nkpts = eom.nkpts

    if kptlist is None:
        kptlist = range(nkpts)

    if dtype is None:
        dtype = imds.t1.dtype

    evals = np.zeros((len(kptlist), nroots), np.float)
    evecs = []
    convs = np.zeros((len(kptlist), nroots), dtype)
    from pyscf.pbc.lib.linalg_helper import eigs
    for k, kshift in enumerate(kptlist):
        matvec, diag = eom.gen_matvec(kshift, imds, left=left, **kwargs)
        eom.update_symlib(kshift)
        user_guess = False
        if guess:
            user_guess = True
            assert len(guess) == nroots
            for g in guess:
                assert g.size == size
        else:
            user_guess = False
            guess = eom.get_init_guess(kshift, nroots, koopmans, diag)

        conv_k, evals_k, evecs_k = eigs(matvec,
                                        size,
                                        nroots,
                                        x0=guess,
                                        Adiag=diag,
                                        verbose=eom.verbose)
        evals_k = evals_k.real
        evals[k] = evals_k.real
        evecs.append(evecs_k)
        convs[k] = conv_k
        for n, en, vn in zip(range(nroots), evals_k, evecs_k.T):
            r1, r2 = eom.vector_to_amplitudes(vn, kshift)
            qp_weight = r1.norm()**2
            log.info('EOM-CCSD root %d E = %.16g  qpwt = %0.6g', n, en,
                     qp_weight)
    log.timer('EOM-CCSD', *cput0)
    evecs = np.vstack(tuple(evecs))
    return convs, evals, evecs
コード例 #8
0
ファイル: ccsd_eom.py プロジェクト: ncrubin/pyscf
 def eaccsd(self, nroots=2*4):
     nocc = self.nocc()
     nvir = self.nmo() - nocc
     size = nvir + nvir*(nvir-1)/2*nocc
     evals, evecs = eigs(self.eaccsd_matvec, size, nroots)
     return evals.real[:nroots], evecs
コード例 #9
0
ファイル: ccsd_eom.py プロジェクト: ncrubin/pyscf
 def ipccsd(self, nroots=2*4):
     nocc = self.nocc()
     nvir = self.nmo() - nocc
     size = nocc + nocc*(nocc-1)/2*nvir
     evals, evecs = eigs(self.ipccsd_matvec, size, nroots)
     return evals.real[:nroots], evecs