コード例 #1
0
    def test_nao_in_tdscf(self):
        """ Attempt to use algorithms implemented in PySCF for diagonalizing the RPA Hamiltonian """
        from pyscf import gto, tddft, scf
        from pyscf.tdscf.rhf import TDA

        mol = gto.M(
            verbose=2,
            atom='''H 0.0 0.0 -0.3707;  H 0.0 0.0 0.3707''',
            basis='cc-pvdz',
        )

        gto_hf = scf.RKS(mol)
        gto_hf.xc = 'hf'
        gto_hf.kernel()
        nocc = mol.nelectron // 2
        nmo = gto_hf.mo_energy.size
        nvir = nmo - nocc
        gto_td = tddft.dRPA(gto_hf)
        gto_td.nstates = min(100, nocc * nvir)
        gto_td.kernel()

        gto_gw = GW(gto_hf, gto_td)
        gto_gw.kernel()

        ww = np.arange(0.0, 4.0, 0.01) + 1j * 0.02
        pxx_xpy = -polariz_inter_xx(gto_hf, mol, gto_td, ww).imag
        data = np.array([ww.real * 27.2114, pxx_xpy])
        fname = dname + '/h2_rpa_xpy_0099.omega.inter.pxx.txt'
        np.savetxt(fname, data.T, fmt=['%f', '%f'])

        gw_nao = gw(gto=mol, mf=gto_hf, tdscf=gto_td)
        gw_nao.chkfile = None
コード例 #2
0
 def test_scf_gto_vs_nao(self):
   """ Test computation of overlaps between NAOs against overlaps computed between GTOs"""
   gto_hf = scf.RHF(mol)
   gto_hf.kernel()
   print(gto_hf.mo_energy)
   
   nao_gw = gw(mf=gto_hf, gto=mol, pb_algorithm='fp', verbosity=1, rescf=True, perform_gw=True)
   nao_gw.dump_chkfile=False
   for e1,egw,e2 in zip(nao_gw.mo_energy[0,0], nao_gw.mo_energy_gw[0,0], gto_hf.mo_energy):
     print(e1,egw,e2)
コード例 #3
0
  def test_0168_cn_rohf(self):
    """ Interacting case """
    spin = 1
    mol=gto.M(verbose=0,atom='C 0 0 -0.6;N 0 0 0.52',basis='cc-pvdz',spin=spin)
    gto_mf = scf.ROHF(mol)
    gto_mf.kernel()

    ss_2sp1 = gto_mf.spin_square()
    
    nao_gw = gw(gto=mol, mf=gto_mf, verbosity=0, nocc=4)
    nao_gw.kernel_gw()
コード例 #4
0
 def test_gw_h2_ae_spin_rf0_spin_downgrade_consistence(self):
   """ This is GW """
   mol = gto.M( verbose = 1, atom = '''H 0 0 0;  H 0.17 0.7 0.587''', basis = 'cc-pvdz', spin=0)
   #mol = gto.M( verbose = 0, atom = '''H 0.0 0.0 -0.3707;  H 0.0 0.0 0.3707''', basis = 'cc-pvdz',)
   gto_mf = scf.RHF(mol)
   etot = gto_mf.kernel()
   #print(__name__, 'etot', etot)
   #print('gto_mf.mo_energy:', gto_mf.mo_energy)
   b = gw(mf=gto_mf, gto=mol, verbosity=0, nvrt=4)
   ww = np.arange(0.0, 1.0, 0.1)+1j*0.2
   rf0_ref = b.rf0_cmplx_ref(ww)
   rf0 = b.rf0_cmplx_vertex_ac(ww)
   self.assertTrue(abs(rf0_ref-rf0).sum()/rf0.size<1e-14)
コード例 #5
0
 def test_gw_h2_ae_spin_rf0_spin_downgrade_consistence(self):
     """ This is GW """
     mol = gto.M(verbose=1,
                 atom='''H 0 0 0;  H 0.17 0.7 0.587''',
                 basis='cc-pvdz',
                 spin=0)
     #mol = gto.M( verbose = 0, atom = '''H 0.0 0.0 -0.3707;  H 0.0 0.0 0.3707''', basis = 'cc-pvdz',)
     gto_mf = scf.RHF(mol)
     etot = gto_mf.kernel()
     #print(__name__, 'etot', etot)
     #print('gto_mf.mo_energy:', gto_mf.mo_energy)
     b = gw(mf=gto_mf, gto=mol, verbosity=0, nvrt=4)
     ww = np.arange(0.0, 1.0, 0.1) + 1j * 0.2
     rf0_ref = b.rf0_cmplx_ref(ww)
     rf0 = b.rf0_cmplx_vertex_ac(ww)
     self.assertTrue(abs(rf0_ref - rf0).sum() / rf0.size < 1e-14)
