Example #1
0
    def from_pyscf(cls, hf):
        ''' Builds the RHF object from a pyscf.scf.hf.RHF object.

        Parameters
        ----------
        hf : pyscf.scf.hf.RHF
            Hartree-Fock object

        Returns
        -------
        hf : RHF
            Hartree-Fock object
        '''

        _hf = RHF(mol.Molecule.from_pyscf(hf.mol))

        _hf._pyscf = hf

        if not getattr(hf, 'with_df', False):
            _hf._eri_ao = util.restore(1, _hf.mol._pyscf.intor('int2e'),
                                       hf.mol.nao)
        else:
            if hf.with_df._cderi is None:
                hf.with_df.run()

            _hf._eri_ao = lib.unpack_tril(hf.with_df._cderi)

        return _hf
Example #2
0
    def _run(self, **kwargs):
        if self.with_df:
            self._pyscf = self._pyscf.density_fit()
            self._pyscf.with_df.auxbasis = self.auxbasis

        self._pyscf.run(**kwargs)

        if self.check_stability:
            for niter in range(1, self.stability_cycles + 1):
                stability = self.stability()

                if isinstance(stability, tuple):
                    internal, external = stability
                else:
                    internal = stability

                if np.allclose(internal, self._pyscf.mo_coeff):
                    if niter == self.stability_cycles:
                        if mpi.rank:
                            log.warn('Internal stability in HF not resolved.')
                    break
                else:
                    rdm1 = self._pyscf.make_rdm1(internal, self._pyscf.mo_occ)

                self._pyscf.scf(dm0=rdm1)

        if not self.with_df:
            self._eri_ao = util.restore(1, self.mol._pyscf.intor('int2e'),
                                        self.nao)
        else:
            self._eri_ao = lib.unpack_tril(self._pyscf.with_df._cderi)
Example #3
0
    def from_pyscf(cls, hf):
        ''' Builds the GHF object from a pyscf.scf.hf.GHF object.

        Parameters
        ----------
        hf : pyscf.scf.hf.GHF
            Hartree-Fock object

        Returns
        -------
        hf : GHF
            Hartree-Fock object
        '''

        _hf = GHF(mol.Molecule.from_pyscf(hf.mol))

        _hf._pyscf = hf
        _hf._eri_ao = util.restore(1, _hf.mol._pyscf.intor('int2e'),
                                   hf.mol.nao)

        return _hf
Example #4
0
    def from_pyscf(cls, ks):
        ''' Builds the UDFT object from a pyscf.dft.dft.UKS object.

        Parameters
        ----------
        ks : pyscf.dft.dft.UKS
            Unrestricted Kohn-Sham object

        Returns
        -------
        ks : UDFT
            Unrestricted density-functional theory object
        '''

        _ks = UDFT(mol.Molecule.from_pyscf(ks.mol))

        _ks._pyscf = ks
        _ks._eri_ao = util.restore(1, _ks.mol._pyscf.intor('int2e'),
                                   ks.mol.nao)

        return _ks