Ejemplo n.º 1
0
    def test_newton_rohf(self):
        mf = solvent.PE(mol.ROHF(max_memory=0), potfile)
        mf = mf.newton()
        e = mf.kernel()
        self.assertAlmostEqual(e, -112.35232445745123, 9)

        mf = solvent.PE(mol.ROHF(max_memory=0), potfile)
        e = mf.kernel()
        self.assertAlmostEqual(e, -112.35232445745123, 9)
Ejemplo n.º 2
0
    def test_rhf_tda(self):
        # TDA with equilibrium_solvation
        mf = solvent.PE(mol.RHF(), potfile).run()
        td = solvent.PE(mf.TDA(), potfile).run(equilibrium_solvation=True)
        ref = numpy.array([0.1506426609354755, 0.338251407831332, 0.4471267328974609])
        self.assertAlmostEqual(abs(ref - td.e).max(), 0, 8)

        # TDA without equilibrium_solvation
        mf = solvent.PE(mol.RHF(), potfile).run()
        td = solvent.PE(mf.TDA(), potfile).run()
        ref = numpy.array([0.1506431269137912, 0.338254809044639, 0.4471487090255076])
        self.assertAlmostEqual(abs(ref - td.e).max(), 0, 8)
Ejemplo n.º 3
0
 def test_pol_embed_scf(self):
     mol = gto.Mole()
     mol.atom = '''
     C          8.64800        1.07500       -1.71100
     C          9.48200        0.43000       -0.80800
     C          9.39600        0.75000        0.53800
     C          8.48200        1.71200        0.99500
     C          7.65300        2.34500        0.05500
     C          7.73200        2.03100       -1.29200
     H         10.18300       -0.30900       -1.16400
     H         10.04400        0.25200        1.24700
     H          6.94200        3.08900        0.38900
     H          7.09700        2.51500       -2.01800
     N          8.40100        2.02500        2.32500
     N          8.73400        0.74100       -3.12900
     O          7.98000        1.33100       -3.90100
     O          9.55600       -0.11000       -3.46600
     H          7.74900        2.71100        2.65200
     H          8.99100        1.57500        2.99500
     '''
     mol.basis = "STO-3G"
     mol.build()
     pe_options = cppe.PeOptions()
     pe_options.potfile = os.path.join(dname, "pna_6w.potential")
     print(pe_options.potfile)
     pe = pol_embed.PolEmbed(mol, pe_options)
     mf = solvent.PE(scf.RHF(mol), pe)
     mf.conv_tol = 1e-10
     mf.kernel()
     ref_pe_energy = -0.03424830892844
     ref_scf_energy = -482.9411084900
     assert_allclose(ref_pe_energy, mf.with_solvent.e, atol=1e-6)
     assert_allclose(ref_scf_energy, mf.e_tot, atol=1e-6)
Ejemplo n.º 4
0
 def test_as_scanner(self):
     mf_scanner = solvent.PE(scf.RHF(mol), potfile).as_scanner()
     mf_scanner(mol)
     self.assertAlmostEqual(mf_scanner.with_solvent.e,
                            0.00020182314249546455, 9)
     mf_scanner('H  0. 0. 0.; H  0. 0. .9')
     self.assertAlmostEqual(mf_scanner.with_solvent.e,
                            5.2407234004672825e-05, 9)
Ejemplo n.º 5
0
 def test_as_scanner(self):
     mf = mol.RHF(chkfile=tempfile.NamedTemporaryFile().name)
     mf_scanner = solvent.PE(mf, potfile).as_scanner()
     mf_scanner(mol)
     self.assertAlmostEqual(mf_scanner.with_solvent.e,
                            0.00020182314249546455, 9)
     # Change solute. cppe may not support this
     mf_scanner('H  0. 0. 0.; H  0. 0. .9')
     self.assertAlmostEqual(mf_scanner.with_solvent.e,
                            5.2407234004672825e-05, 9)
