def test_opt2_allene(): refnucenergy = 59.2532646680161 # TEST refenergy = -115.8302823663 # TEST # starting point is D2d/c2v allene = psi4.geometry( """ H 0.0 -0.92 -1.8 H 0.0 0.92 -1.8 C 0.0 0.00 -1.3 C 0.0 0.00 0.0 C 0.0 0.00 1.3 H 0.92 0.00 1.8 H -0.92 0.00 1.8 """ ) psi4.core.clean_options() psi4_options = { "basis": "DZ", "e_convergence": 10, "d_convergence": 10, "scf_type": "pk", } psi4.set_options(psi4_options) json_output = optking.optimize_psi4("hf") E = json_output["energies"][-1] nucenergy = json_output["trajectory"][-1]["properties"]["nuclear_repulsion_energy"] assert psi4.compare_values(refnucenergy, nucenergy, 2, "Nuclear repulsion energy") # TEST assert psi4.compare_values(refenergy, E, 6, "Reference energy") # TEST # central C-C-C bond angle starts around 170 degrees to test the dynamic addition # of new linear bending coordinates, and the redefinition of dihedrals. allene = psi4.geometry( """ H 0.0 -0.92 -1.8 H 0.0 0.92 -1.8 C 0.0 0.00 -1.3 C 0.0 0.10 0.0 C 0.0 0.00 1.3 H 0.92 0.00 1.8 H -0.92 0.00 1.8 """ ) psi4.set_options(psi4_options) json_output = optking.optimize_psi4("hf") E = json_output["energies"][-1] nucenergy = json_output["trajectory"][-1]["properties"]["nuclear_repulsion_energy"] assert psi4.compare_values(refnucenergy, nucenergy, 2, "Nuclear repulsion energy") # TEST assert psi4.compare_values(refenergy, E, 6, "Reference energy") # TEST
def test_dcft_O2(): o2 = psi4.geometry(""" 0 3 O O 1 R R = 1.230 """) psi4.core.clean_options() psi4_options = { 'r_convergence': 10, 'algorithm': 'twostep', 'response_algorithm': 'twostep', 'basis': 'dzp', 'max_disp_g_convergence': 1e-6, 'rms_force_g_convergence': 1e-6, 'max_energy_g_convergence': 1e-7, 'reference': 'uhf', 'dct_functional': 'dc-06' } psi4.set_options(psi4_options) result = optking.optimize_psi4('dct') this_uhf = result['trajectory'][-1]['properties'][ 'scf_total_energy'] #TEST this_mp2 = result['trajectory'][-1]['properties'][ 'mp2_total_energy'] #TEST this_dct = result['energies'][-1] #TEST REF_uhf = -149.6520519320 #TEST REF_mp2 = -150.0109986566 #TEST REF_dct = -150.0227937862 #TEST assert psi4.compare_values(REF_uhf, this_uhf, 6, "UHF Energy") #TEST assert psi4.compare_values(REF_mp2, this_mp2, 6, "MP2 Energy") #TEST assert psi4.compare_values(REF_dct, this_dct, 6, "DC-06 Energy (two-step response)") #TEST # Now try alternative response psi4.set_options({'response_algorithm': 'simultaneous'}) o2.R = 1.232 result = optking.optimize_psi4('dct') this_uhf = result['trajectory'][-1]['properties']['scf_total_energy'] this_mp2 = result['trajectory'][-1]['properties']['mp2_total_energy'] this_dct = result['energies'][-1] assert psi4.compare_values(REF_uhf, this_uhf, 6, "UHF Energy") assert psi4.compare_values(REF_mp2, this_mp2, 6, "MP2 Energy") assert psi4.compare_values(REF_dct, this_dct, 6, "DC-06 Energy (simultaneous response)")
def test_ccsd_h2o(): h2o = psi4.geometry(""" O H 1 0.97 H 1 0.97 2 103.0 """) psi4.core.clean_options() psi4_options = {'basis': '6-31G**', 'scf_type': 'pk'} psi4.set_options(psi4_options) result = optking.optimize_psi4('ccsd') this_scf = result['trajectory'][-1]['properties'][ 'scf_total_energy'] #TEST this_ccsd = result['trajectory'][-1]['properties'][ 'ccsd_correlation_energy'] #TEST this_total = result['trajectory'][-1]['properties']['return_energy'] #TEST REF_scf = -76.0229406477 #TEST REF_ccsd = -0.2082378354 #TEST REF_total = -76.2311784830 #TEST assert psi4.compare_values(REF_scf, this_scf, 4, "SCF energy") #TEST assert psi4.compare_values(REF_ccsd, this_ccsd, 4, "CCSD contribution") #TEST assert psi4.compare_values(REF_total, this_total, 4, "Total energy") #TEST
def test_hooh_irc(): energy_5th_IRC_pt = -150.812913276783 # TEST h2o2 = psi4.geometry(""" H 0.0000000000 0.9803530335 -0.8498671785 O 0.0000000000 0.6988545188 0.0536419016 O 0.0000000000 -0.6988545188 0.0536419016 H 0.0000000000 -0.9803530335 -0.8498671785 """) # Necessary since IRC will break C2h. h2o2.reset_point_group('c2') psi4.core.clean_options() psi4_options = { 'basis': 'dzp', 'scf_type': 'pk', "g_convergence": "gau_verytight", 'opt_type': 'irc', 'geom_maxiter': 20} psi4.set_options(psi4_options) json_output = optking.optimize_psi4('hf') print(json_output) IRC = json_output['extras']['irc_rxn_path'] print("%15s%15s%20s%15s" % ('Step Number', 'Arc Distance', 'Energy', 'HOOH dihedral')) for step in IRC: print("%15d%15.5f%20.10f%15.5f" % (step['Step Number'], step['Arc Distance'], step['Energy'], step['Intco Values'][5] )) assert psi4.compare_values(energy_5th_IRC_pt, IRC[5]['Energy'], 6, "Energy of 5th IRC point.") #TEST
def test_ccsd_h2o(): h2o = psi4.geometry( """ O H 1 0.97 H 1 0.97 2 103.0 """ ) psi4.core.clean_options() psi4_options = {"basis": "6-31G**", "scf_type": "pk"} psi4.set_options(psi4_options) result = optking.optimize_psi4("ccsd") print(result["trajectory"][-1].keys()) this_scf = result["trajectory"][-1]["properties"]["scf_total_energy"] # TEST this_ccsd = result["trajectory"][-1]["properties"]["ccsd_correlation_energy"] # TEST this_total = result["trajectory"][-1]["properties"]["return_energy"] # TEST REF_scf = -76.0229406477 # TEST REF_ccsd = -0.2082378354 # TEST REF_total = -76.2311784830 # TEST assert psi4.compare_values(REF_scf, this_scf, 4, "SCF energy") # TEST assert psi4.compare_values(REF_ccsd, this_ccsd, 4, "CCSD contribution") # TEST assert psi4.compare_values(REF_total, this_total, 4, "Total energy") # TEST
def test_sosmp2_opt(): h2o = psi4.geometry( """ 0 1 o h 1 0.958 h 1 0.958 2 104.4776 """ ) psi4.core.clean_options() psi4_options = {"basis": "cc-pvdz", "max_energy_g_convergence": 7} psi4.set_options(psi4_options) result = optking.optimize_psi4("sos-omp2") this_nuc = result["trajectory"][-1]["properties"]["nuclear_repulsion_energy"] # TEST this_scf = result["trajectory"][-1]["properties"]["scf_total_energy"] # TEST this_energy = result["energies"][-1] # TEST REF_nuc = 9.1236764248 # TEST REF_scf = -76.0262152850 # TEST REF_sosomp2 = -76.2106507336 # TEST assert psi4.compare_values(REF_nuc, this_nuc, 3, "Nuclear Repulsion Energy (a.u.)") # TEST assert psi4.compare_values(REF_scf, this_scf, 6, "SCF Energy (a.u.)") # TEST assert psi4.compare_values(REF_sosomp2, this_energy, 6, "SOS-OMP2 Total Energy (a.u.)")
def test_maxiter_geom(): h2o = psi4.geometry(""" O H 1 1.0 H 1 1.0 2 104.5 """) psi4.core.clean_options() psi4options = { 'basis': 'cc-pvdz', 'e_convergence': 10, 'd_convergence': 10, 'scf_type': 'pk', 'geom_maxiter': 2 } psi4.set_options(psi4options) result = optking.optimize_psi4('hf') nextStepSchema = result['final_molecule'] #TEST nextStepMolecule = psi4.core.Molecule.from_schema(nextStepSchema) #TEST psi4.core.set_active_molecule(nextStepMolecule) #TEST nextStepEnergy = psi4.driver.energy('scf') #TEST REF_energy = -76.0270381300 #TEST assert psi4.compare_values(REF_energy, nextStepEnergy, 5, 'Energy of next-step molecule') #TEST
def test_maxiter(): h2o = psi4.geometry(""" O H 1 1.0 H 1 1.0 2 104.5 """) psi4.core.clean_options() psi4options = { #Throw a bunch of options at psi4 'diis': 0, 'basis': 'STO-3G', 'e_convergence': 1e-10, 'd_convergence': 1e-10, 'scf_type': 'PK', 'geom_maxiter': 2, } psi4.set_options(psi4options) json_output = optking.optimize_psi4('hf') assert 'geom_maxiter' in json_output['keywords'] #TEST assert "Maximum number of steps exceeded" in json_output['error'][ 'error_message'] #TEST assert "OptError" in json_output['error']['error_type'] #TEST
def test_scsmp2_opt(): h2o = psi4.geometry(""" 0 1 o h 1 0.958 h 1 0.958 2 104.4776 """) psi4.core.clean_options() psi4_options = { 'basis': 'cc-pvdz', 'max_energy_g_convergence': 7 } psi4.set_options(psi4_options) result = optking.optimize_psi4('scs-omp2') this_nuc = result['trajectory'][-1]['properties']['nuclear_repulsion_energy'] #TEST this_scf = result['trajectory'][-1]['properties']['scf_total_energy'] #TEST this_energy = result['energies'][-1] #TEST REF_nuc = 9.1123208123 REF_scf = -76.0260868661 REF_scsomp2 = -76.2280452486 assert psi4.compare_values(REF_nuc, this_nuc, 3, "Nuclear Repulsion Energy (a.u.)"); #TEST assert psi4.compare_values(REF_scf, this_scf, 6, "SCF Energy (a.u.)"); #TEST assert psi4.compare_values(REF_scsomp2, this_energy, 6, "SCS-OMP2 Total Energy (a.u.)"); #TEST
def test_maxiter(): h2o = psi4.geometry(""" O H 1 1.0 H 1 1.0 2 104.5 """) psi4.core.clean_options() psi4options = { # Throw a bunch of options at psi4 "diis": 0, "basis": "STO-3G", "e_convergence": 1e-10, "d_convergence": 1e-10, "scf_type": "PK", "geom_maxiter": 2, } psi4.set_options(psi4options) json_output = optking.optimize_psi4("hf") assert "geom_maxiter" in json_output["keywords"] # TEST assert "Maximum number of steps exceeded" in json_output["error"][ "error_message"] # TEST assert "OptError" in json_output["error"]["error_type"] # TEST
def test_linesearch(): Ar2 = psi4.geometry(""" Ar Ar 1 5.0 """) psi4.core.clean_options() psi4_options = { 'basis': 'cc-pvdz', 'd_convergence': 10, 'geom_maxiter': 20, 'g_convergence': 'gau_tight' } psi4.set_options(psi4_options) # For some reason this works but setting it through set_options throws an error psi4.set_module_options("OPTKING", {"step_type": "linesearch"}) json_output = optking.optimize_psi4('mp2') E = json_output['energies'][-1] nucenergy = json_output['trajectory'][-1]['properties'][ 'nuclear_repulsion_energy'] assert psi4.compare_values(nucenergy, nucenergy, 3, "Nuclear repulsion energy") #TEST assert psi4.compare_values(refenergy, E, 1, "Reference energy") #TEST
def test_ch2_with_dummy_atoms(): ch2 = psi4.geometry(""" 0 3 c x 1 1.0 h 1 b1 2 a1 h 1 b1 2 a1 3 180.0 b1 = 1.0 a1 = 60.0 """) psi4.core.clean_options() psi4_options = { 'reference': 'uhf', 'basis': '6-31G(d,p)', 'docc': [2, 0, 0, 1], 'socc': [1, 0, 1, 0], 'scf_type': 'pk' } psi4.set_options(psi4_options) json_output = optking.optimize_psi4('hf') thisenergy = json_output['energies'][-1] nucenergy = json_output['trajectory'][-1]['properties'][ 'nuclear_repulsion_energy'] assert psi4.compare_values(nucrefenergy, nucenergy, 3, "Nuclear repulsion energy") #TEST assert psi4.compare_values(refenergy, thisenergy, 6, "Reference energy") #TEST
def test_frozen_cart_h2o(): h2o = psi4.geometry(""" O 1.000000 1.000000 1.000000 H 2.000000 1.000000 1.000000 H 1.000000 2.000000 1.000000 units angstrom no_com no_reorient """) psi4.core.clean_options() psi4_options = { 'basis': 'cc-pvdz', 'reference': 'rhf', 'scf_type': 'df', 'max_energy_g_convergence': 7 } psi4.set_options(psi4_options) psi4.set_module_options("OPTKING", {'frozen_cartesian': '''1 xyz'''}) json_output = optking.optimize_psi4('hf') thisenergy = json_output['energies'][-1] assert psi4.compare_values(-76.0270327834836, thisenergy, 6, "RHF Energy") assert psi4.compare_values(h2o.x(0), 1.88972613289, 6, "X Frozen coordinate") assert psi4.compare_values(h2o.y(0), 1.88972613289, 6, "Y Frozen coordinate") assert psi4.compare_values(h2o.z(0), 1.88972613289, 6, "Z Frozen coordinate")
def test_hooh_freeze_xyz_Hs(options, expected): hooh = psi4.geometry(""" H 0.90 0.80 0.5 O 0.00 0.70 0.0 O 0.00 -0.70 0.0 H -0.90 -0.80 0.5 """) psi4.core.clean_options() psi4_options = { 'basis': 'cc-pvdz', 'opt_coordinates': 'cartesian', 'g_convergence': 'gau_tight', 'geom_maxiter': 20, 'consecutive_backsteps': 1 } psi4.set_options(psi4_options) psi4.set_module_options("OPTKING", options) json_output = optking.optimize_psi4('hf') thisenergy = json_output['energies'][-1] #TEST assert psi4.compare_values(expected, thisenergy, 6) #TEST
def test_hooh_TS(): # Optimization to 180 degree torsion from 120 hooh = psi4.geometry(""" 0 1 H O 1 0.95 O 2 1.40 1 105.0 H 3 0.95 2 105.0 1 120.0 """) psi4.core.clean_options() psi4options = { 'basis': 'cc-pvdz', 'geom_maxiter': 20, 'opt_type': 'TS', 'scf_type': 'pk', 'docc': [5, 4], 'intrafrag_step_limit': 0.1 } psi4.set_options(psi4options) json_output = optking.optimize_psi4('hf') # Uses default program (psi4) E = json_output['energies'][-1] assert psi4.compare_values( TORS_ENERGY, E, 6, "cc-pVDZ RHF transition-state opt. of HOOH (dihedral=180), energy" ) #TEST
def test_b3lyp_phenylacetylene(): phenylacetylene = psi4.geometry(""" 0 1 C 0.50424 2.62143 -1.86897 C -0.79405 2.10443 -1.80601 C -1.78491 2.59819 -2.66154 C -1.47738 3.60745 -3.57782 C -0.17996 4.12418 -3.64086 C 0.81143 3.63137 -2.78697 H 1.27012 2.23852 -1.20693 H -2.24344 3.98980 -4.23978 H 0.05756 4.90505 -4.35040 H -1.03189 1.32372 -1.09717 H -2.78881 2.19838 -2.61341 C 2.14399 4.16411 -2.85667 C 3.26501 4.60083 -2.90366 H 4.24594 4.99166 -2.95361 """) psi4.core.clean_options() psi4_options = { "guess": "sad", "basis": "cc-pVDZ", } psi4.set_options(psi4_options) result = optking.optimize_psi4("B3LYP") REF_b3lyp_E = -308.413691796 # TEST E = result["energies"][-1] # TEST assert psi4.compare_values(REF_b3lyp_E, E, 5, "B3LYP energy") # TEST
def test_hf_g_h2o(): h2o = psi4.geometry(""" O H 1 1.0 H 1 1.0 2 104.5 """) psi4.core.clean_options() psi4_options = { "diis": False, "basis": "sto-3g", "e_convergence": 10, "d_convergence": 10, "scf_type": "pk", } psi4.set_options(psi4_options) json_output = optking.optimize_psi4("hf") E = json_output["energies"][-1] # TEST nucenergy = json_output["trajectory"][-1]["properties"][ "nuclear_repulsion_energy"] # TEST refnucenergy = 8.9064983474 # TEST refenergy = -74.9659011923 # TEST assert psi4.compare_values(refnucenergy, nucenergy, 3, "Nuclear repulsion energy") # TEST assert psi4.compare_values(refenergy, E, 6, "Reference energy") # TEST
def test_B_dB_matrices(): hooh = psi4.geometry(""" H O 1 0.9 O 2 1.4 1 100.0 H 3 0.9 2 100.0 1 114.0 """) psi4.core.clean_options() psi4_options = { "basis": "cc-pvdz", "g_convergence": "gau_tight", "scf_type": "pk", "TEST_B": True, "TEST_DERIVATIVE_B": True, "G_CONVERGENCE": "gau_tight", } psi4.set_options(psi4_options) json_output = optking.optimize_psi4("hf") # Uses default program (psi4) E = json_output["energies"][-1] # TEST nucenergy = json_output["trajectory"][-1]["properties"][ "nuclear_repulsion_energy"] # TEST refnucenergy = 38.06177 # TEST refenergy = -150.786766850 # TEST assert "test_b" in json_output["keywords"] # TEST assert "test_derivative_b" in json_output["keywords"] # TEST assert "g_convergence" in json_output["keywords"] # TEST assert psi4.compare_values(refnucenergy, nucenergy, 3, "Nuclear repulsion energy") # TEST assert psi4.compare_values(refenergy, E, 8, "Reference energy") # TEST
def test_sosmp3_opt(): h2o = psi4.geometry(""" 0 1 o h 1 0.958 h 1 0.958 2 104.4776 """) psi4.core.clean_options() psi4_options = { 'basis': 'cc-pvdz', 'max_energy_g_convergence': 7 } psi4.set_options(psi4_options) result = optking.optimize_psi4('sos-omp3') this_nuc = result['trajectory'][-1]['properties']['nuclear_repulsion_energy'] #TEST this_scf = result['trajectory'][-1]['properties']['scf_total_energy'] #TEST this_energy = result['energies'][-1] #TEST REF_nuc = 9.1134855397 #TEST REF_scf = -76.0261191302 #TEST REF_sosomp3 = -76.2277207554 #TEST assert psi4.compare_values(REF_nuc, this_nuc, 3, "Nuclear Repulsion Energy (a.u.)"); #TEST assert psi4.compare_values(REF_scf, this_scf, 6, "SCF Energy (a.u.)"); #TEST assert psi4.compare_values(REF_sosomp3, this_energy, 6, "SOS-OMP3 Total Energy (a.u.)"); #TEST
def test_maxiter_geom(): h2o = psi4.geometry(""" O H 1 1.0 H 1 1.0 2 104.5 """) psi4.core.clean_options() psi4options = { "basis": "cc-pvdz", "e_convergence": 10, "d_convergence": 10, "scf_type": "pk", "geom_maxiter": 2 } psi4.set_options(psi4options) result = optking.optimize_psi4("hf") nextStepSchema = result["final_molecule"] # TEST nextStepMolecule = psi4.core.Molecule.from_schema(nextStepSchema) # TEST psi4.core.set_active_molecule(nextStepMolecule) # TEST psi4.set_options(psi4options) nextStepEnergy = psi4.driver.energy("scf/cc-pvdz") # TEST REF_energy = -76.0270381300 # TEST assert psi4.compare_values(REF_energy, nextStepEnergy, 5, "Energy of next-step molecule")
def test_B_dB_matrices(): hooh = psi4.geometry(""" H O 1 0.9 O 2 1.4 1 100.0 H 3 0.9 2 100.0 1 114.0 """) psi4.core.clean_options() psi4_options = { 'basis': 'cc-pvdz', 'g_convergence': 'gau_tight', 'scf_type': 'pk', 'TEST_B': True, 'TEST_DERIVATIVE_B': True, "G_CONVERGENCE": "gau_tight" } psi4.set_options(psi4_options) json_output = optking.optimize_psi4('hf') # Uses default program (psi4) E = json_output['energies'][-1] #TEST nucenergy = json_output['trajectory'][-1]['properties'][ 'nuclear_repulsion_energy'] #TEST refnucenergy = 38.06177 #TEST refenergy = -150.786766850 #TEST assert 'test_b' in json_output['keywords'] #TEST assert 'test_derivative_b' in json_output['keywords'] #TEST assert "g_convergence" in json_output['keywords'] #TEST assert psi4.compare_values(refnucenergy, nucenergy, 3, "Nuclear repulsion energy") #TEST assert psi4.compare_values(refenergy, E, 8, "Reference energy") #TEST
def test_hooh_irc(): energy_5th_IRC_pt = -150.812913276783 # TEST h2o2 = psi4.geometry(""" H 0.0000000000 0.9803530335 -0.8498671785 O 0.0000000000 0.6988545188 0.0536419016 O 0.0000000000 -0.6988545188 0.0536419016 H 0.0000000000 -0.9803530335 -0.8498671785 """) # Necessary since IRC will break C2h. h2o2.reset_point_group("c2") psi4.core.clean_options() psi4_options = { "basis": "dzp", "scf_type": "pk", "g_convergence": "gau_verytight", "opt_type": "irc", "geom_maxiter": 20, } psi4.set_options(psi4_options) json_output = optking.optimize_psi4("hf") print(json_output) IRC = json_output["extras"]["irc_rxn_path"] print("%15s%15s%20s%15s" % ("Step Number", "Arc Distance", "Energy", "HOOH dihedral")) for step in IRC: print("%15d%15.5f%20.10f%15.5f" % (step["Step Number"], step["Arc Distance"], step["Energy"], step["Intco Values"][5])) assert psi4.compare_values(energy_5th_IRC_pt, IRC[5]["Energy"], 6, "Energy of 5th IRC point.") # TEST
def test_scsmp3_opt(): h2o = psi4.geometry( """ 0 1 o h 1 0.958 h 1 0.958 2 104.4776 """ ) psi4.core.clean_options() psi4_options = {"basis": "cc-pvdz", "max_energy_g_convergence": 7} psi4.set_options(psi4_options) result = optking.optimize_psi4("scs-omp3") this_nuc = result["trajectory"][-1]["properties"]["nuclear_repulsion_energy"] # TEST this_scf = result["trajectory"][-1]["properties"]["scf_total_energy"] # TEST this_energy = result["energies"][-1] # TEST REF_nuc = 9.1193753755 # TEST REF_scf = -76.0261614278 # TEST REF_scsomp3 = -76.2296260036 # TEST assert psi4.compare_values(REF_nuc, this_nuc, 3, "Nuclear Repulsion Energy (a.u.)") # TEST assert psi4.compare_values(REF_scf, this_scf, 6, "SCF Energy (a.u.)") # TEST assert psi4.compare_values(REF_scsomp3, this_energy, 6, "SCS-OMP3 Total Energy (a.u.)")
def test_ch2_with_dummy_atoms(): ch2 = psi4.geometry(""" 0 3 c x 1 1.0 h 1 b1 2 a1 h 1 b1 2 a1 3 180.0 b1 = 1.0 a1 = 60.0 """) psi4.core.clean_options() psi4_options = { "reference": "uhf", "basis": "6-31G(d,p)", "docc": [2, 0, 0, 1], "socc": [1, 0, 1, 0], "scf_type": "pk", } psi4.set_options(psi4_options) json_output = optking.optimize_psi4("hf") thisenergy = json_output["energies"][-1] nucenergy = json_output["trajectory"][-1]["properties"][ "nuclear_repulsion_energy"] assert psi4.compare_values(nucrefenergy, nucenergy, 3, "Nuclear repulsion energy") # TEST assert psi4.compare_values(refenergy, thisenergy, 6, "Reference energy") # TEST
def test_frozen_cart_h2o(): h2o = psi4.geometry(""" O 1.000000 1.000000 1.000000 H 2.000000 1.000000 1.000000 H 1.000000 2.000000 1.000000 units angstrom no_com no_reorient """) psi4.core.clean_options() psi4_options = { "basis": "cc-pvdz", "reference": "rhf", "scf_type": "df", "max_energy_g_convergence": 7 } psi4.set_options(psi4_options) psi4.set_options({"optking__frozen_cartesian": """1 xyz"""}) json_output = optking.optimize_psi4("hf") thisenergy = json_output["energies"][-1] assert psi4.compare_values(-76.0270327834836, thisenergy, 6, "RHF Energy") assert psi4.compare_values(h2o.x(0), 1.88972613289, 6, "X Frozen coordinate") assert psi4.compare_values(h2o.y(0), 1.88972613289, 6, "Y Frozen coordinate") assert psi4.compare_values(h2o.z(0), 1.88972613289, 6, "Z Frozen coordinate")
def test_frozen_coords(option, expected): # Constrained minimization with frozen bond, bend, and torsion hooh = psi4.geometry(""" H O 1 0.90 O 2 1.40 1 100.0 H 3 0.90 2 100.0 1 115.0 """) psi4.core.clean_options() psi4_options = { "diis": "false", "basis": "cc-PVDZ", "scf_type": "pk", "print": 4, "g_convergence": "gau_tight" } psi4.set_options(psi4_options) psi4.set_options(option) json_output = optking.optimize_psi4("hf") thisenergy = json_output["energies"][-1] assert psi4.compare_values(expected, thisenergy, 6) # TEST
def test_uccsd_ch2(): ch2 = psi4.geometry( """ 0 3 C H 1 1.1 H 1 1.1 2 109.0 """ ) psi4.core.clean_options() psi4_options = { "reference": "uhf", "basis": "cc-pvdz", "max_disp_g_convergence": 1e-6, "max_force_g_convergence": 1.0e-6, "max_energy_g_convergence": 7, "e_convergence": 10, "r_convergence": 10, "scf_type": "pk", } psi4.set_options(psi4_options) result = optking.optimize_psi4("CCSD") this_scf = result["trajectory"][-1]["properties"]["scf_total_energy"] # TEST this_ccsd = result["trajectory"][-1]["properties"]["ccsd_correlation_energy"] # TEST this_total = result["trajectory"][-1]["properties"]["return_energy"] # TEST REF_scf = -38.9265869596 # TEST REF_ccsd = -0.1153361899 # TEST REF_total = -39.0419231495 # TEST assert psi4.compare_values(REF_scf, this_scf, 6, "UHF energy") # TEST assert psi4.compare_values(REF_ccsd, this_ccsd, 6, "UHF CCSD contribution") # TEST assert psi4.compare_values(REF_total, this_total, 6, "UCCSD Total energy") # TEST
def test_hooh_freeze_xyz_Hs(options, expected): hooh = psi4.geometry(""" H 0.90 0.80 0.5 O 0.00 0.70 0.0 O 0.00 -0.70 0.0 H -0.90 -0.80 0.5 """) psi4.core.clean_options() psi4_options = { "basis": "cc-pvdz", "opt_coordinates": "cartesian", "g_convergence": "gau_tight", "geom_maxiter": 20, "consecutive_backsteps": 1, } psi4.set_options(psi4_options) psi4.set_module_options("OPTKING", options) json_output = optking.optimize_psi4("hf") thisenergy = json_output["energies"][-1] # TEST assert psi4.compare_values(expected, thisenergy, 6) # TEST
def test_hf_g_h2o(): h2o = psi4.geometry(""" O H 1 1.0 H 1 1.0 2 104.5 """) psi4.core.clean_options() psi4_options = { 'diis': False, 'basis': 'sto-3g', 'e_convergence': 10, 'd_convergence': 10, 'scf_type': 'pk', } psi4.set_options(psi4_options) json_output = optking.optimize_psi4('hf') E = json_output['energies'][-1] #TEST nucenergy = json_output['trajectory'][-1]['properties'][ 'nuclear_repulsion_energy'] #TEST refnucenergy = 8.9064983474 #TEST refenergy = -74.9659011923 #TEST assert psi4.compare_values(refnucenergy, nucenergy, 3, "Nuclear repulsion energy") #TEST assert psi4.compare_values(refenergy, E, 6, "Reference energy") #TEST
def test_mp2_h2o(): h2o = psi4.geometry(""" O H 1 1.0 H 1 1.0 2 106.0 """) psi4.core.clean_options() psi4_options = { "basis": "6-31G**", "reference": "rhf", "d_convergence": 9, "e_convergence": 9, "mp2_type": "conv", "max_energy_g_convergence": 7, } psi4.set_options(psi4_options) result = optking.optimize_psi4("mp2") this_nucenergy = result["trajectory"][-1]["properties"][ "nuclear_repulsion_energy"] # TEST this_mp2 = result["energies"][-1] # TEST REF_nucenergy = 9.1622581908184 # TEST REF_mp2 = -76.2224486598878 # TEST assert psi4.compare_values(REF_nucenergy, this_nucenergy, 3, "Nuclear repulsion energy") # TEST assert psi4.compare_values(REF_mp2, this_mp2, 6, "CONV MP2 energy") # TEST