示例#1
0
def test_hooh_fixed_HOOH_tor():
    # Constrained minimization with H-O-O-H dihedral fixed to 120.0 degrees.
    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.set_options({
        'diis': 'false',
        'basis': 'cc-pvdz',
        'g_convergence': 'gau_verytight'
    })

    dihedral_angle = ("""
        1 2 3 4 120.0
    """)

    psi4.set_module_options('Optking', {'fixed_dihedral': dihedral_angle})

    Psi4Opt.calcName = 'hf'
    thisenergy = Psi4Opt.Psi4Opt()
    assert psi4.compare_values(
        HOOH_120_dihedral, thisenergy, 6,
        "Int. Coord. RHF opt of HOOH with H-O-O-H fixed to 120, energy")  #TEST
示例#2
0
def test_scf():
    bas_list = ['STO-3G','DZ','DZP']
    mol_list = ['H2O', 'CO2', 'C2H4']
    for name in mol_list:
        geom = mesp.mollib[name]
        geom += '\nsymmetry c1'
        for bas in bas_list:
            psi4.core.clean()
            mol = mesp.Molecule(name,geom,bas)
            psi4.set_options({
                'basis':bas,
                'scf_type':'pk',
                'freeze_core':'false',
                'e_convergence':1e-12,
                'd_convergence':1e-12})
            psi4.set_module_options('SCF', 
                {'e_convergence': 1e-12, 'd_convergence': 1e-12,
                 'DIIS': True, 'scf_type':'pk'})

            print("Results for {}/SCF/{}".format(name,bas))
            mesp.scf.do_scf(mol)
            E_mesp = mol.E_SCF    
            E_psi4 = psi4.energy('SCF',molecule=mol.p4mol)
            
            print("mesp energy: {}".format(E_mesp))
            print("Psi4 energy: {}\n\n".format(E_psi4))
            psi4.compare_values(E_psi4,E_mesp,11,"RHF Energy")
示例#3
0
def test_mp2():
    bas_list = ['STO-3G','DZ'] 
    mol_list = ['H2O']
    for name in mol_list:
        geom = mesp.mollib[name]
        geom += '\nsymmetry c1'
        for bas in bas_list:
            psi4.core.clean()
            mol = mesp.Molecule(name,geom,bas)
            psi4.set_options({
                'basis':bas,
                'scf_type':'pk',
                'mp2_type':'conv',
                'freeze_core':'false',
                'e_convergence':1e-12,
                'd_convergence':1e-12})
            psi4.set_module_options('SCF', 
                {'e_convergence': 1e-12, 'd_convergence': 1e-12,
                 'DIIS': True, 'scf_type':'pk'})

            print("Results for {}/MP2/{}".format(name,bas))
            mesp.mp2.do_mp2(mol)
            E_mesp = mol.E_MP2    
            E_psi4 = psi4.energy('MP2')
    
            print("mesp energy: {}".format(E_mesp))
            print("Psi4 energy: {}".format(E_psi4))
            psi4.compare_values(E_psi4,E_mesp,11,"MP2 Energy")