Ejemplo n.º 6
0
    def test_exec_cppe(self):
        pe = solvent.PE(mol, os.path.join(dname, "pna_6w.potential"))
        numpy.random.seed(2)
        nao = mol.nao
        dm = numpy.random.random((2,nao,nao))
        dm = dm + dm.transpose(0,2,1)

        eref, vref = _exec_cppe(pe, dm[1], elec_only=False)
        e, v = pe._exec_cppe(dm, elec_only=False)
        self.assertAlmostEqual(abs(vref - v[1]).max(), 0, 10)

        eref, vref = _exec_cppe(pe, dm[0], elec_only=True)
        e, v = pe._exec_cppe(dm, elec_only=True)
        self.assertAlmostEqual(eref, e[0], 10)
        self.assertAlmostEqual(abs(vref - v[0]).max(), 0, 10)
Ejemplo n.º 7
0
H    43.151000    37.062000    37.180000
H    40.929000    35.954000    37.704000
H    39.378000    37.062000    39.158000
H    40.246000    38.878000    40.859000
"""
mol.basis = "6-31G*"
mol.build()
pe_options = cppe.PeOptions()
pe_options.do_diis = True
pe_options.potfile = "nilered_in_blg_1000WAT.pot"
pe = pol_embed.PolEmbed(mol, pe_options)
pe.verbose = 4

lib.num_threads(32)

mf = solvent.PE(scf.RKS(mol), pe)
mf.xc = "camb3lyp"
mf._numint.libxc = xcfun
mf.conv_tol = 1e-8
mf.verbose = 4
mf.kernel()

print(mf._pol_embed.cppe_state.summary_string)

td = TDA(mf)
td.verbose = 5
td.conv_tol = 1e-7
td.triplet = False
td.singlet = True
td.nstates = 3
evals, xy = td.kernel()
Ejemplo n.º 8
0
 def test_pe_scf(self):
     pe = solvent.PE(mol, potfile)
     mf = solvent.PE(mol.RHF(), pe).run(conv_tol=1e-10)
     self.assertAlmostEqual(mf.e_tot, -112.35232445743728, 9)
     self.assertAlmostEqual(mf.with_solvent.e, 0.00020182314249546455, 9)
Ejemplo n.º 9
0
 def test_pe_scf_ecp(self):
     pe = solvent.PE(mol2, {"potfile": potfile2, "ecp": True})
     mf = solvent.PE(mol2.RHF(), pe).run(conv_tol=1e-10)
     self.assertAlmostEqual(mf.e_tot, -168.147494986446, 8)
Ejemplo n.º 10
0
'''
A simple example of using polarizable embedding model in the mean-field
calculations. This example requires the cppe library

GitHub:      https://github.com/maxscheurer/cppe
Code:        10.5281/zenodo.3345696
Publication: https://doi.org/10.1021/acs.jctc.9b00758

The CPPE library can be installed via:
pip install git+https://github.com/maxscheurer/cppe.git

The potfile required by this example can be generated with the script
04-pe_potfile_from_pyframe.py
'''

import pyscf
from pyscf import solvent

mol = pyscf.M(atom='''
C        0.000000    0.000000             -0.542500
O        0.000000    0.000000              0.677500
H        0.000000    0.9353074360871938   -1.082500
H        0.000000   -0.9353074360871938   -1.082500
            ''',
            verbose = 4)
mf = mol.UKS()
mf.xc = 'b3lyp'
mf = solvent.PE(mf, '4NP_in_water/4NP_in_water.pot')
mf.run()

Ejemplo n.º 11
0
H    40.929000    35.954000    37.704000
H    39.378000    37.062000    39.158000
H    40.246000    38.878000    40.859000
    """,
    basis="cc-pvdz",
)

pe_options = cppe.PeOptions()
pe_options.do_diis = True
pe_options.potfile = "nilered_in_blg_1000WAT.pot"
pe = pol_embed.PolEmbed(mol, pe_options)
pe.verbose = 4

lib.num_threads(32)

scfres = solvent.PE(scf.RHF(mol), pe)
scfres.conv_tol = 1e-10
scfres.conv_tol_grad = 1e-8
scfres.verbose = 4
scfres.kernel()

print(adcc.banner())

# Run an adc2 calculation:
state = adcc.adc2(scfres, n_singlets=3, conv_tol=1e-5)

ptss_list = []
ptlr_list = []
# Print results
print()
print("  st  ex.ene. (au)         f     transition dipole moment (au)"