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)
def PE(method_or_mol, solvent_obj, dm=None): '''Initialize polarizable embedding model. Args: method_or_mol (pyscf method object or gto.Mole object) If method_or_mol is gto.Mole object, this function returns a PolEmbed object constructed with this Mole object. solvent_obj (PolEmbed object or cppe.PeOptions object or str) If solvent_obj is an object of PolEmbed class, the PE-enabled method will be created using solvent_obj. If solvent_obj is cppe.PeOptions or str, an PolEmbed object will be created first with the solvent_obj, on top of which PE-enabled method will be created. Examples: >>> pe_options = cppe.PeOptions() >>> pe_options.potfile = "pyframe.pot" >>> mf = PE(scf.RHF(mol), pe_options) >>> mf.kernel() ''' from pyscf.solvent import pol_embed from pyscf import gto, scf, mcscf, tdscf if isinstance(method_or_mol, gto.mole.Mole): return pol_embed.PolEmbed(method_or_mol, solvent_obj) elif isinstance(method_or_mol, scf.hf.SCF): return pol_embed.pe_for_scf(method_or_mol, solvent_obj, dm) elif isinstance(method_or_mol, mcscf.mc1step.CASSCF): return pol_embed.pe_for_casscf(method_or_mol, solvent_obj, dm) elif isinstance(method_or_mol, mcscf.casci.CASCI): return pol_embed.pe_for_casci(method_or_mol, solvent_obj, dm) elif isinstance(method_or_mol, (tdscf.rhf.TDA, tdscf.rhf.TDHF)): return pol_embed.pe_for_tdscf(method_or_mol, solvent_obj, dm) else: return pol_embed.pe_for_post_scf(method_or_mol, solvent_obj, dm)
H 42.475000 49.165000 42.501000 H 40.832000 44.272000 44.125000 H 40.325000 42.016000 43.331000 H 44.291000 44.409000 41.560000 H 45.508000 40.786000 39.175000 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