def _test_scf5(): """scf5""" #! Test of all different algorithms and reference types for SCF, on singlet and triplet O2, using the cc-pVTZ basis set and using ERD integrals. psi4.print_stdout( ' Case Study Test of all SCF algorithms/spin-degeneracies: Singlet-Triplet O2' ) psi4.print_stdout(' -Integral package: {}'.format( psi4.core.get_global_option('integral_package'))) #Ensure that the checkpoint file is always nuked psi4.core.IOManager.shared_object().set_specific_retention(32, False) Eref_nuc = 30.78849213614545 Eref_sing_can = -149.58723684929720 Eref_sing_df = -149.58715054487624 Eref_uhf_can = -149.67135517240553 Eref_uhf_df = -149.67125624291961 Eref_rohf_can = -149.65170765757173 Eref_rohf_df = -149.65160796208073 singlet_o2 = psi4.geometry(""" 0 1 O O 1 1.1 units angstrom """) triplet_o2 = psi4.geometry(""" 0 3 O O 1 1.1 units angstrom """) singlet_o2.update_geometry() triplet_o2.update_geometry() psi4.print_stdout(' -Nuclear Repulsion:') assert psi4.compare_values(Eref_nuc, triplet_o2.nuclear_repulsion_energy(), 9, "Triplet nuclear repulsion energy") assert psi4.compare_values(Eref_nuc, singlet_o2.nuclear_repulsion_energy(), 9, "Singlet nuclear repulsion energy") psi4.set_options({ 'basis': 'cc-pvtz', 'df_basis_scf': 'cc-pvtz-jkfit', 'print': 2 }) print(' -Singlet RHF:') psi4.set_module_options('scf', {'reference': 'rhf'}) psi4.set_module_options('scf', {'scf_type': 'pk'}) E = psi4.energy('scf', molecule=singlet_o2) assert psi4.compare_values(Eref_sing_can, E, 6, 'Singlet PK RHF energy') psi4.set_module_options('scf', {'scf_type': 'direct'}) E = psi4.energy('scf', molecule=singlet_o2) assert psi4.compare_values(Eref_sing_can, E, 6, 'Singlet Direct RHF energy') psi4.set_module_options('scf', {'scf_type': 'out_of_core'}) E = psi4.energy('scf', molecule=singlet_o2) assert psi4.compare_values(Eref_sing_can, E, 6, 'Singlet Disk RHF energy') psi4.set_module_options('scf', {'scf_type': 'df'}) E = psi4.energy('scf', molecule=singlet_o2) assert psi4.compare_values(Eref_sing_df, E, 6, 'Singlet DF RHF energy') print(' -Singlet UHF:') psi4.set_module_options('scf', {'reference': 'uhf'}) psi4.set_module_options('scf', {'scf_type': 'pk'}) E = psi4.energy('scf', molecule=singlet_o2) assert psi4.compare_values(Eref_sing_can, E, 6, 'Singlet PK UHF energy') psi4.set_module_options('scf', {'scf_type': 'direct'}) E = psi4.energy('scf', molecule=singlet_o2) assert psi4.compare_values(Eref_sing_can, E, 6, 'Singlet Direct UHF energy') psi4.set_module_options('scf', {'scf_type': 'out_of_core'}) E = psi4.energy('scf', molecule=singlet_o2) assert psi4.compare_values(Eref_sing_can, E, 6, 'Singlet Disk UHF energy') psi4.set_module_options('scf', {'scf_type': 'df'}) E = psi4.energy('scf', molecule=singlet_o2) assert psi4.compare_values(Eref_sing_df, E, 6, 'Singlet DF UHF energy') print(' -Singlet CUHF:') psi4.set_module_options('scf', {'reference': 'cuhf'}) psi4.set_module_options('scf', {'scf_type': 'pk'}) E = psi4.energy('scf', molecule=singlet_o2) assert psi4.compare_values(Eref_sing_can, E, 6, 'Singlet PK CUHF energy') psi4.set_module_options('scf', {'scf_type': 'direct'}) E = psi4.energy('scf', molecule=singlet_o2) assert psi4.compare_values(Eref_sing_can, E, 6, 'Singlet Direct CUHF energy') psi4.set_module_options('scf', {'scf_type': 'out_of_core'}) E = psi4.energy('scf', molecule=singlet_o2) assert psi4.compare_values(Eref_sing_can, E, 6, 'Singlet Disk CUHF energy') psi4.set_module_options('scf', {'scf_type': 'df'}) E = psi4.energy('scf', molecule=singlet_o2) assert psi4.compare_values(Eref_sing_df, E, 6, 'Singlet DF CUHF energy') psi4.set_options({ 'basis': 'cc-pvtz', 'df_basis_scf': 'cc-pvtz-jkfit', 'guess': 'core', 'print': 2 }) print(' -Triplet UHF:') psi4.set_module_options('scf', {'reference': 'uhf'}) psi4.set_module_options('scf', {'scf_type': 'pk'}) E = psi4.energy('scf', molecule=triplet_o2) assert psi4.compare_values(Eref_uhf_can, E, 6, 'Triplet PK UHF energy') psi4.set_module_options('scf', {'scf_type': 'direct'}) E = psi4.energy('scf', molecule=triplet_o2) assert psi4.compare_values(Eref_uhf_can, E, 6, 'Triplet Direct UHF energy') psi4.set_module_options('scf', {'scf_type': 'out_of_core'}) E = psi4.energy('scf', molecule=triplet_o2) assert psi4.compare_values(Eref_uhf_can, E, 6, 'Triplet Disk UHF energy') psi4.set_module_options('scf', {'scf_type': 'df'}) E = psi4.energy('scf', molecule=triplet_o2) assert psi4.compare_values(Eref_uhf_df, E, 6, 'Triplet DF UHF energy') psi4.core.clean() print(' -Triplet ROHF:') psi4.set_module_options('scf', {'reference': 'rohf'}) psi4.set_module_options('scf', {'scf_type': 'pk'}) E = psi4.energy('scf', molecule=triplet_o2) assert psi4.compare_values(Eref_rohf_can, E, 6, 'Triplet PK ROHF energy') psi4.core.clean() psi4.set_module_options('scf', {'scf_type': 'direct'}) E = psi4.energy('scf', molecule=triplet_o2) assert psi4.compare_values(Eref_rohf_can, E, 6, 'Triplet Direct ROHF energy') psi4.core.clean() psi4.set_module_options('scf', {'scf_type': 'out_of_core'}) E = psi4.energy('scf', molecule=triplet_o2) assert psi4.compare_values(Eref_rohf_can, E, 6, 'Triplet Disk ROHF energy') psi4.core.clean() psi4.set_module_options('scf', {'scf_type': 'df'}) E = psi4.energy('scf', molecule=triplet_o2) assert psi4.compare_values(Eref_rohf_df, E, 6, 'Triplet DF ROHF energy') psi4.core.clean() print(' -Triplet CUHF:') psi4.set_module_options('scf', {'reference': 'cuhf'}) psi4.set_module_options('scf', {'scf_type': 'pk'}) E = psi4.energy('scf', molecule=triplet_o2) assert psi4.compare_values(Eref_rohf_can, E, 6, 'Triplet PK CUHF energy') psi4.core.clean() psi4.set_module_options('scf', {'scf_type': 'direct'}) E = psi4.energy('scf', molecule=triplet_o2) assert psi4.compare_values(Eref_rohf_can, E, 6, 'Triplet Direct CUHF energy') psi4.core.clean() psi4.set_module_options('scf', {'scf_type': 'out_of_core'}) E = psi4.energy('scf', molecule=triplet_o2) assert psi4.compare_values(Eref_rohf_can, E, 6, 'Triplet Disk CUHF energy') psi4.core.clean() psi4.set_module_options('scf', {'scf_type': 'df'}) E = psi4.energy('scf', molecule=triplet_o2) assert psi4.compare_values(Eref_rohf_df, E, 6, 'Triplet DF CUHF energy')
def _test_scf5(): """scf5""" #! Test of all different algorithms and reference types for SCF, on singlet and triplet O2, using the cc-pVTZ basis set and using ERD integrals. psi4.print_stdout(' Case Study Test of all SCF algorithms/spin-degeneracies: Singlet-Triplet O2') psi4.print_stdout(' -Integral package: {}'.format(psi4.core.get_global_option('integral_package'))) #Ensure that the checkpoint file is always nuked psi4.core.IOManager.shared_object().set_specific_retention(32,False) Eref_nuc = 30.78849213614545 Eref_sing_can = -149.58723684929720 Eref_sing_df = -149.58715054487624 Eref_uhf_can = -149.67135517240553 Eref_uhf_df = -149.67125624291961 Eref_rohf_can = -149.65170765757173 Eref_rohf_df = -149.65160796208073 singlet_o2 = psi4.geometry(""" 0 1 O O 1 1.1 units angstrom """) triplet_o2 = psi4.geometry(""" 0 3 O O 1 1.1 units angstrom """) singlet_o2.update_geometry() triplet_o2.update_geometry() psi4.print_stdout(' -Nuclear Repulsion:') assert psi4.compare_values(Eref_nuc, triplet_o2.nuclear_repulsion_energy(), 9, "Triplet nuclear repulsion energy") assert psi4.compare_values(Eref_nuc, singlet_o2.nuclear_repulsion_energy(), 9, "Singlet nuclear repulsion energy") psi4.set_options({ 'basis': 'cc-pvtz', 'df_basis_scf': 'cc-pvtz-jkfit', 'print': 2}) print(' -Singlet RHF:') psi4.set_module_options('scf', {'reference': 'rhf'}) psi4.set_module_options('scf', {'scf_type': 'pk'}) E = psi4.energy('scf', molecule=singlet_o2) assert psi4.compare_values(Eref_sing_can, E, 6, 'Singlet PK RHF energy') psi4.set_module_options('scf', {'scf_type': 'direct'}) E = psi4.energy('scf', molecule=singlet_o2) assert psi4.compare_values(Eref_sing_can, E, 6, 'Singlet Direct RHF energy') psi4.set_module_options('scf', {'scf_type': 'out_of_core'}) E = psi4.energy('scf', molecule=singlet_o2) assert psi4.compare_values(Eref_sing_can, E, 6, 'Singlet Disk RHF energy') psi4.set_module_options('scf', {'scf_type': 'df'}) E = psi4.energy('scf', molecule=singlet_o2) assert psi4.compare_values(Eref_sing_df, E, 6, 'Singlet DF RHF energy') print(' -Singlet UHF:') psi4.set_module_options('scf', {'reference': 'uhf'}) psi4.set_module_options('scf', {'scf_type': 'pk'}) E = psi4.energy('scf', molecule=singlet_o2) assert psi4.compare_values(Eref_sing_can, E, 6, 'Singlet PK UHF energy') psi4.set_module_options('scf', {'scf_type': 'direct'}) E = psi4.energy('scf', molecule=singlet_o2) assert psi4.compare_values(Eref_sing_can, E, 6, 'Singlet Direct UHF energy') psi4.set_module_options('scf', {'scf_type': 'out_of_core'}) E = psi4.energy('scf', molecule=singlet_o2) assert psi4.compare_values(Eref_sing_can, E, 6, 'Singlet Disk UHF energy') psi4.set_module_options('scf', {'scf_type': 'df'}) E = psi4.energy('scf', molecule=singlet_o2) assert psi4.compare_values(Eref_sing_df, E, 6, 'Singlet DF UHF energy') print(' -Singlet CUHF:') psi4.set_module_options('scf', {'reference': 'cuhf'}) psi4.set_module_options('scf', {'scf_type': 'pk'}) E = psi4.energy('scf', molecule=singlet_o2) assert psi4.compare_values(Eref_sing_can, E, 6, 'Singlet PK CUHF energy') psi4.set_module_options('scf', {'scf_type': 'direct'}) E = psi4.energy('scf', molecule=singlet_o2) assert psi4.compare_values(Eref_sing_can, E, 6, 'Singlet Direct CUHF energy') psi4.set_module_options('scf', {'scf_type': 'out_of_core'}) E = psi4.energy('scf', molecule=singlet_o2) assert psi4.compare_values(Eref_sing_can, E, 6, 'Singlet Disk CUHF energy') psi4.set_module_options('scf', {'scf_type': 'df'}) E = psi4.energy('scf', molecule=singlet_o2) assert psi4.compare_values(Eref_sing_df, E, 6, 'Singlet DF CUHF energy') psi4.set_options({ 'basis': 'cc-pvtz', 'df_basis_scf': 'cc-pvtz-jkfit', 'guess': 'core', 'print': 2}) print(' -Triplet UHF:') psi4.set_module_options('scf', {'reference': 'uhf'}) psi4.set_module_options('scf', {'scf_type': 'pk'}) E = psi4.energy('scf', molecule=triplet_o2) assert psi4.compare_values(Eref_uhf_can, E, 6, 'Triplet PK UHF energy') psi4.set_module_options('scf', {'scf_type': 'direct'}) E = psi4.energy('scf', molecule=triplet_o2) assert psi4.compare_values(Eref_uhf_can, E, 6, 'Triplet Direct UHF energy') psi4.set_module_options('scf', {'scf_type': 'out_of_core'}) E = psi4.energy('scf', molecule=triplet_o2) assert psi4.compare_values(Eref_uhf_can, E, 6, 'Triplet Disk UHF energy') psi4.set_module_options('scf', {'scf_type': 'df'}) E = psi4.energy('scf', molecule=triplet_o2) assert psi4.compare_values(Eref_uhf_df, E, 6, 'Triplet DF UHF energy') psi4.core.clean() print(' -Triplet ROHF:') psi4.set_module_options('scf', {'reference': 'rohf'}) psi4.set_module_options('scf', {'scf_type': 'pk'}) E = psi4.energy('scf', molecule=triplet_o2) assert psi4.compare_values(Eref_rohf_can, E, 6, 'Triplet PK ROHF energy') psi4.core.clean() psi4.set_module_options('scf', {'scf_type': 'direct'}) E = psi4.energy('scf', molecule=triplet_o2) assert psi4.compare_values(Eref_rohf_can, E, 6, 'Triplet Direct ROHF energy') psi4.core.clean() psi4.set_module_options('scf', {'scf_type': 'out_of_core'}) E = psi4.energy('scf', molecule=triplet_o2) assert psi4.compare_values(Eref_rohf_can, E, 6, 'Triplet Disk ROHF energy') psi4.core.clean() psi4.set_module_options('scf', {'scf_type': 'df'}) E = psi4.energy('scf', molecule=triplet_o2) assert psi4.compare_values(Eref_rohf_df, E, 6, 'Triplet DF ROHF energy') psi4.core.clean() print(' -Triplet CUHF:') psi4.set_module_options('scf', {'reference': 'cuhf'}) psi4.set_module_options('scf', {'scf_type': 'pk'}) E = psi4.energy('scf', molecule=triplet_o2) assert psi4.compare_values(Eref_rohf_can, E, 6, 'Triplet PK CUHF energy') psi4.core.clean() psi4.set_module_options('scf', {'scf_type': 'direct'}) E = psi4.energy('scf', molecule=triplet_o2) assert psi4.compare_values(Eref_rohf_can, E, 6, 'Triplet Direct CUHF energy') psi4.core.clean() psi4.set_module_options('scf', {'scf_type': 'out_of_core'}) E = psi4.energy('scf', molecule=triplet_o2) assert psi4.compare_values(Eref_rohf_can, E, 6, 'Triplet Disk CUHF energy') psi4.core.clean() psi4.set_module_options('scf', {'scf_type': 'df'}) E = psi4.energy('scf', molecule=triplet_o2) assert psi4.compare_values(Eref_rohf_df, E, 6, 'Triplet DF CUHF energy')
def test_dftd3(): """dftd3/energy""" #! Exercises the various DFT-D corrections, both through python directly and through c++ ref_d2 = [-0.00390110, -0.00165271, -0.00058118] ref_d3zero = [-0.00285088, -0.00084340, -0.00031923] ref_d3bj = [-0.00784595, -0.00394347, -0.00226683] ref_pbe_d2 = [-0.00278650, -0.00118051, -0.00041513] ref_pbe_d3zero = [-0.00175474, -0.00045421, -0.00016839] ref_pbe_d3bj = [-0.00475937, -0.00235265, -0.00131239] eneyne = psi4.geometry(""" C 0.000000 -0.667578 -2.124659 C 0.000000 0.667578 -2.124659 H 0.923621 -1.232253 -2.126185 H -0.923621 -1.232253 -2.126185 H -0.923621 1.232253 -2.126185 H 0.923621 1.232253 -2.126185 -- C 0.000000 0.000000 2.900503 C 0.000000 0.000000 1.693240 H 0.000000 0.000000 0.627352 H 0.000000 0.000000 3.963929 """) psi4.print_stdout(' -D correction from Py-side') eneyne.update_geometry() E, G = eneyne.run_dftd3('b3lyp', 'd2gr') assert psi4.compare_values(ref_d2[0], E, 7, 'Ethene-Ethyne -D2') mA = eneyne.extract_subsets(1) E, G = mA.run_dftd3('b3lyp', 'd2gr') assert psi4.compare_values(ref_d2[1], E, 7, 'Ethene -D2') mB = eneyne.extract_subsets(2) E, G = mB.run_dftd3('b3lyp', 'd2gr') assert psi4.compare_values(ref_d2[2], E, 7, 'Ethyne -D2') #mBcp = eneyne.extract_subsets(2,1) #E, G = mBcp.run_dftd3('b3lyp', 'd2gr') #compare_values(ref_d2[2], E, 7, 'Ethyne(CP) -D2') E, G = eneyne.run_dftd3('b3lyp', 'd3zero') assert psi4.compare_values(ref_d3zero[0], E, 7, 'Ethene-Ethyne -D3 (zero)') mA = eneyne.extract_subsets(1) E, G = mA.run_dftd3('b3lyp', 'd3zero') assert psi4.compare_values(ref_d3zero[1], E, 7, 'Ethene -D3 (zero)') mB = eneyne.extract_subsets(2) E, G = mB.run_dftd3('b3lyp', 'd3zero') assert psi4.compare_values(ref_d3zero[2], E, 7, 'Ethyne -D3 (zero)') E, G = eneyne.run_dftd3('b3lyp', 'd3bj') assert psi4.compare_values(ref_d3bj[0], E, 7, 'Ethene-Ethyne -D3 (bj)') mA = eneyne.extract_subsets(1) E, G = mA.run_dftd3('b3lyp', 'd3bj') assert psi4.compare_values(ref_d3bj[1], E, 7, 'Ethene -D3 (bj)') mB = eneyne.extract_subsets(2) E, G = mB.run_dftd3('b3lyp', 'd3bj') assert psi4.compare_values(ref_d3bj[2], E, 7, 'Ethyne -D3 (bj)') E, G = eneyne.run_dftd3('b3lyp', 'd3') assert psi4.compare_values(ref_d3zero[0], E, 7, 'Ethene-Ethyne -D3 (alias)') E, G = eneyne.run_dftd3('b3lyp', 'd') assert psi4.compare_values(ref_d2[0], E, 7, 'Ethene-Ethyne -D (alias)') E, G = eneyne.run_dftd3('b3lyp', 'd2') assert psi4.compare_values(ref_d2[0], E, 7, 'Ethene-Ethyne -D2 (alias)') psi4.set_options({ 'basis': 'sto-3g', 'scf_type': 'df', 'dft_radial_points': 50, # use really bad grid for speed since all we want is the -D value 'dft_spherical_points': 110, #'scf print': 3, # will print dftd3 program output to psi4 output file }) psi4.print_stdout(' -D correction from C-side') psi4.activate(mA) #psi4.energy('b3lyp-d2p4') #assert psi4.compare_values(ref_d2[1], psi4.get_variable('DISPERSION CORRECTION ENERGY'), 7, 'Ethene -D2 (calling psi4 Disp class)') #psi4.energy('b3lyp-d2gr') #assert psi4.compare_values(ref_d2[1], psi4.get_variable('DISPERSION CORRECTION ENERGY'), 7, 'Ethene -D2 (calling dftd3 -old)') #psi4.energy('b3lyp-d3zero') #assert psi4.compare_values(ref_d3zero[1], psi4.get_variable('DISPERSION CORRECTION ENERGY'), 7, 'Ethene -D3 (calling dftd3 -zero)') psi4.energy('b3lyp-d3bj') assert psi4.compare_values( ref_d3bj[1], psi4.get_variable('DISPERSION CORRECTION ENERGY'), 7, 'Ethene -D3 (calling dftd3 -bj)') psi4.energy('b3lyp-d2') assert psi4.compare_values( ref_d2[1], psi4.get_variable('DISPERSION CORRECTION ENERGY'), 7, 'Ethene -D2 (alias)') #psi4.energy('b3lyp-d3') #assert psi4.compare_values(ref_d3zero[1], psi4.get_variable('DISPERSION CORRECTION ENERGY'), 7, 'Ethene -D3 (alias)') #psi4.energy('b3lyp-d') #assert psi4.compare_values(ref_d2[1], psi4.get_variable('DISPERSION CORRECTION ENERGY'), 7, 'Ethene -D (alias)') psi4.energy('wb97x-d') assert psi4.compare_values( -0.000834247063, psi4.get_variable('DISPERSION CORRECTION ENERGY'), 7, 'Ethene wb97x-d (chg)') psi4.print_stdout(' non-default -D correction from C-side') psi4.activate(mB) #psi4.set_options({'dft_dispersion_parameters': [0.75]}) #psi4.energy('b3lyp-d2p4') #assert psi4.compare_values(ref_pbe_d2[2], psi4.get_variable('DISPERSION CORRECTION ENERGY'), 7, 'Ethene -D2 (calling psi4 Disp class)') #psi4.set_options({'dft_dispersion_parameters': [0.75, 20.0]}) #psi4.energy('b3lyp-d2gr') #assert psi4.compare_values(ref_pbe_d2[2], psi4.get_variable('DISPERSION CORRECTION ENERGY'), 7, 'Ethene -D2 (calling dftd3 -old)') #psi4.set_options({'dft_dispersion_parameters': [1.0, 0.722, 1.217, 14.0]}) #psi4.energy('b3lyp-d3zero') #assert psi4.compare_values(ref_pbe_d3zero[2], psi4.get_variable('DISPERSION CORRECTION ENERGY'), 7, 'Ethene -D3 (calling dftd3 -zero)') psi4.set_options( {'dft_dispersion_parameters': [1.000, 0.7875, 0.4289, 4.4407]}) psi4.energy('b3lyp-d3bj') assert psi4.compare_values( ref_pbe_d3bj[2], psi4.get_variable('DISPERSION CORRECTION ENERGY'), 7, 'Ethene -D3 (calling dftd3 -bj)') psi4.set_options({'dft_dispersion_parameters': [0.75]}) psi4.energy('b3lyp-d2') assert psi4.compare_values( ref_pbe_d2[2], psi4.get_variable('DISPERSION CORRECTION ENERGY'), 7, 'Ethene -D2 (alias)') psi4.set_options({'dft_dispersion_parameters': [1.0, 0.722, 1.217, 14.0]}) psi4.energy('b3lyp-d3') assert psi4.compare_values( ref_pbe_d3zero[2], psi4.get_variable('DISPERSION CORRECTION ENERGY'), 7, 'Ethene -D3 (alias)') psi4.set_options({'dft_dispersion_parameters': [0.75]}) psi4.energy('b3lyp-d') assert psi4.compare_values( ref_pbe_d2[2], psi4.get_variable('DISPERSION CORRECTION ENERGY'), 7, 'Ethene -D (alias)') psi4.activate(mA) psi4.set_options({'dft_dispersion_parameters': [1.0]}) psi4.energy('wb97x-d') assert psi4.compare_values( -0.000834247063, psi4.get_variable('DISPERSION CORRECTION ENERGY'), 7, 'Ethene wb97x-d (chg)') psi4.print_stdout(' non-default -D correction from Py-side') eneyne.update_geometry() eneyne.run_dftd3('b3lyp', 'd2gr', {'s6': 0.75}) assert psi4.compare_values( ref_pbe_d2[0], psi4.get_variable('DISPERSION CORRECTION ENERGY'), 7, 'Ethene-Ethyne -D2') mA = eneyne.extract_subsets(1) mA.run_dftd3('b3lyp', 'd2gr', {'s6': 0.75}) assert psi4.compare_values( ref_pbe_d2[1], psi4.get_variable('DISPERSION CORRECTION ENERGY'), 7, 'Ethene -D2') mB = eneyne.extract_subsets(2) mB.run_dftd3('b3lyp', 'd2gr', {'s6': 0.75}) assert psi4.compare_values( ref_pbe_d2[2], psi4.get_variable('DISPERSION CORRECTION ENERGY'), 7, 'Ethyne -D2') eneyne.run_dftd3('b3lyp', 'd3zero', { 's6': 1.0, 's8': 0.722, 'sr6': 1.217, 'alpha6': 14.0 }) assert psi4.compare_values( ref_pbe_d3zero[0], psi4.get_variable('DISPERSION CORRECTION ENERGY'), 7, 'Ethene-Ethyne -D3 (zero)') mA = eneyne.extract_subsets(1) mA.run_dftd3('b3lyp', 'd3zero', { 's6': 1.0, 's8': 0.722, 'sr6': 1.217, 'alpha6': 14.0 }) assert psi4.compare_values( ref_pbe_d3zero[1], psi4.get_variable('DISPERSION CORRECTION ENERGY'), 7, 'Ethene -D3 (zero)') mB = eneyne.extract_subsets(2) mB.run_dftd3('b3lyp', 'd3zero', { 's6': 1.0, 's8': 0.722, 'sr6': 1.217, 'alpha6': 14.0 }) assert psi4.compare_values( ref_pbe_d3zero[2], psi4.get_variable('DISPERSION CORRECTION ENERGY'), 7, 'Ethyne -D3 (zero)') eneyne.run_dftd3('b3lyp', 'd3bj', { 's6': 1.000, 's8': 0.7875, 'a1': 0.4289, 'a2': 4.4407 }) assert psi4.compare_values( ref_pbe_d3bj[0], psi4.get_variable('DISPERSION CORRECTION ENERGY'), 7, 'Ethene-Ethyne -D3 (bj)') mA = eneyne.extract_subsets(1) mA.run_dftd3('b3lyp', 'd3bj', { 's6': 1.000, 's8': 0.7875, 'a1': 0.4289, 'a2': 4.4407 }) assert psi4.compare_values( ref_pbe_d3bj[1], psi4.get_variable('DISPERSION CORRECTION ENERGY'), 7, 'Ethene -D3 (bj)') mB = eneyne.extract_subsets(2) mB.run_dftd3('b3lyp', 'd3bj', { 's6': 1.000, 's8': 0.7875, 'a1': 0.4289, 'a2': 4.4407 }) assert psi4.compare_values( ref_pbe_d3bj[2], psi4.get_variable('DISPERSION CORRECTION ENERGY'), 7, 'Ethyne -D3 (bj)') eneyne.run_dftd3('b3lyp', 'd3', { 's6': 1.0, 's8': 0.722, 'sr6': 1.217, 'alpha6': 14.0 }) assert psi4.compare_values( ref_pbe_d3zero[0], psi4.get_variable('DISPERSION CORRECTION ENERGY'), 7, 'Ethene-Ethyne -D3 (alias)') eneyne.run_dftd3('b3lyp', 'd', {'s6': 0.75}) assert psi4.compare_values( ref_pbe_d2[0], psi4.get_variable('DISPERSION CORRECTION ENERGY'), 7, 'Ethene-Ethyne -D (alias)') eneyne.run_dftd3('b3lyp', 'd2', {'s6': 0.75}) assert psi4.compare_values( ref_pbe_d2[0], psi4.get_variable('DISPERSION CORRECTION ENERGY'), 7, 'Ethene-Ethyne -D2 (alias)')
def test_dftd3(): """dftd3/energy""" #! Exercises the various DFT-D corrections, both through python directly and through c++ ref_d2 = [-0.00390110, -0.00165271, -0.00058118] ref_d3zero = [-0.00285088, -0.00084340, -0.00031923] ref_d3bj = [-0.00784595, -0.00394347, -0.00226683] ref_pbe_d2 = [-0.00278650, -0.00118051, -0.00041513] ref_pbe_d3zero = [-0.00175474, -0.00045421, -0.00016839] ref_pbe_d3bj = [-0.00475937, -0.00235265, -0.00131239] eneyne = psi4.geometry(""" C 0.000000 -0.667578 -2.124659 C 0.000000 0.667578 -2.124659 H 0.923621 -1.232253 -2.126185 H -0.923621 -1.232253 -2.126185 H -0.923621 1.232253 -2.126185 H 0.923621 1.232253 -2.126185 -- C 0.000000 0.000000 2.900503 C 0.000000 0.000000 1.693240 H 0.000000 0.000000 0.627352 H 0.000000 0.000000 3.963929 """) psi4.print_stdout(' -D correction from Py-side') eneyne.update_geometry() E, G = eneyne.run_dftd3('b3lyp', 'd2gr') assert psi4.compare_values(ref_d2[0], E, 7, 'Ethene-Ethyne -D2') mA = eneyne.extract_subsets(1) E, G = mA.run_dftd3('b3lyp', 'd2gr') assert psi4.compare_values(ref_d2[1], E, 7, 'Ethene -D2') mB = eneyne.extract_subsets(2) E, G = mB.run_dftd3('b3lyp', 'd2gr') assert psi4.compare_values(ref_d2[2], E, 7, 'Ethyne -D2') #mBcp = eneyne.extract_subsets(2,1) #E, G = mBcp.run_dftd3('b3lyp', 'd2gr') #compare_values(ref_d2[2], E, 7, 'Ethyne(CP) -D2') E, G = eneyne.run_dftd3('b3lyp', 'd3zero') assert psi4.compare_values(ref_d3zero[0], E, 7, 'Ethene-Ethyne -D3 (zero)') mA = eneyne.extract_subsets(1) E, G = mA.run_dftd3('b3lyp', 'd3zero') assert psi4.compare_values(ref_d3zero[1], E, 7, 'Ethene -D3 (zero)') mB = eneyne.extract_subsets(2) E, G = mB.run_dftd3('b3lyp', 'd3zero') assert psi4.compare_values(ref_d3zero[2], E, 7, 'Ethyne -D3 (zero)') E, G = eneyne.run_dftd3('b3lyp', 'd3bj') assert psi4.compare_values(ref_d3bj[0], E, 7, 'Ethene-Ethyne -D3 (bj)') mA = eneyne.extract_subsets(1) E, G = mA.run_dftd3('b3lyp', 'd3bj') assert psi4.compare_values(ref_d3bj[1], E, 7, 'Ethene -D3 (bj)') mB = eneyne.extract_subsets(2) E, G = mB.run_dftd3('b3lyp', 'd3bj') assert psi4.compare_values(ref_d3bj[2], E, 7, 'Ethyne -D3 (bj)') E, G = eneyne.run_dftd3('b3lyp', 'd3') assert psi4.compare_values(ref_d3zero[0], E, 7, 'Ethene-Ethyne -D3 (alias)') E, G = eneyne.run_dftd3('b3lyp', 'd') assert psi4.compare_values(ref_d2[0], E, 7, 'Ethene-Ethyne -D (alias)') E, G = eneyne.run_dftd3('b3lyp', 'd2') assert psi4.compare_values(ref_d2[0], E, 7, 'Ethene-Ethyne -D2 (alias)') psi4.set_options({'basis': 'sto-3g', 'scf_type': 'df', 'dft_radial_points': 50, # use really bad grid for speed since all we want is the -D value 'dft_spherical_points': 110, #'scf print': 3, # will print dftd3 program output to psi4 output file }) psi4.print_stdout(' -D correction from C-side') psi4.activate(mA) #psi4.energy('b3lyp-d2p4') #assert psi4.compare_values(ref_d2[1], psi4.get_variable('DISPERSION CORRECTION ENERGY'), 7, 'Ethene -D2 (calling psi4 Disp class)') #psi4.energy('b3lyp-d2gr') #assert psi4.compare_values(ref_d2[1], psi4.get_variable('DISPERSION CORRECTION ENERGY'), 7, 'Ethene -D2 (calling dftd3 -old)') #psi4.energy('b3lyp-d3zero') #assert psi4.compare_values(ref_d3zero[1], psi4.get_variable('DISPERSION CORRECTION ENERGY'), 7, 'Ethene -D3 (calling dftd3 -zero)') psi4.energy('b3lyp-d3bj') assert psi4.compare_values(ref_d3bj[1], psi4.get_variable('DISPERSION CORRECTION ENERGY'), 7, 'Ethene -D3 (calling dftd3 -bj)') psi4.energy('b3lyp-d2') assert psi4.compare_values(ref_d2[1], psi4.get_variable('DISPERSION CORRECTION ENERGY'), 7, 'Ethene -D2 (alias)') #psi4.energy('b3lyp-d3') #assert psi4.compare_values(ref_d3zero[1], psi4.get_variable('DISPERSION CORRECTION ENERGY'), 7, 'Ethene -D3 (alias)') #psi4.energy('b3lyp-d') #assert psi4.compare_values(ref_d2[1], psi4.get_variable('DISPERSION CORRECTION ENERGY'), 7, 'Ethene -D (alias)') psi4.energy('wb97x-d') assert psi4.compare_values(-0.000834247063, psi4.get_variable('DISPERSION CORRECTION ENERGY'), 7, 'Ethene wb97x-d (chg)') psi4.print_stdout(' non-default -D correction from C-side') psi4.activate(mB) #psi4.set_options({'dft_dispersion_parameters': [0.75]}) #psi4.energy('b3lyp-d2p4') #assert psi4.compare_values(ref_pbe_d2[2], psi4.get_variable('DISPERSION CORRECTION ENERGY'), 7, 'Ethene -D2 (calling psi4 Disp class)') #psi4.set_options({'dft_dispersion_parameters': [0.75, 20.0]}) #psi4.energy('b3lyp-d2gr') #assert psi4.compare_values(ref_pbe_d2[2], psi4.get_variable('DISPERSION CORRECTION ENERGY'), 7, 'Ethene -D2 (calling dftd3 -old)') #psi4.set_options({'dft_dispersion_parameters': [1.0, 0.722, 1.217, 14.0]}) #psi4.energy('b3lyp-d3zero') #assert psi4.compare_values(ref_pbe_d3zero[2], psi4.get_variable('DISPERSION CORRECTION ENERGY'), 7, 'Ethene -D3 (calling dftd3 -zero)') psi4.set_options({'dft_dispersion_parameters': [1.000, 0.7875, 0.4289, 4.4407]}) psi4.energy('b3lyp-d3bj') assert psi4.compare_values(ref_pbe_d3bj[2], psi4.get_variable('DISPERSION CORRECTION ENERGY'), 7, 'Ethene -D3 (calling dftd3 -bj)') psi4.set_options({'dft_dispersion_parameters': [0.75]}) psi4.energy('b3lyp-d2') assert psi4.compare_values(ref_pbe_d2[2], psi4.get_variable('DISPERSION CORRECTION ENERGY'), 7, 'Ethene -D2 (alias)') psi4.set_options({'dft_dispersion_parameters': [1.0, 0.722, 1.217, 14.0]}) psi4.energy('b3lyp-d3') assert psi4.compare_values(ref_pbe_d3zero[2], psi4.get_variable('DISPERSION CORRECTION ENERGY'), 7, 'Ethene -D3 (alias)') psi4.set_options({'dft_dispersion_parameters': [0.75]}) psi4.energy('b3lyp-d') assert psi4.compare_values(ref_pbe_d2[2], psi4.get_variable('DISPERSION CORRECTION ENERGY'), 7, 'Ethene -D (alias)') psi4.activate(mA) psi4.set_options({'dft_dispersion_parameters': [1.0]}) psi4.energy('wb97x-d') assert psi4.compare_values(-0.000834247063, psi4.get_variable('DISPERSION CORRECTION ENERGY'), 7, 'Ethene wb97x-d (chg)') psi4.print_stdout(' non-default -D correction from Py-side') eneyne.update_geometry() eneyne.run_dftd3('b3lyp', 'd2gr', {'s6': 0.75}) assert psi4.compare_values(ref_pbe_d2[0], psi4.get_variable('DISPERSION CORRECTION ENERGY'), 7, 'Ethene-Ethyne -D2') mA = eneyne.extract_subsets(1) mA.run_dftd3('b3lyp', 'd2gr', {'s6': 0.75}) assert psi4.compare_values(ref_pbe_d2[1], psi4.get_variable('DISPERSION CORRECTION ENERGY'), 7, 'Ethene -D2') mB = eneyne.extract_subsets(2) mB.run_dftd3('b3lyp', 'd2gr', {'s6': 0.75}) assert psi4.compare_values(ref_pbe_d2[2], psi4.get_variable('DISPERSION CORRECTION ENERGY'), 7, 'Ethyne -D2') eneyne.run_dftd3('b3lyp', 'd3zero', {'s6': 1.0, 's8': 0.722, 'sr6': 1.217, 'alpha6': 14.0}) assert psi4.compare_values(ref_pbe_d3zero[0], psi4.get_variable('DISPERSION CORRECTION ENERGY'), 7, 'Ethene-Ethyne -D3 (zero)') mA = eneyne.extract_subsets(1) mA.run_dftd3('b3lyp', 'd3zero', {'s6': 1.0, 's8': 0.722, 'sr6': 1.217, 'alpha6': 14.0}) assert psi4.compare_values(ref_pbe_d3zero[1], psi4.get_variable('DISPERSION CORRECTION ENERGY'), 7, 'Ethene -D3 (zero)') mB = eneyne.extract_subsets(2) mB.run_dftd3('b3lyp', 'd3zero', {'s6': 1.0, 's8': 0.722, 'sr6': 1.217, 'alpha6': 14.0}) assert psi4.compare_values(ref_pbe_d3zero[2], psi4.get_variable('DISPERSION CORRECTION ENERGY'), 7, 'Ethyne -D3 (zero)') eneyne.run_dftd3('b3lyp', 'd3bj', {'s6': 1.000, 's8': 0.7875, 'a1': 0.4289, 'a2': 4.4407}) assert psi4.compare_values(ref_pbe_d3bj[0], psi4.get_variable('DISPERSION CORRECTION ENERGY'), 7, 'Ethene-Ethyne -D3 (bj)') mA = eneyne.extract_subsets(1) mA.run_dftd3('b3lyp', 'd3bj', {'s6': 1.000, 's8': 0.7875, 'a1': 0.4289, 'a2': 4.4407}) assert psi4.compare_values(ref_pbe_d3bj[1], psi4.get_variable('DISPERSION CORRECTION ENERGY'), 7, 'Ethene -D3 (bj)') mB = eneyne.extract_subsets(2) mB.run_dftd3('b3lyp', 'd3bj', {'s6': 1.000, 's8': 0.7875, 'a1': 0.4289, 'a2': 4.4407}) assert psi4.compare_values(ref_pbe_d3bj[2], psi4.get_variable('DISPERSION CORRECTION ENERGY'), 7, 'Ethyne -D3 (bj)') eneyne.run_dftd3('b3lyp', 'd3', {'s6': 1.0, 's8': 0.722, 'sr6': 1.217, 'alpha6': 14.0}) assert psi4.compare_values(ref_pbe_d3zero[0], psi4.get_variable('DISPERSION CORRECTION ENERGY'), 7, 'Ethene-Ethyne -D3 (alias)') eneyne.run_dftd3('b3lyp', 'd', {'s6': 0.75}) assert psi4.compare_values(ref_pbe_d2[0], psi4.get_variable('DISPERSION CORRECTION ENERGY'), 7, 'Ethene-Ethyne -D (alias)') eneyne.run_dftd3('b3lyp', 'd2', {'s6': 0.75}) assert psi4.compare_values(ref_pbe_d2[0], psi4.get_variable('DISPERSION CORRECTION ENERGY'), 7, 'Ethene-Ethyne -D2 (alias)')