コード例 #6
0
 def test_gw_h2_ae_spin_rf0_speed(self):
   """ This is GW """
   mol = gto.M( verbose = 1, 
     atom = '''H 0 0 0;  H 0 0 0.5; H 0 0 1.0; H 0 0 1.5; H 0 0 2.0; H 0 0 2.5; H 0 0 3.0; H 0 0 3.5;''', 
     basis = 'cc-pvdz', spin=0)
   #mol = gto.M( verbose = 0, atom = '''H 0.0 0.0 -0.3707;  H 0.0 0.0 0.3707''', basis = 'cc-pvdz',)
   gto_mf = scf.RHF(mol)
   etot = gto_mf.kernel()
   #print(__name__, 'etot', etot)
   #print('gto_mf.mo_energy:', gto_mf.mo_energy)
   b = gw(mf=gto_mf, gto=mol, verbosity=0, nvrt=4)
   ww = np.arange(0.0, 1.0, 0.1)+1j*0.2
   rf0 = b.rf0_den(ww)
   rf0_ref = b.rf0_cmplx_ref(ww)
   print(__name__, '|diff|', abs(rf0_ref-rf0).sum()/rf0.size)
   self.assertTrue(abs(rf0_ref-rf0).sum()/rf0.size<1e-12)
コード例 #7
0
    def test_scf_gto_vs_nao(self):
        """ Test computation of overlaps between NAOs against overlaps computed between GTOs"""
        gto_hf = scf.RHF(mol)
        gto_hf.kernel()
        #print(gto_hf.mo_energy)

        nao_gw = gw(mf=gto_hf,
                    gto=mol,
                    pb_algorithm='fp',
                    verbosity=0,
                    rescf=True,
                    perform_gw=True)
        nao_gw.dump_chkfile = False
        for e1, egw, e2 in zip(nao_gw.mo_energy[0, 0],
                               nao_gw.mo_energy_gw[0, 0], gto_hf.mo_energy):
            self.assertAlmostEqual(e1, e2)
コード例 #8
0
  def test_nao_in_gw_pyscf(self):
    """ This is interacting polarizability with SIESTA starting point """
    from pyscf import gto, tddft, scf
    
    mol = gto.M( verbose = 0,
      atom = '''H 0.0 0.0 -0.3707;  H 0.0 0.0 0.3707''', basis = 'cc-pvdz',)

    gto_hf = scf.RKS(mol)
    gto_hf.xc = 'hf'
    gto_hf.kernel()
    nocc = mol.nelectron//2
    nmo = gto_hf.mo_energy.size
    nvir = nmo-nocc
    gto_td = tddft.dRPA(gto_hf)
    gto_td.nstates = min(100, nocc*nvir)
    gto_td.kernel()

    gto_gw = GW(gto_hf, gto_td)
    gto_gw.kernel()

    ww = np.arange(0.0,4.0,0.01)+1j*0.02
    pxx_xpy = -polariz_inter_xx(gto_hf, mol, gto_td, ww).imag
    data = np.array([ww.real*27.2114, pxx_xpy])
    fname = dname+'/h2_rpa_xpy_0098.omega.inter.pxx.txt'
    np.savetxt(fname, data.T, fmt=['%f','%f'])
    data_ref = np.loadtxt(fname+'-ref')
    self.assertTrue(np.allclose(data_ref,data.T, rtol=0.1, atol=1e-05))
 
    gw_nao = gw(gto=mol, mf=gto_hf, tdscf=gto_td)
    x  = gw_nao.moms1[:,0]
    
    rf_nao = gw_nao.rf( ww )
    pxx_nao = np.einsum('p,wpq,q->w', x, -rf_nao.imag, x)
    data = np.array([ww.real*27.2114, pxx_nao])
    fname = dname+'/h2_rpa_nao_0098.omega.inter.pxx.txt'
    np.savetxt(fname, data.T, fmt=['%f','%f'])
    data_ref = np.loadtxt(fname+'-ref')
    self.assertTrue(np.allclose(data_ref,data.T, rtol=0.1, atol=1e-05))

    rf_gto = gw_nao.rf_pyscf( ww )
    pxx_gto = np.einsum('p,wpq,q->w', x, -rf_gto.imag, x)
    data = np.array([ww.real*27.2114, pxx_gto])
    fname = dname+'/h2_rpa_gto_0098.omega.inter.pxx.txt'
    np.savetxt(fname, data.T, fmt=['%f','%f'])
    data_ref = np.loadtxt(fname+'-ref')
    self.assertTrue(np.allclose(data_ref,data.T, rtol=0.1, atol=1e-05))
