示例#1
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'])
示例#2
0
from pyscf.pbc import gto, scf

cell = gto.M(
    a=numpy.eye(3) * 3.5668,
    atom='''C     0.      0.      0.    
              C     0.8917  0.8917  0.8917
              C     1.7834  1.7834  0.    
              C     2.6751  2.6751  0.8917
              C     1.7834  0.      1.7834
              C     2.6751  0.8917  2.6751
              C     0.      1.7834  1.7834
              C     0.8917  2.6751  2.6751''',
    basis='6-31g',
    verbose=4,
)

mf = scf.RHF(cell).density_fit()
mf.with_df.gs = [5] * 3
mf.kernel()

#
# Import CC, TDDFT moduel from the molecular implementations
#
from pyscf import cc, tddft
mycc = cc.CCSD(mf)
mycc.kernel()

mytd = tddft.TDHF(mf)
mytd.nstates = 5
mytd.kernel()
示例#3
0
import numpy
from pyscf import gto, scf, tddft, qmmm

mol = gto.M(atom='''
C       1.1879  -0.3829 0.0000
C       0.0000  0.5526  0.0000
O       -1.1867 -0.2472 0.0000
H       -1.9237 0.3850  0.0000
H       2.0985  0.2306  0.0000
H       1.1184  -1.0093 0.8869
H       1.1184  -1.0093 -0.8869
H       -0.0227 1.1812  0.8852
H       -0.0227 1.1812  -0.8852
            ''',
            basis='3-21g',
            verbose=4)

numpy.random.seed(1)
coords = numpy.random.random((5, 3)) * 10
charges = (numpy.arange(5) + 1.) * -.1

#
# Background charges have to be patched to the underlying SCF calculaitons.
#
mf = scf.RHF(mol)
mf = qmmm.mm_charge(mf, coords, charges).run()

tddft.TDA(mf).run()

tddft.TDHF(mf).run()
示例#4
0
#!/usr/bin/env python
#
# Author: Qiming Sun <*****@*****.**>
#
'''
TDDFT analytical nuclear gradients.
'''

from pyscf import gto, scf, dft, tddft

mol = gto.M(atom=[['O', 0., 0., 0], ['H', 0., -0.757, 0.587],
                  ['H', 0., 0.757, 0.587]],
            basis='ccpvdz')

mf = scf.RHF(mol).run()
postmf = tddft.TDHF(mf).run()
g = postmf.nuc_grad_method()
g.kernel(state=1)

mf = dft.RKS(mol).x2c().set(xc='pbe0').run()
# Switch to xcfun because 3rd order GGA functional derivative is not
# available in libxc
mf._numint.libxc = dft.xcfun
postmf = tddft.TDDFT(mf).run()
# PySCF-1.6.1 and newer supports the .Gradients method to create a grad
# object after grad module was imported. It is equivalent to call the
# .nuc_grad_method method.
from pyscf import grad
g = postmf.Gradients()
g.kernel(state=1)
示例#5
0

#
# RHF/RKS-TDDFT
#
def diagonalize(a, b, nroots=5):
    nocc, nvir = a.shape[:2]
    a = a.reshape(nocc * nvir, nocc * nvir)
    b = b.reshape(nocc * nvir, nocc * nvir)
    e = numpy.linalg.eig(numpy.bmat([[a, b], [-b.conj(), -a.conj()]]))[0]
    lowest_e = numpy.sort(e[e > 0])[:nroots]
    return lowest_e


mf = scf.RHF(mol).run()
a, b = tddft.TDHF(mf).get_ab()
print('Direct diagoanlization:', diagonalize(a, b))
print('Reference:', tddft.TDHF(mf).kernel(nstates=5)[0])

mf = dft.RKS(mol).run(xc='lda,vwn')
a, b = tddft.TDDFT(mf).get_ab()
print('Direct diagoanlization:', diagonalize(a, b))
print('Reference:', tddft.TDDFT(mf).kernel(nstates=5)[0])

mf = dft.RKS(mol).run(xc='b3lyp')
a, b = tddft.TDDFT(mf).get_ab()
print('Direct diagoanlization:', diagonalize(a, b))
print('Reference:', tddft.TDDFT(mf).kernel(nstates=5)[0])


#