def template_adc2_r2methyloxirane(self, basis): results = {} for b in backends: scfres = cached_backend_hf(b, "r2methyloxirane", basis, conv_tol=1e-10) results[b] = adcc.adc2(scfres, n_singlets=3, conv_tol=1e-9) compare_adc_results(results, 5e-8)
def base_test(self, system, **args): hf = DataHfProvider(cache.hfdata[system]) refdata = cache.reference_data[system] res = adcc.adc2(hf, n_singlets=9, **args) assert isinstance(res, ExcitedStates) ref = refdata["adc2"]["singlet"]["eigenvalues"] assert res.converged assert res.excitation_energy == approx(ref)
def template_adc2_uhf_ch2nh2(self, basis): results = {} # UHF not supported for VeloxChem if "veloxchem" in backends: backends.remove("veloxchem") if not len(backends): pytest.skip("Not enough backends that support UHF available.") for b in backends: scfres = cached_backend_hf(b, "ch2nh2", basis, multiplicity=2) results[b] = adcc.adc2(scfres, n_states=5, conv_tol=1e-10) compare_adc_results(results, 5e-9)
def run_spin_flip(distance): # Run SCF in pyscf mol = gto.M( atom='H 0 0 0;' 'F 0 0 {}'.format(distance), basis='6-31G', unit="Bohr", spin=2 # =2S, ergo triplet ) scfres = scf.UHF(mol) scfres.conv_tol = 1e-12 scfres.conv_tol_grad = 1e-8 scfres.kernel() # Run ADC and compute total energy states = adcc.adc2(scfres, n_spin_flip=1) ene = scfres.energy_tot() + states.ground_state.energy_correction(2) return ene + states.excitation_energy[0]
#!/usr/bin/env python3 ## vi: tabstop=4 shiftwidth=4 softtabstop=4 expandtab import adcc from import_data import import_data # Gather precomputed data data = import_data() # Run an adc2 calculation: singlets = adcc.adc2(data, n_singlets=5, conv_tol=1e-8) triplets = adcc.adc2(singlets.matrix, n_triplets=5, conv_tol=1e-8) print(singlets.describe()) print(triplets.describe())
def template_adc2_h2o(self, basis): results = {} for b in backends: scfres = cached_backend_hf(b, "h2o", basis) results[b] = adcc.adc2(scfres, n_singlets=5, conv_tol=1e-10) compare_adc_results(results, 5e-9)
# Make a core hole mo0 = copy.deepcopy(mf.mo_coeff) occ0 = copy.deepcopy(mf.mo_occ) occ0[1][0] = 0.0 # beta core hole dm = mf.make_rdm1(mo0, occ0) mf_core = scf.UHF(mol) mf_core.conv_tol = 1e-13 mf_core.conv_tol_grad = 1e-8 scf.addons.mom_occ(mf_core, mo0, occ0) mf_core.kernel(dm) del dm print("Water core hole energy", mf_core.energy_tot()) # Run an adc2 calculation: state = adcc.adc2(mf_core, n_states=4) # Print results in a nice way print() print(" st ex.ene. (au) f transition dipole moment (au)" " state dip (au)") for i, val in enumerate(state.excitation_energies): fmt = "{0:2d} {1:12.8g} {2:9.3g} [{3:9.3g}, {4:9.3g}, {5:9.3g}]" fmt += " [{6:9.3g}, {7:9.3g}, {8:9.3g}]" print( state.kind[0], fmt.format(i, val, state.oscillator_strengths[i], *state.transition_dipole_moments[i], *state.state_dipole_moments[i])) state.plot_spectrum()
#!/usr/bin/env python3 ## vi: tabstop=4 shiftwidth=4 softtabstop=4 expandtab import adcc import psi4 # Run SCF in psi4 mol = psi4.geometry(""" 0 3 H 0 0 0 F 0 0 2.5 symmetry c1 units au no_reorient no_com """) psi4.set_num_threads(adcc.thread_pool.n_cores) psi4.core.be_quiet() psi4.set_options({ 'basis': "6-31g", 'e_convergence': 1e-14, 'd_convergence': 1e-9, 'reference': 'uhf' }) scf_e, wfn = psi4.energy('SCF', return_wfn=True) # Run solver and print results states = adcc.adc2(wfn, n_spin_flip=5, conv_tol=1e-8) print(states.describe()) print(states.describe_amplitudes())
with open(infile, "w") as fp: fp.write(""" @jobs task: hf @end @method settings basis: sto-3g @end @molecule charge: 0 multiplicity: 1 units: bohr xyz: O 0 0 0 H 0 0 1.795239827225189 H 1.693194615993441 0 -0.599043184453037 @end """) task = MpiTask([infile, outfile], MPI.COMM_WORLD) scfdrv = vlx.ScfRestrictedDriver(task.mpi_comm, task.ostream) scfdrv.conv_thresh = 1e-8 scfdrv.compute(task.molecule, task.ao_basis, task.min_basis) scfdrv.task = task # Run an adc2 calculation: state = adcc.adc2(scfdrv, n_singlets=5) print(state.describe())
xyz: O 0 0 0 H 0 0 1.795239827225189 H 1.693194615993441 0 -0.599043184453037 @end """) task = MpiTask([infile, outfile], MPI.COMM_WORLD) scfdrv = vlx.ScfRestrictedDriver(task.mpi_comm, task.ostream) scfdrv.conv_thresh = 1e-9 scfdrv.compute(task.molecule, task.ao_basis, task.min_basis) scfdrv.task = task print(adcc.banner()) # Run an adc2 calculation: state = adcc.adc2(scfdrv, n_singlets=7, conv_tol=1e-8) print() print(" st ex.ene. (au) f transition dipole moment (au)" " state dip (au)") for i, val in enumerate(state.excitation_energy): fmt = "{0:2d} {1:12.8g} {2:9.3g} [{3:9.3g}, {4:9.3g}, {5:9.3g}]" fmt += " [{6:9.3g}, {7:9.3g}, {8:9.3g}]" print(state.kind[0], fmt.format(i, val, state.oscillator_strength[i], *state.transition_dipole_moment[i], *state.state_dipole_moment[i])) # Plot a spectrum state.plot_spectrum() plt.savefig("veloxchem_ccpvdz_adc2_spectrum.pdf") plt.show()
## vi: tabstop=4 shiftwidth=4 softtabstop=4 expandtab import adcc import psi4 mol = psi4.geometry(""" 0 3 O 0 0 0 H 0 0 1.795239827225189 H 1.693194615993441 0 -0.599043184453037 symmetry c1 units au """) # set the number of cores equal to the auto-determined value from # the adcc ThreadPool psi4.set_num_threads(adcc.get_n_threads()) psi4.core.be_quiet() psi4.set_options({ 'basis': "sto-3g", 'scf_type': 'pk', 'e_convergence': 1e-12, 'reference': 'uhf', 'd_convergence': 1e-8 }) scf_e, wfn = psi4.energy('SCF', return_wfn=True) # Run an adc2 calculation: state = adcc.adc2(wfn, n_states=5) print(state.describe())
#!/usr/bin/env python3 ## vi: tabstop=4 shiftwidth=4 softtabstop=4 expandtab import adcc from pyscf import gto, scf # Run SCF in pyscf mol = gto.M( atom='H 0 0 0;' 'F 0 0 2.5', basis='6-31G', unit="Bohr", spin=2 # =2S, ergo triplet ) scfres = scf.UHF(mol) scfres.conv_tol = 1e-14 scfres.conv_tol_grad = 1e-10 scfres.kernel() # Run solver and print results states = adcc.adc2(scfres, n_spin_flip=5, conv_tol=1e-8) print(states.describe())
#!/usr/bin/env python3 ## vi: tabstop=4 shiftwidth=4 softtabstop=4 expandtab import adcc from import_data import import_data # Gather precomputed data data = import_data() # Make it unrestricted data["restricted"] = False # Run an unrestricted adc2 calculation: states = adcc.adc2(data, n_states=10, conv_tol=1e-8) print(states.describe())
#!/usr/bin/env python3 ## vi: tabstop=4 shiftwidth=4 softtabstop=4 expandtab import adcc import psi4 mol = psi4.geometry(""" O 0 0 0 H 0 0 1.795239827225189 H 1.693194615993441 0 -0.599043184453037 symmetry c1 units au """) # set the number of cores equal to the auto-determined value from # the adcc ThreadPool psi4.set_num_threads(adcc.get_n_threads()) psi4.core.be_quiet() psi4.set_options({ 'basis': "sto-3g", 'scf_type': 'pk', 'e_convergence': 1e-12, 'd_convergence': 1e-8 }) scf_e, wfn = psi4.energy('SCF', return_wfn=True) # Run an adc2 calculation: state = adcc.adc2(wfn, n_singlets=5) print(state.describe())
S_mat = np.asarray(mints.ao_overlap()) molden_dict = {"basis_file": "n2.molden", "molecule": "molden"} s = pyopencap.System(molden_dict) s.check_overlap_mat(S_mat, "psi4") print('', end='', flush=True) cap_dict = { "cap_type": "box", "cap_x": "2.76", "cap_y": "2.76", "cap_z": "4.88", } nstates = 30 pc = pyopencap.CAP(s, cap_dict, nstates) # ground state energy state = adcc.adc2(wfn, n_singlets=1) E_0 = E + state.ground_state.energy_correction(2) print("MP2 energy of neutral:" + str(E_0)) # now starting anion calculation, starting from UHF reference mol = psi4.geometry(""" -1 2 N 0.0000000000 0.0000000000 0.548756750 N 0.0000000000 0.0000000000 -0.548756750 Gh(He) 0.0000000000 0.0000000000 0.000 Symmetry C1 """) psi4.qcdb.libmintsbasisset.basishorde[ 'ANONYMOUS03952CBD'] = basisspec_psi4_yo__anonymous03952cbd psi4.core.set_global_option("BASIS", "anonymous03952cbd") psi4.core.set_global_option("REFERENCE", "uhf")
#!/usr/bin/env python3 ## vi: tabstop=4 shiftwidth=4 softtabstop=4 expandtab import adcc from pyscf import gto, scf # Run SCF in pyscf mol = gto.M(atom='O 0 0 0;' 'H 0 0 1.795239827225189;' 'H 1.693194615993441 0 -0.599043184453037', basis='sto-3g', spin=2, unit="Bohr") scfres = scf.UHF(mol) scfres.conv_tol = 1e-8 scfres.conv_tol_grad = 1e-8 scfres.max_cycle = 100 scfres.verbose = 4 scfres.kernel() # Run an adc2 calculation: singlets = adcc.adc2(scfres, n_states=5) print(singlets.describe())
N_bas = gto.basis.load('n2.nw', 'N') mol = gto.M( atom = ' N 0.0000000000 0.0000000000 0.548756750;\ N 0.0000000000 0.0000000000 -0.548756750;\ ghost 0.0 0.0 0.0', basis = {'N': N_bas, 'ghost': ghost_bas} ) mol.build() scfres = scf.RHF(mol) scfres.kernel() # check overlap matrix pyscf_smat = scf.hf.get_ovlp(mol) s.check_overlap_mat(pyscf_smat,"pyscf") # run scf and mp2 on neutral state = adcc.adc2(scfres, n_singlets=1) E_0 = scfres.energy_tot() + state.ground_state.energy_correction(2) print("MP2 energy of neutral:" + str(E_0)) # run scf and mp2 on anion mol.charge = -1 mol.spin = 1 mol.build() scfres = scf.UHF(mol) scfres.kernel() # now run adc state = adcc.adc2(scfres, n_states=nstates) print(state.describe()) E_0 = scfres.energy_tot() + state.ground_state.energy_correction(2) print("MP2 energy of anion:" + str(E_0))
#!/usr/bin/env python3 ## vi: tabstop=4 shiftwidth=4 softtabstop=4 expandtab import adcc from import_data import import_data # Gather precomputed data data = import_data() # Run an adc2 calculation: singlets = adcc.adc2(data, frozen_core=1, n_singlets=5, conv_tol=1e-8) triplets = adcc.adc2(singlets.matrix, frozen_core=1, n_triplets=5, conv_tol=1e-8) print(singlets.describe()) print(triplets.describe())
#!/usr/bin/env python3 ## vi: tabstop=4 shiftwidth=4 softtabstop=4 expandtab import adcc import molsturm # Run SCF in molsturm atoms = ["O", "H", "H"] coords = [[0, 0, 0], [0, 0, 1.795239827225189], [1.693194615993441, 0, -0.599043184453037]] system = molsturm.System(atoms, coords) hfres = molsturm.hartree_fock(system, basis_type="gaussian", basis_set_name="sto-3g", conv_tol=1e-12, print_iterations=True) # Run an adc2 calculation: singlets = adcc.adc2(hfres, n_singlets=5, conv_tol=1e-9) triplets = adcc.adc2(singlets.matrix, n_triplets=3, conv_tol=1e-9) print(singlets.describe()) print(triplets.describe())
# set the number of cores equal to the auto-determined value from # the adcc ThreadPool psi4.set_num_threads(adcc.thread_pool.n_cores) psi4.core.be_quiet() psi4.set_options({ 'basis': "cc-pvdz", 'scf_type': 'pk', 'e_convergence': 1e-14, 'd_convergence': 1e-9 }) scf_e, wfn = psi4.energy('SCF', return_wfn=True) print(adcc.banner()) # Run an adc2 calculation: state = adcc.adc2(wfn, n_singlets=7, conv_tol=1e-8) # Print results print() print(" st ex.ene. (au) f transition dipole moment (au)" " state dip (au)") for i, val in enumerate(state.excitation_energies): fmt = "{0:2d} {1:12.8g} {2:9.3g} [{3:9.3g}, {4:9.3g}, {5:9.3g}]" fmt += " [{6:9.3g}, {7:9.3g}, {8:9.3g}]" print( state.kind[0], fmt.format(i, val, state.oscillator_strengths[i], *state.transition_dipole_moments[i], *state.state_dipole_moments[i])) state.plot_spectrum()
#!/usr/bin/env python3 ## vi: tabstop=4 shiftwidth=4 softtabstop=4 expandtab from pyscf import gto, scf from matplotlib import pyplot as plt import adcc # pyscf-H2O Hartree-Fock calculation mol = gto.M(atom='O 0 0 0;' 'H 0 0 1.795239827225189;' 'H 1.693194615993441 0 -0.599043184453037', basis='cc-pvtz', unit="Bohr") scfres = scf.RHF(mol) scfres.conv_tol = 1e-13 scfres.kernel() plt.figure(figsize=(7, 5)) state = adcc.adc2(scfres, n_singlets=10) state.plot_spectrum() plt.savefig("plot_spectrum_water.png", bbox="tight") plt.close()
# Run SCF in pyscf mol = gto.M( atom='O 0 0 0;' 'H 0 0 1.795239827225189;' 'H 1.693194615993441 0 -0.599043184453037', basis='aug-cc-pvdz', unit="Bohr" ) scfres = scf.RHF(mol) scfres.conv_tol = 1e-12 scfres.conv_tol_grad = 1e-9 scfres.kernel() # solve for Eigenvalues state = adcc.adc2(scfres, n_singlets=1, conv_tol=1e-8) # setup modified transition moments dips = state.reference_state.operators.electric_dipole rhss = [ compute_modified_transition_moments(state.matrix, dip, "adc2") for dip in dips ] S = np.zeros((len(state.excitation_energies), 3, 3)) for f, ee in enumerate(state.excitation_energies): freq = ee / 2.0 matrix = ShiftedMat("adc2", state.ground_state, freq) preconditioner = JacobiPreconditioner(matrix) explicit_symmetrisation = IndexSymmetrisation(matrix) preconditioner.update_shifts(freq)
#!/usr/bin/env python3 ## vi: tabstop=4 shiftwidth=4 softtabstop=4 expandtab import adcc from pyscf import gto, scf # Run SCF in pyscf mol = gto.M(atom='O 0 0 0;' 'H 0 0 1.795239827225189;' 'H 1.693194615993441 0 -0.599043184453037', basis='sto-3g', unit="Bohr") scfres = scf.RHF(mol) scfres.conv_tol = 1e-14 scfres.conv_tol_grad = 1e-10 scfres.kernel() # Run an adc2 calculation: singlets = adcc.adc2(scfres, n_singlets=5) triplets = adcc.adc2(singlets.matrix, n_triplets=3) print(singlets.describe()) print() print(triplets.describe())
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 symmetry c1 no_reorient no_com """) psi4.core.set_num_threads(4) psi4.set_options({ 'basis': "sto-3g", 'scf_type': 'pk', 'pe': 'true', 'e_convergence': 1e-10, 'd_convergence': 1e-10 }) psi4.set_module_options("pe", {"potfile": "pna_6w.pot"}) scf_e, wfn = psi4.energy('SCF', return_wfn=True) # Run an adc2 calculation: state = adcc.adc2(wfn, n_singlets=5, conv_tol=1e-8, environment=True) print(state.describe())
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 """, basis='sto-3g', ) scfres = PE(scf.RHF(mol), {"potfile": "pna_6w.pot"}) scfres.conv_tol = 1e-8 scfres.conv_tol_grad = 1e-6 scfres.max_cycle = 250 scfres.kernel() # model the solvent through perturbative corrections state_pt = adcc.adc2(scfres, n_singlets=5, conv_tol=1e-5, environment=['ptss', 'ptlr']) # now model the solvent through linear-response coupling # in the ADC matrix, re-using the matrix from previous run. # This will modify state_pt.matrix state_lr = adcc.run_adc(state_pt.matrix, n_singlets=5, conv_tol=1e-5, environment='linear_response') print(state_pt.describe()) print(state_lr.describe())