コード例 #9
0
  def test_0167_cn_ugw_spin_contam(self):
    """ Interacting case """
    spin = 1
    mol=gto.M(verbose=0,atom='C 0 0 -0.6;N 0 0 0.52',basis='cc-pvdz',spin=spin)
    gto_mf = scf.UHF(mol)
    gto_mf.kernel()

    ss_2sp1 = gto_mf.spin_square()
    self.assertTrue(np.allclose(ss_2sp1, (0.9768175623447295, 2.2152359353754889)))
    
    nao_gw = gw(gto=mol, mf=gto_mf, verbosity=0)
    nao_gw.kernel_gw()
    #nao_gw.report()
    
    ss_2sp1 = nao_gw.spin_square()
    #print(' nao_gw.spin_square() ', ss_2sp1)
    self.assertTrue(np.allclose(ss_2sp1, (0.9767930087836918, 2.2152137673675574)))
コード例 #10
0
 def test_gw_h2_ae_spin_rf0_speed(self):
     """ This is GW """
     mol = gto.M(
         verbose=1,
         atom=
         '''H 0 0 0;  H 0 0 0.5; H 0 0 1.0; H 0 0 1.5; H 0 0 2.0; H 0 0 2.5;''',
         basis='cc-pvdz',
         spin=0)
     #mol = gto.M( verbose = 0, atom = '''H 0.0 0.0 -0.3707;  H 0.0 0.0 0.3707''', basis = 'cc-pvdz',)
     gto_mf = scf.UHF(mol)
     etot = gto_mf.kernel()
     #print(__name__, 'etot', etot)
     #print('gto_mf.mo_energy:', gto_mf.mo_energy)
     b = gw(mf=gto_mf, gto=mol, verbosity=0, nvrt=4)
     ww = np.arange(0.0, 1.0, 0.1) + 1j * 0.2
     rf0 = b.rf0(ww)
     rf0_ref = b.rf0_cmplx_ref(ww)
     #print(__name__, len(b.x), '|diff|', abs(rf0_ref-rf0).sum()/rf0.size)
     self.assertTrue(abs(rf0_ref - rf0).sum() / rf0.size < 1e-12)
コード例 #11
0
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

from __future__ import print_function, division
import os,unittest,numpy as np
from pyscf.nao import gw

dname = os.path.dirname(os.path.abspath(__file__))
td = gw(label='water', cd=dname, jcutoff=7, iter_broadening=1e-2)
x  = td.moms1[:,0]

class KnowValues(unittest.TestCase):

  def test_chi0_v_rf0(self):
    """ This is non-interacting polarizability with SIESTA starting point """
    omegas = np.arange(0.0,1.0,0.01)+1j*0.02
    rf0 = -td.rf0(omegas).imag
    pxx_rf = np.einsum('p,wpq,q->w', x, rf0, x)
    data_rf = np.array([omegas.real*27.2114, pxx_rf])
    np.savetxt(dname+'/water.tddft_iter_fm_0097.omega.nonin.pxx.txt', data_rf.T, fmt=['%f','%f'])
    data_ref = np.loadtxt(dname+'/water.tddft_iter_fm_0097.omega.nonin.pxx.txt-ref')
    self.assertTrue(np.allclose(data_ref,data_rf.T, rtol=1.0, atol=1e-05))

  def test_tddft_iter_v_rpa_rf(self):