示例#4
0
def test_hooh_freeze_xyz_Hs():    
    # Freeze H xyz in HOOH.
    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
      no_com
      no_reorient
    """)
    
    psi4.set_options({
     'basis': 'cc-pvdz',
     'opt_coordinates': 'cartesian',
     'g_convergence': 'gau_tight',
     'geom_maxiter': 20,
     'consecutive_backsteps': 1  # TEST backsteps 
    })
    
    freeze_list = """ 1 Xyz 4 xYz """
    
    psi4.set_module_options('Optking', {'frozen_cartesian': freeze_list})
    #set optking frozen_cartesian $freeze_list
    
    Psi4Opt.calcName = 'hf'
    thisenergy = Psi4Opt.Psi4Opt()
    assert psi4.compare_values(HOOH_E_fixed_H_xyz, thisenergy, 6, 
                        "Cart. Coord. RHF opt of HOOH with H's xyz frozen, energy")  #TEST
示例#5
0
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_module_options('OPTKING', option)

    json_output = optking.optimize_psi4('hf')
    thisenergy = json_output['energies'][-1]

    assert psi4.compare_values(expected, thisenergy, 6)  # TEST
示例#6
0
def test_hooh_fixed_OH_stre():
    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.set_options({
        'diis': 'false',
        'basis': 'cc-pvdz',
        'g_convergence': 'gau_verytight'
    })

    OH_bondlengths = ("""
        1  2 0.950
        3  4 0.950
    """)

    psi4.set_module_options('Optking', {'fixed_distance': OH_bondlengths})

    Psi4Opt.calcName = 'hf'
    thisenergy = Psi4Opt.Psi4Opt()
    assert psi4.compare_values(
        OH_950_stre, thisenergy, 6,
        "Int. Coord. RHF opt of HOOH with O-H fixed to 0.95, energy")  #TEST
示例#7
0
def test_fci_ecp_2():
    """Water-Argon complex with ECP present; CASCI(6,6)."""

    nucenergy =   23.253113522963400
    refenergy =  -96.68319147222

    arwater = psi4.geometry("""
        Ar  0.000000000000     0.000000000000     3.000000000000
        O   0.000000000000     0.000000000000    -0.071143036192
        H   0.000000000000    -0.758215806856     0.564545805801
        H   0.000000000000     0.758215806856     0.564545805801
    """)

    psi4.set_options({
        'scf_type':      'pk',
        'basis':         'lanl2dz',
        'df_scf_guess':  False,
        'd_convergence': 10,
    })

    psi4.set_module_options("FORTE", {
      'job_type': 'fci',
      'restricted_docc': [4,0,1,1],
      'active':          [2,0,2,2],
    })

    e = psi4.energy('forte')
    assert psi4.compare_values(nucenergy, arwater.nuclear_repulsion_energy(), 10, "Nuclear repulsion energy")
    assert psi4.compare_values(refenergy, e, 10, "FCI energy with ECP")
def test_input_multistate():
    """Test input for a multi-state computation using the `AVG_STATE` keyword."""

    psi4.geometry("""
    Li
    H 1 3.0
    units bohr
    """)

    ref_energies = {
        '1A1': [-8.008550659909, -7.890309067618, -7.776162395969],
        '1A2': [-7.396156201690, -7.321587400358, -7.262899599968],
        '1B1': [-7.853436217153, -7.749808606728, -7.382069881110],
        '1B2': [-7.853436217170, -7.749808606704, -7.382069881071],
    }

    # need to clean the options otherwise this job will interfere
    forte.clean_options()

    psi4.set_options({'basis': 'DZ', 'scf_type': 'pk', 'e_convergence': 12})
    psi4.set_module_options(
        'FORTE', {
            'active_space_solver': 'fci',
            'active': [8, 0, 2, 2],
            'restricted_docc': [0, 0, 0, 0],
            'avg_state': [[0, 1, 3], [1, 1, 3], [2, 1, 3], [3, 1, 3]],
            'ms': 0.0
        })
    efci = psi4.energy('forte')
    for k, vals in ref_energies.items():
        for i in range(3):
            assert psi4.core.variable(f'ENERGY ROOT {i} {k}') == pytest.approx(
                vals[i], 1.0e-9)
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
示例#10
0
def v2rdm_psi4():

    mol = psi4.geometry("""
    0 1
    b
    h 1 1.1
    """)

    psi4.set_options({
      'basis':           'sto-3g',
      'scf_type':        'out_of_core',
      'd_convergence':   1e-10,
      'maxiter':         500,
    })
    psi4.set_module_options('hilbert', {
      #'sdp_solver':      'rrsdp',
      'positivity':      'dqg',
      'r_convergence':   1e-5,
      'e_convergence':   1e-4,
      'maxiter':         20000,
    })

    psi4.activate(mol)

    # get scf wfn
    scf_energy,ref_wfn = psi4.energy('scf',return_wfn=True)

    # grab options object
    options = psi4.core.get_options()
    options.set_current_module('HILBERT')

    v2rdm_psi4 = hilbert.v2RDMHelper(ref_wfn,options)
    current_energy = v2rdm_psi4.compute_energy()

    return current_energy, mol.nuclear_repulsion_energy()
示例#11
0
    def __init__(self,memory=2):

        psi4.set_module_options('SCF', {'SCF_TYPE':'PK'})
        psi4.set_module_options('SCF', {'E_CONVERGENCE':1e-14})
        psi4.set_module_options('SCF', {'D_CONVERGENCE':1e-14})

        psi4.set_module_options('CCENERGY', {'E_CONVERGENCE':1e-16})
        psi4.set_module_options('CCLAMBDA', {'R_CONVERGENCE':1e-16})

        mol = psi4.core.get_active_molecule()
        ccsd = CCEnergy(mol, memory=2)
        ccsd.compute_ccsd()

        #hbar = CCHbar(ccsd)

        Lambda = CCLambda(ccsd)
        Lambda.compute_lambda()
        #Lambda = 0
        #density = 0

        #density = CCDensity(ccsd,Lambda)

        options = {
            'timestep'          : 0.1,
            'number of steps'   : 1000,
            'timelength'        : np.inf,
            'field amplitude'   : 0.002,
            'field frequency'   : 0.5}
示例#12
0
def test_input_example_2():
    """Run a FCISCF computation on methylene using ROHF orbitals optimized for the 3B1 state.
       Computes both the lowest 3B1 and 1A1 states."""
    import math
    import psi4
    import forte
    import pytest

    ref_e_1a1 = -38.900217662950
    ref_e_3b1 = -38.960623289646

    psi4.geometry("""
    0 3
    C
    H 1 1.085
    H 1 1.085 2 135.5
    """)

    psi4.set_options({'basis': 'DZ', 'scf_type': 'pk', 'e_convergence': 12, 'reference': 'rohf'})
    psi4.set_module_options(
        'FORTE', {
            'job_type': 'mcscf_two_step',
            'active_space_solver': 'fci',
            'restricted_docc': [1, 0, 0, 0],
            'active': [3, 0, 2, 2],
            'avg_state': [[2, 3, 1], [0, 1, 1]]
        }
    )
    psi4.energy('forte')
    assert psi4.core.variable('ENERGY ROOT 0 3B1') == pytest.approx(ref_e_3b1, 1.0e-9)
    assert psi4.core.variable('ENERGY ROOT 0 1A1') == pytest.approx(ref_e_1a1, 1.0e-9)
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")
示例#14
0
def test_hooh_fixed_OOH_bend():
    # Constrained minimization with O-O-H angles fixed to reach eq. at 105.0 degrees.
    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.set_options({
        'diis': 'false',
        'basis': 'cc-pvdz',
        'g_convergence': 'gau_verytight'
    })

    #fixed_distance = (" ")
    bend_coordinates = (""" 
        1 2 3 105.0 
        2 3 4 105.0
    """)

    psi4.set_module_options('Optking', {'fixed_bend': bend_coordinates})

    Psi4Opt.calcName = 'hf'
    thisenergy = Psi4Opt.Psi4Opt()
    assert psi4.compare_values(
        OOH_105_bend, thisenergy, 6,
        "Int. Coord. RHF opt of HOOH with O-O-H fixed to 105, energy")  #TEST
示例#15
0
def test_hess_every3():
    hooh = psi4.geometry("""
      H
      O 1 0.9
      O 2 1.4 1 100.0
      H 3 0.9 2 100.0 1 170.0
    """)

    #set optking full_hess_every 3

    psi4.set_options({
        'basis': 'cc-pvdz',
        'g_convergence': 'gau_verytight',
        'scf_type': 'pk',
    })
    psi4.set_module_options('Optking', {
        'full_hess_every': 3,
        'geom_maxiter': 200
    })

    #reload(Psi4Opt)
    Psi4Opt.calcName = 'hf'
    E = Psi4Opt.Psi4Opt()
    assert psi4.compare_values(finalEnergy, E, 8,
                               "Final energy, every 3rd step Hessian")  #TEST
示例#16
0
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
示例#17
0
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")
示例#18
0
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
示例#19
0
def disabled_test_forte():
    """aci-10: Perform aci on benzyne"""

    import forte

    refscf    = -229.20378006852584
    refaci    = -229.359450812283
    refacipt2 = -229.360444943286

    mbenzyne = psi4.geometry("""
      0 1
       C   0.0000000000  -2.5451795941   0.0000000000
       C   0.0000000000   2.5451795941   0.0000000000
       C  -2.2828001669  -1.3508352528   0.0000000000
       C   2.2828001669  -1.3508352528   0.0000000000
       C   2.2828001669   1.3508352528   0.0000000000
       C  -2.2828001669   1.3508352528   0.0000000000
       H  -4.0782187459  -2.3208602146   0.0000000000
       H   4.0782187459  -2.3208602146   0.0000000000
       H   4.0782187459   2.3208602146   0.0000000000
       H  -4.0782187459   2.3208602146   0.0000000000

      units bohr
    """)

    psi4.set_options({
       'basis': 'DZ',
       'df_basis_mp2': 'cc-pvdz-ri',
       'reference': 'uhf',
       'scf_type': 'pk',
       'd_convergence': 10,
       'e_convergence': 12,
       'guess': 'gwh',
    })

    psi4.set_module_options("FORTE", {
      'root_sym': 0,
      'frozen_docc':     [2,1,0,0,0,0,2,1],
      'restricted_docc': [3,2,0,0,0,0,2,3],
      'active':          [1,0,1,2,1,2,1,0],
      'multiplicity': 1,
      'aci_nroot': 1,
      'job_type': 'aci',
      'sigma': 0.001,
      'aci_select_type': 'aimed_energy',
      'aci_spin_projection': 1,
      'aci_enforce_spin_complete': True,
      'aci_add_aimed_degenerate': False,
      'aci_project_out_spin_contaminants': False,
      'diag_algorithm': 'full',
      'aci_quiet_mode': True,
    })

    scf = psi4.energy('scf')
    assert psi4.compare_values(refscf, scf,10,"SCF Energy")

    psi4.energy('forte')
    assert psi4.compare_values(refaci, psi4.variable("ACI ENERGY"),10,"ACI energy")
    assert psi4.compare_values(refacipt2, psi4.variable("ACI+PT2 ENERGY"),8,"ACI+PT2 energy")
示例#20
0
def test_optrot():
    psi4.core.clean()

    # Set memory
    psi4.set_memory('2 GB')
    psi4.core.set_output_file('test_optrot_out.dat', False)
    np.set_printoptions(precision=12, threshold=np.inf, linewidth=200, suppress=True)

    # Set Psi4 options
    mol = psi4.geometry("""                                                 
     O     -0.028962160801    -0.694396279686    -0.049338350190                                                                  
     O      0.028962160801     0.694396279686    -0.049338350190                                                                  
     H      0.350498145881    -0.910645626300     0.783035421467                                                                  
     H     -0.350498145881     0.910645626300     0.783035421467                                                                  
    symmetry c1        
    """)

    psi4.set_options({'basis': 'cc-pVDZ', 'scf_type': 'pk',
                      'freeze_core': 'false', 'e_convergence': 1e-10,
                      'd_convergence': 1e-10, 'save_jk': 'true'})

    # Set for CCSD
    E_conv = 1e-10
    R_conv = 1e-10
    maxiter = 40
    compare_psi4 = False

    # Set for LPNO
    #local=True
    local=False
    pno_cut = 0.0

    # Set for polarizability calculation
    typ = 'polar'
    omega_nm = 589.0

    # Compute RHF energy with psi4
    psi4.set_module_options('SCF', {'E_CONVERGENCE': 1e-10})
    psi4.set_module_options('SCF', {'D_CONVERGENCE': 1e-10})
    e_scf, wfn = psi4.energy('SCF', return_wfn=True)
    print('SCF energy: {}\n'.format(e_scf))
    print('Nuclear repulsion energy: {}\n'.format(mol.nuclear_repulsion_energy()))

    # Create Helper_CCenergy object
    optrot_lg = ccsd_lpno.do_linresp(wfn, omega_nm, mol, method='optrot', gauge='length', e_conv=E_conv, r_conv=R_conv, localize=local, pno_cut=pno_cut) 
    optrot_mvg = ccsd_lpno.do_linresp(wfn, omega_nm, mol, method='optrot', gauge='velocity', e_conv=E_conv, r_conv=R_conv, localize=local, pno_cut=pno_cut) 

    # Comaprison with Psi4
    psi4.set_options({'e_convergence': 1e-10})
    psi4.set_options({'r_convergence': 1e-10})
    psi4.set_options({'omega': [589, 'nm'],
                      'gauge': 'both'})  
    psi4.properties('ccsd', properties=['rotation'], ref_wfn=wfn)
    psi4.compare_values(optrot_lg, psi4.core.variable("CCSD SPECIFIC ROTATION (LEN) @ 589NM"), \
     4, "CCSD SPECIFIC ROTATION (LENGTH GAUGE) 589 nm") #TEST
    psi4.compare_values(optrot_mvg, psi4.core.variable("CCSD SPECIFIC ROTATION (MVG) @ 589NM"), \
     4, "CCSD SPECIFIC ROTATION (MODIFIED VELOCITY GAUGE) 589 nm") #TEST
示例#21
0
def surf_psi4(params, output_file):
    natoms = params.natoms
    geom = params.geometry
    #print(geom)
    geom += "symmetry c1\n"
    geom += "no_reorient\n"
    geom += "no_com"
    #print(geom)
    #print(geom)
    mol = psi4.geometry(geom)
    if (params.constraint_type == 'angle'):
        coord_constraint = 'fixed_bend'
    if (params.constraint_type == 'bond'):
        coord_constraint = 'fixed_distance'
    if (params.constraint_type == 'dihedral'):
        coord_constraint = 'fixed_dihedral'
    output = open(output_file, "a")
    output.write(
        '\n\n--%s surface scan for fixed %s of atoms %s--\n' %
        (params.scan_type, params.constraint_type, params.constrained_atoms))
    output.write(
        '\n--------------------------------------------------------------------------------------\n'
    )
    output.write('\n{:>20} {:>20}\n'.format('Coordinate', 'E'))
    output.write(
        '-------------------------------------------------------------------------------------\n'
    )
    output.close()
    surf_out = open("surface_scan.xyz", "w+")
    surf_out.close()
    for constrained_value in params.constrained_values:
        #print(params.constrained_values)
        fixed_coord = params.constrained_atoms + str(constrained_value)
        #print(fixed_coord)
        psi4.set_options(params.keywords)
        psi4.set_module_options('Optking', {coord_constraint: fixed_coord})
        psi4.set_num_threads(params.nthreads)
        psi4.core.set_output_file(
            "psi4_output/surf_%.2f.out" % constrained_value, False)
        surf_out = open("surface_scan.xyz", "a")
        surf_out.write("%s\n" % natoms)
        surf_out.write(
            "%s surface scan with fixed %s of %f\n" %
            (params.scan_type, params.constraint_type, constrained_value))
        if (params.scan_type == 'relaxed'):
            E = psi4.optimize("%s/%s" % (params.method, params.basis))
            pre_string = mol.create_psi4_string_from_molecule()
            #print(pre_string)
            struct = pre_string.split("\n", 7)[7]
            #print(struct)
            surf_out.write(struct[:-1])
        if (params.scan_type == 'unrelaxed'):
            E = psi4.energy("%s/%s" % (params.method, params.basis))
        output = open(output_file, "a")
        output.write('\n{:>20.4f} {:>20.7f}\n'.format(constrained_value, E))
        output.close()
示例#22
0
def test_v2rdm_casscf():
    """v2rdm_casscf/tests/v2rdm1"""
    #! cc-pvdz N2 (6,6) active space Test DQG

    print(
        '        N2 / cc-pVDZ / DQG(6,6), scf_type = CD / 1e-12, rNN = 0.5 A')

    import v2rdm_casscf

    n2 = psi4.geometry("""
    0 1
    n
    n 1 r
    """)

    interloper = psi4.geometry("""
    0 1
    O
    H 1 1.0
    H 1 1.0 2 90.0
    """)

    psi4.set_options({
        'basis': 'cc-pvdz',
        'scf_type': 'cd',
        'cholesky_tolerance': 1e-12,
        'd_convergence': 1e-10,
        'maxiter': 500,
        'restricted_docc': [2, 0, 0, 0, 0, 2, 0, 0],
        'active': [1, 0, 1, 1, 0, 1, 1, 1],
    })
    psi4.set_module_options(
        'v2rdm_casscf',
        {
            'positivity': 'dqg',
            'r_convergence': 1e-5,
            'e_convergence': 1e-6,
            'maxiter': 20000,
            #'orbopt_frequency': 1000,
            #'mu_update_frequency': 1000,
        })

    psi4.activate(n2)

    n2.r = 0.5 * 0.52917721067 / 0.52917720859
    refscf = -103.04337420425350
    refv2rdm = -103.086205379481

    psi4.energy('v2rdm-casscf', molecule=n2)

    assert psi4.compare_values(refscf, psi4.variable("SCF TOTAL ENERGY"), 8,
                               "SCF total energy")
    assert psi4.compare_values(refv2rdm, psi4.variable("CURRENT ENERGY"), 5,
                               "v2RDM-CASSCF total energy")
示例#23
0
def test_v2rdm_casscf():
    """v2rdm_casscf/tests/v2rdm1"""
    #! cc-pvdz N2 (6,6) active space Test DQG

    print('        N2 / cc-pVDZ / DQG(6,6), scf_type = CD / 1e-12, rNN = 0.5 A')

    import v2rdm_casscf

    n2 = psi4.geometry("""
    0 1
    n
    n 1 r
    """)

    interloper = psi4.geometry("""
    0 1
    O
    H 1 1.0
    H 1 1.0 2 90.0
    """)

    psi4.set_options({
      'basis': 'cc-pvdz',
      'scf_type': 'cd',
      'cholesky_tolerance': 1e-12,
      'd_convergence': 1e-10,
      'maxiter': 500,
      'restricted_docc': [ 2, 0, 0, 0, 0, 2, 0, 0 ],
      'active': [ 1, 0, 1, 1, 0, 1, 1, 1 ],
    })
    psi4.set_module_options('v2rdm_casscf', {
      'positivity': 'dqg',
      'r_convergence': 1e-5,
      'e_convergence': 1e-6,
      'maxiter': 20000,
      #'orbopt_frequency': 1000,
      #'mu_update_frequency': 1000,
    })

    psi4.activate(n2)

    n2.r     = 0.5 * 0.52917721067 / 0.52917720859
    refscf   = -103.04337420425350
    refv2rdm = -103.086205379481

    psi4.energy('v2rdm-casscf', molecule=n2)

    assert psi4.compare_values(refscf, psi4.variable("SCF TOTAL ENERGY"), 8, "SCF total energy")
    assert psi4.compare_values(refv2rdm, psi4.variable("CURRENT ENERGY"), 5, "v2RDM-CASSCF total energy")
示例#24
0
def run_hf(xyz,
           basis,
           charge=0,
           multiplicity=1,
           conv_tol=1e-11,
           conv_tol_grad=1e-8,
           max_iter=150,
           pe_options=None):
    basissets = {
        "sto3g": "sto-3g",
        "def2tzvp": "def2-tzvp",
        "ccpvdz": "cc-pvdz",
    }

    # needed for PE and PCM tests
    psi4.core.clean_options()
    mol = psi4.geometry(f"""
        {charge} {multiplicity}
        {xyz}
        symmetry c1
        units au
        no_reorient
        no_com
    """)

    psi4.core.be_quiet()
    psi4.set_options({
        'basis': basissets.get(basis, basis),
        'scf_type': 'pk',
        'e_convergence': conv_tol,
        'd_convergence': conv_tol_grad,
        'maxiter': max_iter,
        'reference': "RHF",
    })
    if pe_options:
        psi4.set_options({"pe": "true"})
        psi4.set_module_options("pe", {"potfile": pe_options["potfile"]})

    if multiplicity != 1:
        psi4.set_options({
            'reference': "UHF",
            'maxiter': max_iter + 500,
            'soscf': 'true'
        })

    _, wfn = psi4.energy('SCF', return_wfn=True, molecule=mol)
    psi4.core.clean()
    return wfn
示例#25
0
def test_input_simple():
    """Test input for a simple computation using the `ROOT_SYM` keyword."""    
    import math
    import psi4
    import forte
    import pytest

    psi4.geometry("""
    Li
    H 1 3.0
    units bohr
    """)

    ref_efci_0 = -8.008550659909
    ref_efci_1 = -7.396156201698
    ref_efci_2 = -7.853436217184
    ref_efci_3 = -7.853436217157

    # need to clean the options otherwise this job will interfere
    forte.clean_options()

    psi4.set_options({'basis': 'DZ', 'scf_type': 'pk', 'e_convergence': 12})
    
    psi4.set_module_options(
        'FORTE', {
            'active_space_solver': 'fci',
            'active': [8, 0, 2, 2],
            'restricted_docc': [0, 0, 0, 0],
            'root_sym': 0,
            'multiplicity' : 1,
            'ms': 0.0
        }
    )
    psi4.core.set_output_file('debug.txt',False)
    efci = psi4.energy('forte')
    print('Test 1')
    assert efci == pytest.approx(ref_efci_0, 1.0e-9)

    print('Test 2')
    psi4.set_module_options('FORTE', {
        'root_sym': 1,
    })
    efci = psi4.energy('forte')
    assert efci == pytest.approx(ref_efci_1, 1.0e-9)

    psi4.set_module_options('FORTE', {
        'root_sym': 2,
    })
    efci = psi4.energy('forte')
    assert efci == pytest.approx(ref_efci_2, 1.0e-9)

    psi4.set_module_options('FORTE', {
        'root_sym': 3,
    })
    efci = psi4.energy('forte')
    assert efci == pytest.approx(ref_efci_3, 1.0e-9)
示例#26
0
def test_v2rdm6():
    #! cc-pvdz N2 (6,6) active space Test DQG

    print('        N2 / cc-pVDZ / DQG(6,6), geometry optimization')

    import psi4

    n2 = psi4.geometry("""
    0 1
    n
    n 1 1.1
    """)

    psi4.set_options({
        'basis': 'cc-pvdz',
        'scf_type': 'pk',
        'd_convergence': 1e-10,
        'maxiter': 500,
        'restricted_docc': [2, 0, 0, 0, 0, 2, 0, 0],
        'active': [1, 0, 1, 1, 0, 1, 1, 1],
    })
    psi4.set_module_options(
        'v2rdm_casscf',
        {
            'positivity': 'dqg',
            #'r_convergence': 1e-7,
            'r_convergence': 1e-6,
            'e_convergence': 1e-5,
            'orbopt_gradient_convergence': 1e-8,
            'maxiter': 20000,
        })

    psi4.activate(n2)

    psi4.optimize('v2rdm-casscf')

    refnuc = 23.1968666562054260
    refscf = -108.95016246035139
    refv2rdm = -109.095505119442

    assert psi4.compare_values(refnuc, n2.nuclear_repulsion_energy(), 4,
                               "Nuclear repulsion energy")
    assert psi4.compare_values(refscf, psi4.variable("SCF TOTAL ENERGY"), 5,
                               "SCF total energy")
    assert psi4.compare_values(refv2rdm, psi4.variable("CURRENT ENERGY"), 4,
                               "v2RDM-CASSCF total energy")
示例#27
0
def test_v2rdm():
    #! cc-pvdz N2 (6,6) active space Test DQG

    print('        N2 / cc-pVDZ / DQG(6,6), scf_type = DF, rNN = 1.1 A')

    import psi4

    import sys
    sys.path.insert(0, '../..')
    import hilbert

    n2 = psi4.geometry("""
    0 1
    n
    n 1 r
    """)

    psi4.set_options({
        'basis': 'cc-pvdz',
        'scf_type': 'df',
        'd_convergence': 1e-10,
        'maxiter': 500,
        'restricted_docc': [2, 0, 0, 0, 0, 2, 0, 0],
        'active': [1, 0, 1, 1, 0, 1, 1, 1],
    })
    psi4.set_module_options(
        'hilbert', {
            'positivity': 'dqg',
            'r_convergence': 1e-5,
            'e_convergence': 1e-6,
            'maxiter': 20000,
        })

    psi4.activate(n2)

    n2.r = 1.1
    refscf = -108.95348837831371
    refv2rdm = -109.094404909477

    psi4.energy('v2rdm-casscf')

    assert psi4.compare_values(refscf, psi4.variable("SCF TOTAL ENERGY"), 8,
                               "SCF total energy")
    assert psi4.compare_values(refv2rdm, psi4.variable("CURRENT ENERGY"), 5,
                               "v2RDM-CASSCF total energy")
示例#28
0
def test_v2rdm8():
    # H2 / cc-pVDZ / D(2,2), scf_type = DF, rHH = 1.0 A

    print('        H2 / cc-pVDZ / D(2,2), scf_type = DF, rHH = 1.0 A')

    import v2rdm_casscf
    import psi4

    h2 = psi4.geometry("""
    0 1
    h
    h 1 r
    symmetry c1
    """)

    psi4.set_options({
        "basis": "cc-pvdz",
        "mcscf_type": "df",
        "scf_type": "df",
        "d_convergence": 1e-10,
        "maxiter": 500,
        "restricted_docc": [0],
        "restricted_uocc": [8],
        "active": [2],
    })
    psi4.set_module_options(
        'v2rdm_casscf', {
            "positivity": "d",
            "r_convergence": 1e-6,
            "e_convergence": 1e-8,
            "maxiter": 20000,
        })

    psi4.activate(h2)

    h2.r = 1.0

    psi4.set_options({"df_ints_io": "save"})
    en, wfn = psi4.energy('scf', return_wfn=True)

    en1 = v2rdm_casscf.v2rdm_scf_solver(wfn)
    en2 = psi4.energy('casscf')

    assert psi4.compare_values(en1, en2, 6, "v2RDM-CASSCF total energy")
示例#29
0
def test_h2o_rfo():
    h2o = psi4.geometry("""
     O
     H 1 1.0
     H 1 1.0 2 104.5
    """)

    psi4.set_options({
        'basis': 'cc-pvtz',
        'e_convergence': '10',
        'd_convergence': '10',
        'scf_type': 'pk',
    })

    psi4.set_module_options('Optking', {'step_type': 'rfo'})
    Psi4Opt.calcName = 'hf'
    E = Psi4Opt.Psi4Opt()
    assert psi4.compare_values(finalEnergy, E, 6,
                               "RFO Step Final Energy")  #TEST
示例#30
0
def v2rdm_pyscf():

    # pyscf reference
    np.set_printoptions(linewidth=500)
    basis = 'STO-3G'
    mol = pyscf.M(
        atom='B 0 0 0; H 0 0 {}'.format(1.1),
        basis=basis)

    mf = mol.RHF()
    mf.verbose = 3
    mf.run()

    # make h1 and spatial integrals in MO basis
    eri = ao2mo.kernel(mol, mf.mo_coeff)
    eri = ao2mo.restore(1, eri, mf.mo_coeff.shape[1])

    # this produces spatial MO h1 integrals
    h1 = reduce(np.dot, (mf.mo_coeff.T, mf.get_hcore(), mf.mo_coeff))

    # these parameters are hard-coded for now
    nalpha = 3
    nbeta  = 3
    nmo    = 6

    # hilbert options
    psi4.set_module_options('hilbert', {
      #'sdp_solver':      'rrsdp',
      'positivity':      'dqg',
      'r_convergence':   1e-5,
      'e_convergence':   1e-4,
      'maxiter':         20000,
    })

    # grab options object
    options = psi4.core.get_options()
    options.set_current_module('HILBERT')

    v2rdm_pyscf = hilbert.v2RDMHelper(nalpha,nbeta,nmo,h1.flatten(),eri.flatten(),options)
    current_energy = v2rdm_pyscf.compute_energy()

    return current_energy
示例#31
0
def test_v2rdm5():
    #! cc-pvdz N2 (6,6) active space Test DQG

    print('        N2 / cc-pVDZ / DQG+T2(6,6), scf_type = PK, rNN = 1.1 A')

    import psi4

    n2 = psi4.geometry("""
    0 1
    n
    n 1 r
    """)

    psi4.set_options({
        'basis': 'cc-pvdz',
        'scf_type': 'pk',
        'd_convergence': 1e-10,
        'maxiter': 500,
        'restricted_docc': [2, 0, 0, 0, 0, 2, 0, 0],
        'active': [1, 0, 1, 1, 0, 1, 1, 1],
    })
    psi4.set_module_options(
        'v2rdm_casscf', {
            'positivity': 'dqgt2',
            'r_convergence': 1e-4,
            'e_convergence': 5e-4,
            'maxiter': 20000,
        })

    psi4.activate(n2)

    n2.r = 1.1
    refscf = -108.95379624015767
    refv2rdm = -109.091487394061

    psi4.energy('v2rdm-casscf')

    assert psi4.compare_values(refscf, psi4.variable("SCF TOTAL ENERGY"), 8,
                               "SCF total energy")
    assert psi4.compare_values(refv2rdm, psi4.variable("CURRENT ENERGY"), 4,
                               "v2RDM-CASSCF total energy")
示例#32
0
    def __init__(self, mol, freeze_core=False, memory=2):

        if freeze_core:
            raise Exception("Frozen core doesnt work yet!")
        print("\nInitalizing CCSD object...\n")

        # Integral generation from Psi4's MintsHelper
        time_init = time.time()

        print('Computing RHF reference.')
        psi4.core.set_active_molecule(mol)
        psi4.set_module_options('SCF', {'SCF_TYPE': 'PK'})
        psi4.set_module_options('SCF', {'E_CONVERGENCE': 10e-10})
        psi4.set_module_options('SCF', {'D_CONVERGENCE': 10e-10})

        # Core is frozen by default
        if not freeze_core:
            psi4.set_module_options('CCENERGY', {'FREEZE_CORE': 'FALSE'})

        self.rhf_e, self.wfn = psi4.energy('SCF', return_wfn=True)
        print('RHF Final Energy                          % 16.10f\n' % (self.rhf_e))

        self.ccsd_corr_e = 0.0
        self.ccsd_e = 0.0

        self.eps = np.asarray(self.wfn.epsilon_a())
        self.ndocc = self.wfn.doccpi()[0]
        self.nmo = self.wfn.nmo()
        self.memory = memory
        self.nfzc = 0

        # Freeze core
        if freeze_core:
            Zlist = np.array([mol.Z(x) for x in range(mol.natom())])
            self.nfzc = np.sum(Zlist > 2)
            self.nfzc += np.sum(Zlist > 10) * 4
            if np.any(Zlist > 18):
                raise Exception("Frozen core for Z > 18 not yet implemented")

            print("Cutting %d core orbitals." % self.nfzc)

            # Copy C
            oldC = np.array(self.wfn.Ca(), copy=True)

            # Build new C matrix and view, set with numpy slicing
            self.C = psi.Matrix(self.nmo, self.nmo - self.nfzc)
            self.npC = np.asarray(self.C)
            self.npC[:] = oldC[:, self.nfzc:]

            # Update epsilon array
            self.ndocc -= self.nfzc

        else:
            self.C = self.wfn.Ca()
            self.npC = np.asarray(self.C)

        mints = psi4.core.MintsHelper(self.wfn.basisset())
        H = np.asarray(mints.ao_kinetic()) + np.asarray(mints.ao_potential())
        self.nmo = H.shape[0]

        # Update H, transform to MO basis and tile for alpha/beta spin
        H = np.einsum('uj,vi,uv', self.npC, self.npC, H)
        H = np.repeat(H, 2, axis=0)
        H = np.repeat(H, 2, axis=1)

        # Make H block diagonal
        spin_ind = np.arange(H.shape[0], dtype=np.int) % 2
        H *= (spin_ind.reshape(-1, 1) == spin_ind)

        #Make spin-orbital MO
        print('Starting AO -> spin-orbital MO transformation...')

        ERI_Size = (self.nmo**4) * 128.e-9
        memory_footprint = ERI_Size * 5
        if memory_footprint > self.memory:
            psi.clean()
            raise Exception("Estimated memory utilization (%4.2f GB) exceeds numpy_memory \
                            limit of %4.2f GB." % (memory_footprint, self.memory))

        # Integral generation from Psi4's MintsHelper
        self.MO = np.asarray(mints.mo_spin_eri(self.C, self.C))
        print("Size of the ERI tensor is %4.2f GB, %d basis functions." % (ERI_Size, self.nmo))

        # Update nocc and nvirt
        self.nso = self.nmo * 2
        self.nfzc = self.nfzc * 2
        self.nocc = self.ndocc * 2
        self.nvirt = self.nso - self.nocc - self.nfzc * 2

        # Make slices
        self.slice_nfzc = slice(0, self.nfzc)
        self.slice_o = slice(self.nfzc, self.nocc + self.nfzc)
        self.slice_v = slice(self.nocc + self.nfzc, self.nso)
        self.slice_a = slice(0, self.nso)
        self.slice_dict = {'f': self.slice_nfzc, 'o': self.slice_o, 'v': self.slice_v, 'a': self.slice_a}

        #Extend eigenvalues
        self.eps = np.repeat(self.eps, 2)

        # Compute Fock matrix
        self.F = H + np.einsum('pmqm->pq', self.MO[:, self.slice_o, :, self.slice_o])

        ### Build D matrices
        print('\nBuilding denominator arrays...')
        Focc = np.diag(self.F)[self.slice_o]
        Fvir = np.diag(self.F)[self.slice_v]

        self.Dia = Focc.reshape(-1, 1) - Fvir
        self.Dijab = Focc.reshape(-1, 1, 1, 1) + Focc.reshape(-1, 1, 1) - Fvir.reshape(-1, 1) - Fvir

        ### Construct initial guess
        print('Building initial guess...')
        # t^a_i
        self.t1 = np.zeros((self.nocc, self.nvirt))
        # t^{ab}_{ij}
        self.t2 = self.MO[self.slice_o, self.slice_o, self.slice_v, self.slice_v] / self.Dijab

        print('\n..initialed CCSD in %.3f seconds.\n' % (time.time() - time_init))
示例#33
0
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.

    print(' Case Study Test of all SCF algorithms/spin-degeneracies: Singlet-Triplet O2')
    print('    -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.7884922572
    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()

    print('    -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')