def run_core_hole(xyz, basis, charge=0, multiplicity=1, conv_tol=1e-12, conv_tol_grad=1e-8, max_iter=150): mol = gto.M( atom=xyz, basis=basis, unit="Bohr", # spin in the pyscf world is 2S spin=multiplicity - 1, charge=charge, # Disable commandline argument parsing in pyscf parse_arg=False, dump_input=False, verbose=0, ) # First normal run mf = scf.UHF(mol) mf.conv_tol = conv_tol mf.conv_tol_grad = conv_tol_grad mf.max_cycle = max_iter # since we want super tight convergence for tests, # tweak the options for non-RHF systems if multiplicity != 1: mf.max_cycle += 500 mf.diis = scf.EDIIS() mf.diis_space = 3 mf = scf.addons.frac_occ(mf) mf.kernel() # make beta core hole mo0 = tuple(c.copy() for c in mf.mo_coeff) occ0 = tuple(o.copy() for o in mf.mo_occ) occ0[1][0] = 0.0 dm0 = mf.make_rdm1(mo0, occ0) # Run second SCF with MOM mf_chole = scf.UHF(mol) scf.addons.mom_occ_(mf_chole, mo0, occ0) mf_chole.conv_tol = conv_tol mf_chole.conv_tol_grad = conv_tol_grad mf_chole.max_cycle += 500 mf_chole.diis = scf.EDIIS() mf_chole.diis_space = 3 mf_chole.kernel(dm0) return mf_chole
def run_hf(xyz, basis, charge=0, multiplicity=1, conv_tol=1e-12, conv_tol_grad=1e-8, max_iter=150): mol = gto.M( atom=xyz, basis=basis, unit="Bohr", # spin in the pyscf world is 2S spin=multiplicity - 1, charge=charge, # Disable commandline argument parsing in pyscf parse_arg=False, dump_input=False, verbose=0, ) mf = scf.HF(mol) mf.conv_tol = conv_tol mf.conv_tol_grad = conv_tol_grad mf.max_cycle = max_iter # since we want super tight convergence for tests, # tweak the options for non-RHF systems if multiplicity != 1: mf.max_cycle += 500 mf.diis = scf.EDIIS() mf.diis_space = 3 mf = scf.addons.frac_occ(mf) mf.kernel() return mf
def run_scf(self): fn = "cn_sto3g.hdf5" if os.path.isfile(fn): return fn mol = gto.M( atom=""" C 0 0 0 N 0 0 2.2143810738114829 """, spin=1, basis='sto-3g', unit="Bohr", ) mf = scf.UHF(mol) mf.conv_tol = 1e-11 mf.conv_tol_grad = 1e-10 mf.diis = scf.EDIIS() mf.diis_space = 5 mf.max_cycle = 500 mf.kernel() return atd.dump_pyscf(mf, fn)
## --------------------------------------------------------------------- import sys from pyscf import gto, scf from static_data import xyz from os.path import dirname, join sys.path.insert(0, join(dirname(__file__), "adcc-testdata")) import adcctestdata as atd # noqa: E402 # Run SCF in pyscf and converge super-tight using an EDIIS mol = gto.M(atom=xyz["h2o"], basis='def2-tzvp', unit="Bohr") mf = scf.RHF(mol) mf.conv_tol = 1e-13 mf.conv_tol_grad = 1e-12 mf.diis = scf.EDIIS() mf.diis_space = 3 mf.max_cycle = 500 mf.kernel() h5f = atd.dump_pyscf(mf, "h2o_def2tzvp_hfdata.hdf5") # Store configuration parameters for interesting cases to generate # reference data for. The data is stored as a stringified dict. h5f["reference_cases"] = str({ "gen": {}, "cvs": { "core_orbitals": 1 }, })
mf.run() mf.DIIS = scf.EDIIS mf.diis_space = 14 mf.run() # # 2. Overwrite the attribute mf.diis. In this approach, DIIS parameters # specified in the SCF object (mf.diis_space, mf.diis_file, ...) have no # effects. DIIS parameters need to be assigned to the diis object. # my_diis_obj = scf.ADIIS() my_diis_obj.space = 12 my_diis_obj.filename = 'o2_diis.h5' mf.diis = my_diis_obj mf.run() my_diis_obj = scf.EDIIS() my_diis_obj.space = 12 mf.diis = my_diis_obj mf.run() # # By creating an DIIS object and assigning it to the attribute mf.diis, we can # restore SCF iterations from an existed SCF calculation (see also the example # 14-restart.py) # mf = mol.RKS() mf.diis = scf.ADIIS().restore('h2o_diis.h5') mf.run()