Esempio n. 1
0
  def __init__(self, **kw):
    """ Constructor... """
    scf.__init__(self, **kw)

    nf = self.nfermi[0]
    nv = self.norbs-self.vstart[0]
    self.FmE = np.add.outer(self.ksn2e[0,0,self.vstart[0]:],-self.ksn2e[0,0,:self.nfermi[0]]).T
    self.sqrt_FmE = np.sqrt(self.FmE).reshape([nv*nf])
    self.kernel_qchem_inter_rf()
Esempio n. 2
0
    def __init__(self, **kw):
        """ Constructor... """
        scf.__init__(self, **kw)

        nf = self.nfermi[0]
        nv = self.norbs - self.vstart[0]
        self.FmE = np.add.outer(self.ksn2e[0, 0, self.vstart[0]:],
                                -self.ksn2e[0, 0, :self.nfermi[0]]).T
        self.sqrt_FmE = np.sqrt(self.FmE).reshape([nv * nf])
        self.kernel_qchem_inter_rf()
Esempio n. 3
0
  def __init__(self, **kw):
    from pyscf.nao.log_mesh import funct_log_mesh
    """ Constructor G0W0 class """
    # how to exclude from the input the dtype and xc_code ?
    scf.__init__(self, **kw)
    print(__name__, ' dtype ', self.dtype)

    self.xc_code_scf = copy(self.xc_code)
    self.niter_max_ev = kw['niter_max_ev'] if 'niter_max_ev' in kw else 15
    self.tol_ev = kw['tol_ev'] if 'tol_ev' in kw else 1e-6
    self.perform_gw = kw['perform_gw'] if 'perform_gw' in kw else False
    self.rescf = kw['rescf'] if 'rescf' in kw else False
    self.bsize = kw['bsize'] if 'bsize' in kw else min(40, self.norbs)
    self.tdscf = kw['tdscf'] if 'tdscf' in kw else None
    self.frozen_core = kw['frozen_core'] if 'frozen_core' in kw else None
    self.write_w = kw['write_w'] if 'write_w' in kw else False
    self.restart_w = kw['restart_w'] if 'restart_w' in kw else False
    if sum(self.nelec) == 1:
      raise RuntimeError('Not implemented H, sorry :-) Look into scf/__init__.py for HF1e class...')
    
    if self.nspin==1:
        self.nocc_0t = nocc_0t = np.array([int((self.nelec+1)/2)])
    elif self.nspin==2:
        self.nocc_0t = nocc_0t = self.nelec
    else:
        raise RuntimeError('nspin>2?')

    if self.verbosity>0:
        mess = """====> Number of:
    * occupied states = {},
    * states up to fermi level= {},
    * nspin = {}, 
    * magnetization = {}""".format(nocc_0t,self.nfermi,self.nspin,self.spin)
        print(__name__, mess)

    if 'nocc' in kw:
      s2nocc = [kw['nocc']] if type(kw['nocc'])==int else kw['nocc']
      self.nocc = array([min(i,j) for i,j in zip(s2nocc,nocc_0t)])
    else :
      self.nocc = array([min(6,j) for j in nocc_0t])
    
    if 'nvrt' in kw:
      s2nvrt = [kw['nvrt']] if type(kw['nvrt'])==int else kw['nvrt']
      self.nvrt = array([min(i,j) for i,j in zip(s2nvrt,self.norbs-nocc_0t)])
    else :
      self.nvrt = array([min(6,j) for j in self.norbs-nocc_0t])

    if self.verbosity>0: print(__name__,'\t\t====> Number of ocupied states are gonna correct (nocc) = {}, Number of virtual states are gonna correct (nvrt) = {}'.format(self.nocc, self.nvrt))

    #self.start_st,self.finish_st = self.nocc_0t-self.nocc, self.nocc_0t+self.nvrt
    frozen_core = kw['frozen_core'] if 'frozen_core' in kw else self.frozen_core
    if frozen_core is not None: 
        st_fi = get_str_fin (self, algo=frozen_core, **kw)
        self.start_st, self.finish_st = st_fi[0], st_fi[1]
    else: 
        self.start_st = self.nocc_0t-self.nocc
        self.finish_st = self.nocc_0t+self.nvrt
    if self.verbosity>0:
      print(__name__,'\t\t====> Indices of states to be corrected start from {} to {} \n'.format(self.start_st,self.finish_st))
    self.nn = [range(self.start_st[s], self.finish_st[s]) for s in range(self.nspin)] # list of states
    

    if 'nocc_conv' in kw:
      s2nocc_conv = [kw['nocc_conv']] if type(kw['nocc_conv'])==int else kw['nocc_conv']
      self.nocc_conv = array([min(i,j) for i,j in zip(s2nocc_conv,nocc_0t)])
    else :
      self.nocc_conv = self.nocc

    if self.verbosity>0:
      print(__name__, __LINE__())
    if 'nvrt_conv' in kw:
      s2nvrt_conv = [kw['nvrt_conv']] if type(kw['nvrt_conv'])==int else kw['nvrt_conv']
      self.nvrt_conv = array([min(i,j) for i,j in zip(s2nvrt_conv,self.norbs-nocc_0t)])
    else :
      self.nvrt_conv = self.nvrt
    
    print(__name__, __LINE__())
    
    if self.rescf:
      self.kernel_scf() # here is rescf with HF functional tacitly assumed
        
    print(__name__, __LINE__())
    self.nff_ia = kw['nff_ia'] if 'nff_ia' in kw else 32    #number of grid points
    self.tol_ia = kw['tol_ia'] if 'tol_ia' in kw else 1e-10
    (wmin_def,wmax_def,tmin_def,tmax_def) = self.get_wmin_wmax_tmax_ia_def(self.tol_ia)
    self.wmin_ia = kw['wmin_ia'] if 'wmin_ia' in kw else wmin_def
    self.wmax_ia = kw['wmax_ia'] if 'wmax_ia' in kw else wmax_def
    self.tmin_ia = kw['tmin_ia'] if 'tmin_ia' in kw else tmin_def
    self.tmax_ia = kw['tmax_ia'] if 'tmax_ia' in kw else tmax_def
    self.tt_ia, self.ww_ia = funct_log_mesh(self.nff_ia, self.tmin_ia, self.tmax_ia, self.wmax_ia)
    #print('self.tmin_ia, self.tmax_ia, self.wmax_ia')
    #print(self.tmin_ia, self.tmax_ia, self.wmax_ia)
    #print(self.ww_ia[0], self.ww_ia[-1])
    print(__name__, __LINE__())

    self.dw_ia = self.ww_ia*(log(self.ww_ia[-1])-log(self.ww_ia[0]))/(len(self.ww_ia)-1)
    self.dw_excl = self.ww_ia[0]
    
    assert self.cc_da.shape[1]==self.nprod
    self.kernel_sq = self.hkernel_den
    #self.v_dab_ds = self.pb.get_dp_vertex_doubly_sparse(axis=2)

    self.x = require(self.mo_coeff[0,:,:,:,0], dtype=self.dtype, requirements='CW')

    if self.perform_gw: self.kernel_gw()
    self.snmw2sf_ncalls = 0
    print(__name__, __LINE__())
