def test_153_bse_h2b_uks_rpa(self):
        """ This  example is with discrepancies... """
        mol = gto.M(verbose=1,
                    atom='B 0 0 0; H 0 0.489 1.074; H 0 0.489 -1.074',
                    basis='cc-pvdz',
                    spin=3)

        gto_mf = scf.UKS(mol)
        gto_mf.kernel()
        gto_td = tddft.dRPA(gto_mf)
        gto_td.nstates = 190
        gto_td.kernel()

        omegas = np.arange(0.0, 2.0, 0.01) + 1j * 0.03
        p_ave = -polariz_freq_osc_strength(
            gto_td.e, gto_td.oscillator_strength(), omegas).imag
        data = np.array([omegas.real * HARTREE2EV, p_ave])
        np.savetxt('test_0153_bse_h2b_uks_rpa_pyscf.txt',
                   data.T,
                   fmt=['%f', '%f'])
        data_ref = np.loadtxt('test_0153_bse_h2b_uks_rpa_pyscf.txt-ref').T
        self.assertTrue(np.allclose(data_ref, data, atol=1e-6, rtol=1e-3))

        nao_td = bse_iter(mf=gto_mf, gto=mol, verbosity=0, xc_code='RPA')

        polariz = -nao_td.comp_polariz_inter_ave(omegas).imag
        data = np.array([omegas.real * HARTREE2EV, polariz])
        np.savetxt('test_0153_bse_h2b_uks_rpa_nao.txt',
                   data.T,
                   fmt=['%f', '%f'])
        data_ref = np.loadtxt('test_0153_bse_h2b_uks_rpa_nao.txt-ref').T
        self.assertTrue(np.allclose(data_ref, data, atol=1e-6, rtol=1e-3))
    def test_0146_bse_h2o_rhf_rpa(self):
        """ Interacting case """
        mol = gto.M(
            verbose=0,
            atom='O 0 0 0;H 0 0.489 1.074;H 0 0.489 -1.074',
            basis='cc-pvdz',
        )
        gto_hf = scf.RKS(mol)
        gto_hf.xc = 'hf'
        gto_hf.kernel()
        gto_td = tddft.dRPA(gto_hf)
        gto_td.nstates = 95
        gto_td.kernel()

        omegas = np.arange(0.0, 2.0, 0.01) + 1j * 0.03
        #p_ave = -polariz_inter_ave(gto_hf, mol, gto_td, omegas).imag
        p_ave = -polariz_freq_osc_strength(
            gto_td.e, gto_td.oscillator_strength(), omegas).imag
        data = np.array([omegas.real * HARTREE2EV, p_ave])
        np.savetxt('test_0146_bse_h2o_rhf_rpa_pyscf.txt',
                   data.T,
                   fmt=['%f', '%f'])
        data_ref = np.loadtxt('test_0146_bse_h2o_rhf_rpa_pyscf.txt-ref').T
        self.assertTrue(np.allclose(data_ref, data, atol=1e-6, rtol=1e-3))

        nao_td = bse_iter(mf=gto_hf, gto=mol, verbosity=0, xc_code='RPA')

        p_iter = -nao_td.comp_polariz_inter_ave(omegas).imag
        data = np.array([omegas.real * HARTREE2EV, p_iter])
        np.savetxt('test_0146_bse_h2o_rhf_rpa_nao.txt',
                   data.T,
                   fmt=['%f', '%f'])
        data_ref = np.loadtxt('test_0146_bse_h2o_rhf_rpa_nao.txt-ref').T
        self.assertTrue(np.allclose(data_ref, data, atol=1e-6, rtol=1e-3))
示例#3
0
  def test_0163_bse_h2o_spin2_uhf_rpa(self):
    """ This  """
    mol = gto.M(verbose=1,atom='O 0 0 0; H 0 0.489 1.074; H 0 0.489 -1.074',basis='cc-pvdz',spin=2)

    gto_mf = scf.UKS(mol)
    gto_mf.xc = 'hf'
    gto_mf.kernel()
    gto_td = tddft.dRPA(gto_mf)
    gto_td.nstates = 190
    gto_td.kernel()

    omegas = np.arange(0.0, 2.0, 0.01) + 1j*0.03
    p_ave = -polariz_freq_osc_strength(gto_td.e, gto_td.oscillator_strength(), omegas).imag
    data = np.array([omegas.real*HARTREE2EV, p_ave])
    np.savetxt('test_0163_bse_h2o_spin2_uhf_rpa_pyscf.txt', data.T, fmt=['%f','%f'])
    data_ref = np.loadtxt('test_0163_bse_h2o_spin2_uhf_rpa_pyscf.txt-ref').T
    self.assertTrue(np.allclose(data_ref, data, atol=1e-6, rtol=1e-3))
    
    nao_td  = bse_iter(mf=gto_mf, gto=mol, verbosity=0, xc_code='RPA')

    polariz = -nao_td.comp_polariz_inter_ave(omegas).imag
    data = np.array([omegas.real*HARTREE2EV, polariz])
    np.savetxt('test_0163_bse_h2o_spin2_uhf_rpa_nao.txt', data.T, fmt=['%f','%f'])
    data_ref = np.loadtxt('test_0163_bse_h2o_spin2_uhf_rpa_nao.txt-ref').T
    self.assertTrue(np.allclose(data_ref, data, atol=1e-5, rtol=1e-3), \
      msg="{}".format(abs(data_ref-data).sum()/data.size))
