Beispiel #1
0
def rhf_internal(mf, with_symmetry=True, verbose=None):
    log = logger.new_logger(mf, verbose)
    g, hop, hdiag = newton_ah.gen_g_hop_rhf(mf,
                                            mf.mo_coeff,
                                            mf.mo_occ,
                                            with_symmetry=with_symmetry)
    hdiag *= 2

    def precond(dx, e, x0):
        hdiagd = hdiag - e
        hdiagd[abs(hdiagd) < 1e-8] = 1e-8
        return dx / hdiagd

    # The results of hop(x) corresponds to a displacement that reduces
    # gradients g.  It is the vir-occ block of the matrix vector product
    # (Hessian*x). The occ-vir block equals to x2.T.conj(). The overall
    # Hessian for internal reotation is x2 + x2.T.conj(). This is
    # the reason we apply (.real * 2) below
    def hessian_x(x):
        return hop(x).real * 2

    x0 = numpy.zeros_like(g)
    x0[g != 0] = 1. / hdiag[g != 0]
    if not with_symmetry:  # allow to break point group symmetry
        x0[numpy.argmin(hdiag)] = 1
    e, v = lib.davidson(hessian_x, x0, precond, tol=1e-4, verbose=log)
    if e < -1e-5:
        log.note('RHF/RKS wavefunction has an internal instablity')
        mo = _rotate_mo(mf.mo_coeff, mf.mo_occ, v)
    else:
        log.note(
            'RHF/RKS wavefunction is stable in the internal stability analysis'
        )
        mo = mf.mo_coeff
    return mo
Beispiel #2
0
def rhf_internal(mf, with_symmetry=True, verbose=None):
    log = logger.new_logger(mf, verbose)
    g, hop, hdiag = newton_ah.gen_g_hop_rhf(mf,
                                            mf.mo_coeff,
                                            mf.mo_occ,
                                            with_symmetry=with_symmetry)

    def precond(dx, e, x0):
        hdiagd = hdiag - e
        hdiagd[abs(hdiagd) < 1e-8] = 1e-8
        return dx / hdiagd

    x0 = numpy.zeros_like(g)
    x0[g != 0] = 1. / hdiag[g != 0]
    if not with_symmetry:  # allow to break point group symmetry
        x0[numpy.argmin(hdiag)] = 1
    e, v = lib.davidson(hop, x0, precond, tol=1e-4, verbose=log)
    if e < -1e-5:
        log.note('RHF/RKS wavefunction has an internal instablity')
        mo = _rotate_mo(mf.mo_coeff, mf.mo_occ, v)
    else:
        log.note(
            'RHF/RKS wavefunction is stable in the intenral stablity analysis')
        mo = mf.mo_coeff
    return mo
Beispiel #3
0
def rhf_internal(mf, with_symmetry=True, verbose=None):
    log = logger.new_logger(mf, verbose)
    g, hop, hdiag = newton_ah.gen_g_hop_rhf(mf, mf.mo_coeff, mf.mo_occ,
                                            with_symmetry=with_symmetry)
    hdiag *= 2
    def precond(dx, e, x0):
        hdiagd = hdiag - e
        hdiagd[abs(hdiagd)<1e-8] = 1e-8
        return dx/hdiagd
    # The results of hop(x) corresponds to a displacement that reduces
    # gradients g.  It is the vir-occ block of the matrix vector product
    # (Hessian*x). The occ-vir block equals to x2.T.conj(). The overall
    # Hessian for internal reotation is x2 + x2.T.conj(). This is
    # the reason we apply (.real * 2) below
    def hessian_x(x):
        return hop(x).real * 2

    x0 = numpy.zeros_like(g)
    x0[g!=0] = 1. / hdiag[g!=0]
    if not with_symmetry:  # allow to break point group symmetry
        x0[numpy.argmin(hdiag)] = 1
    e, v = lib.davidson(hessian_x, x0, precond, tol=1e-4, verbose=log)
    if e < -1e-5:
        log.note('RHF/RKS wavefunction has an internal instablity')
        mo = _rotate_mo(mf.mo_coeff, mf.mo_occ, v)
    else:
        log.note('RHF/RKS wavefunction is stable in the intenral stability analysis')
        mo = mf.mo_coeff
    return mo
Beispiel #4
0
 def gen_g_hop (self, mo_coeff, mo_occ, fock_ao=None, h1e=None,
           with_symmetry=True):
     nmo = len (mo_occ)
     idx_down = np.where (mo_occ==2)[0]
     idx_up = np.where (mo_occ==2)[0]
     idx_down[:self.ncore] = idx_up[:self.ncore] = False
     nocc = self.ncore + self.nfroz
     idx_down[nocc:] = idx_up[nocc:] = False
     mo_occ[idx_down] -= 1e-4
     mo_occ[idx_up] += 1e-4
     rets = gen_g_hop_rhf (self, mo_coeff, mo_occ, fock_ao=fock_ao, h1e=h1e, with_symmetry=with_symmetry)
     mo_occ[idx_up] -= 1e-4
     mo_occ[idx_down] += 1e-4
     return rets