Esempio n. 4
0
    def __init__(self, **kw):
        from pyscf.nao.m_log_mesh import log_mesh
        """ Constructor G0W0 class """
        # how to exclude from the input the dtype and xc_code ?
        scf.__init__(self, **kw)
        #print(__name__, ' dtype ', self.dtype)

        self.xc_code_scf = copy(self.xc_code)
        self.niter_max_ev = kw['niter_max_ev'] if 'niter_max_ev' in kw else 15
        self.tol_ev = kw['tol_ev'] if 'tol_ev' in kw else 1e-6
        self.perform_gw = kw['perform_gw'] if 'perform_gw' in kw else False
        self.rescf = kw['rescf'] if 'rescf' in kw else False
        self.bsize = kw['bsize'] if 'bsize' in kw else min(40, self.norbs)

        if self.nspin == 1:
            self.nocc_0t = nocc_0t = np.array([int(self.nelec / 2)])
        elif self.nspin == 2:
            self.nocc_0t = nocc_0t = self.nelec
        else:
            raise RuntimeError('nspin>2?')

        if self.verbosity > 0:
            print(__name__, 'nocc_0t =', nocc_0t, 'spin =', self.spin,
                  'nspin =', self.nspin)

        if 'nocc' in kw:
            s2nocc = [kw['nocc']] if type(kw['nocc']) == int else kw['nocc']
            self.nocc = array([min(i, j) for i, j in zip(s2nocc, nocc_0t)])
        else:
            self.nocc = array([min(6, j) for j in nocc_0t])

        if 'nvrt' in kw:
            s2nvrt = [kw['nvrt']] if type(kw['nvrt']) == int else kw['nvrt']
            self.nvrt = array(
                [min(i, j) for i, j in zip(s2nvrt, self.norbs - nocc_0t)])
        else:
            self.nvrt = array([min(6, j) for j in self.norbs - nocc_0t])
        if self.verbosity > 0:
            print(__name__, 'nocc =', self.nocc, 'nvrt =', self.nvrt)

        self.start_st, self.finish_st = self.nocc_0t - self.nocc, self.nocc_0t + self.nvrt

        self.nn = [
            range(self.start_st[s], self.finish_st[s])
            for s in range(self.nspin)
        ]  # list of states to correct?
        if self.verbosity > 0: print(__name__, 'nn =', self.nn)

        if 'nocc_conv' in kw:
            s2nocc_conv = [kw['nocc_conv']] if type(
                kw['nocc_conv']) == int else kw['nocc_conv']
            self.nocc_conv = array(
                [min(i, j) for i, j in zip(s2nocc_conv, nocc_0t)])
        else:
            self.nocc_conv = self.nocc

        if 'nvrt_conv' in kw:
            s2nvrt_conv = [kw['nvrt_conv']] if type(
                kw['nvrt_conv']) == int else kw['nvrt_conv']
            self.nvrt_conv = array(
                [min(i, j) for i, j in zip(s2nvrt_conv, self.norbs - nocc_0t)])
        else:
            self.nvrt_conv = self.nvrt

        if self.rescf:
            self.kernel_scf(
            )  # here is rescf with HF functional tacitly assumed

        self.nff_ia = kw['nff_ia'] if 'nff_ia' in kw else 32
        self.tol_ia = kw['tol_ia'] if 'tol_ia' in kw else 1e-10
        (wmin_def, wmax_def, tmin_def,
         tmax_def) = self.get_wmin_wmax_tmax_ia_def(self.tol_ia)
        self.wmin_ia = kw['wmin_ia'] if 'wmin_ia' in kw else wmin_def
        self.wmax_ia = kw['wmax_ia'] if 'wmax_ia' in kw else wmax_def
        self.tmin_ia = kw['tmin_ia'] if 'tmin_ia' in kw else tmin_def
        self.tmax_ia = kw['tmax_ia'] if 'tmax_ia' in kw else tmax_def
        self.tt_ia, self.ww_ia = log_mesh(self.nff_ia, self.tmin_ia,
                                          self.tmax_ia, self.wmax_ia)
        #print('self.tmin_ia, self.tmax_ia, self.wmax_ia')
        #print(self.tmin_ia, self.tmax_ia, self.wmax_ia)
        #print(self.ww_ia[0], self.ww_ia[-1])

        self.dw_ia = self.ww_ia * (log(self.ww_ia[-1]) -
                                   log(self.ww_ia[0])) / (len(self.ww_ia) - 1)
        self.dw_excl = self.ww_ia[0]

        assert self.cc_da.shape[1] == self.nprod
        self.kernel_sq = self.hkernel_den
        #self.v_dab_ds = self.pb.get_dp_vertex_doubly_sparse(axis=2)

        self.x = require(self.mo_coeff[0, :, :, :, 0],
                         dtype=self.dtype,
                         requirements='CW')

        if self.perform_gw: self.kernel_gw()