示例#4
0
    def test_161_bse_h2b_spin1_uhf_cis(self):
        """ This  """
        mol = gto.M(verbose=1,
                    atom='B 0 0 0; H 0 0.489 1.074; H 0 0.489 -1.074',
                    basis='cc-pvdz',
                    spin=1)

        gto_mf = scf.UHF(mol)
        gto_mf.kernel()
        gto_td = tddft.TDHF(gto_mf)
        gto_td.nstates = 150
        gto_td.kernel()

        omegas = np.arange(0.0, 2.0, 0.01) + 1j * 0.03
        p_ave = -polariz_freq_osc_strength(
            gto_td.e, gto_td.oscillator_strength(), omegas).imag
        data = np.array([omegas.real * HARTREE2EV, p_ave])
        np.savetxt('test_0161_bse_h2b_spin1_uhf_cis_pyscf.txt',
                   data.T,
                   fmt=['%f', '%f'])
        #data_ref = np.loadtxt('test_0159_bse_h2b_uhf_cis_pyscf.txt-ref').T
        #self.assertTrue(np.allclose(data_ref, data, atol=1e-6, rtol=1e-3))

        nao_td = bse_iter(mf=gto_mf, gto=mol, verbosity=0, xc_code='CIS')

        polariz = -nao_td.comp_polariz_inter_ave(omegas).imag
        data = np.array([omegas.real * HARTREE2EV, polariz])
        np.savetxt('test_0161_bse_h2b_spin1_uhf_cis_nao.txt',
                   data.T,
                   fmt=['%f', '%f'])
示例#5
0
    def test_170_bse_h2o_rks_b3lyp_pb(self):
        """ This  """
        mol = gto.M(verbose=1,
                    atom='O 0 0 0; H 0 0.489 1.074; H 0 0.489 -1.074',
                    basis='cc-pvdz')
        gto_mf = scf.RKS(mol)
        gto_mf.xc = 'PBE'
        gto_mf.kernel()
        #print(__name__, 'veff')
        veff = gto_mf.get_veff()
        #print(veff.shape)
        #print(veff.sum())
        #gto_td = tddft.TDDFT(gto_mf)
        #gto_td.nstates = 190
        #gto_td.kernel()

        #print(__name__, parse_xc_name(gto_mf.xc) )
        #print(__name__, xc_type(gto_mf.xc) )
        #print(__name__, is_hybrid_xc(gto_mf.xc) )
        #print(__name__, is_gga(gto_mf.xc) )
        #print(__name__, is_lda(gto_mf.xc) )

        return

        raise RuntimeError('check ')

        omegas = np.arange(0.0, 2.0, 0.01) + 1j * 0.03
        p_ave = -polariz_freq_osc_strength(
            gto_td.e, gto_td.oscillator_strength(), omegas).imag
        data = np.array([omegas.real * HARTREE2EV, p_ave])
        np.savetxt('test_0170_bse_h2o_rks_pbe_pyscf.txt',
                   data.T,
                   fmt=['%f', '%f'])
        #data_ref = np.loadtxt('test_0170_bse_h2o_rks_pbe_pyscf.txt-ref').T
        #self.assertTrue(np.allclose(data_ref, data, atol=1e-6, rtol=1e-3))

        nao_td = bse_iter(mf=gto_mf, gto=mol, verbosity=1)

        fxc = nao_td.comp_fxc_pack()
        print(fxc.shape)
        print(__name__, fxc.sum())

        polariz = -nao_td.comp_polariz_inter_ave(omegas).imag
        data = np.array([omegas.real * HARTREE2EV, polariz])
        np.savetxt('test_0170_bse_h2o_rks_pbe_nao.txt',
                   data.T,
                   fmt=['%f', '%f'])