Exemplo n.º 1
0
def test_pcmsolver():
    """pcmsolver/scf"""
    #! pcm

    nucenergy   =  12.0367196636183458
    polenergy   =  -0.0053060443528559
    totalenergy = -55.4559426361734040

    NH3 = psi4.geometry("""
    symmetry c1
    N     -0.0000000001    -0.1040380466      0.0000000000
    H     -0.9015844116     0.4818470201     -1.5615900098
    H     -0.9015844116     0.4818470201      1.5615900098
    H      1.8031688251     0.4818470204      0.0000000000
    units bohr
    no_reorient
    no_com
    """)

    psi4.set_options({
      'basis': 'STO-3G',
      'scf_type': 'pk',
      'pcm': True,
      'pcm_scf_type': 'total',
    })

    psi4.pcm_helper("""
       Units = Angstrom
       Medium {
       SolverType = IEFPCM
       Solvent = Water
       }

       Cavity {
       RadiiSet = UFF
       Type = GePol
       Scaling = False
       Area = 0.3
       Mode = Implicit
       }
    """)

    print('RHF-PCM, total algorithm')
    energy_scf1, wfn1 = psi4.energy('scf', return_wfn=True)
    assert psi4.compare_values(nucenergy, NH3.nuclear_repulsion_energy(), 10, "Nuclear repulsion energy (PCM, total algorithm)") #TEST
    assert psi4.compare_values(totalenergy, energy_scf1, 10, "Total energy (PCM, total algorithm)") #TEST
    assert psi4.compare_values(polenergy, wfn1.get_variable("PCM POLARIZATION ENERGY"), 6, "Polarization energy (PCM, total algorithm)") #TEST

    psi4.set_options({'pcm_scf_type': 'separate'})
    print('RHF-PCM, separate algorithm')
    energy_scf2 = psi4.energy('scf')
    assert psi4.compare_values(totalenergy, energy_scf2, 10, "Total energy (PCM, separate algorithm)")
    assert psi4.compare_values(polenergy, psi4.get_variable("PCM POLARIZATION ENERGY"), 6, "Polarization energy (PCM, separate algorithm)")

    # Now force use of UHF on NH3 to check sanity of the algorithm with PCM
    psi4.set_options({'pcm_scf_type': 'total', 'reference': 'uhf'})
    print('UHF-PCM, total algorithm')
    energy_scf3 = psi4.energy('scf')
    assert psi4.compare_values(totalenergy, energy_scf3, 10, "Total energy (PCM, separate algorithm)")
    assert psi4.compare_values(polenergy, psi4.get_variable("PCM POLARIZATION ENERGY"), 6, "Polarization energy (PCM, separate algorithm)")
Exemplo n.º 2
0
def run_psi4_tdscf(xyz,
                   basis,
                   charge=0,
                   multiplicity=1,
                   conv_tol=1e-12,
                   conv_tol_grad=1e-11,
                   max_iter=150,
                   pcm_options=None):
    mol = psi4.geometry(f"""
        {charge} {multiplicity}
        {xyz}
        units au
        symmetry c1
    """)
    psi4.set_options({
        'basis': basis_remap[basis],
        'scf_type': "pK",
        'e_convergence': conv_tol,
        'd_convergence': conv_tol_grad,
        'maxiter': max_iter,
        'reference': "RHF",
        'save_jk': True,
    })
    if pcm_options:
        # think its better to use a dict for the pcm options, because there
        # are already enough function arguments. Of course one could just
        # fix the options... would be sufficient for now too.
        psi4.set_options({'pcm': True, 'pcm_scf_type': "total"})
        psi4.pcm_helper(f"""
            Units = AU
            Cavity {{
                Type = Gepol
                Area = {pcm_options.get("weight", 0.3)}
            }}
            Medium {{
                Solvertype = {pcm_options.get("pcm_method", "IEFPCM")}
                Solvent = {pcm_options.get("solvent", "Water")}
                Nonequilibrium = {pcm_options.get("neq", True)}
            }}
        """)
    psi4.core.be_quiet()
    _, wfn = psi4.energy('scf', return_wfn=True, molecule=mol)

    res = tdscf_excitations(wfn,
                            states=5,
                            triplets="NONE",
                            tda=True,
                            r_convergence=1e-7)

    # remove cavity files from PSI4 PCM calculations
    if pcm_options:
        for cavityfile in os.listdir(os.getcwd()):
            if cavityfile.startswith(("cavity.off_", "PEDRA.OUT_")):
                os.remove(cavityfile)
    return wfn, res
Exemplo n.º 3
0
def psi4_run_pcm_hf(xyz, basis, charge=0, multiplicity=1, conv_tol=1e-12,
                    conv_tol_grad=1e-11, max_iter=150, pcm_options=None):
    basis_map = {
        "sto3g": "sto-3g",
        "ccpvdz": "cc-pvdz",
    }
    import psi4

    # 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': basis_map[basis],
        'scf_type': 'pk',
        'e_convergence': conv_tol,
        'd_convergence': conv_tol_grad,
        'maxiter': max_iter,
        'reference': "RHF",
        "pcm": True,
        "pcm_scf_type": "total",
    })
    psi4.pcm_helper(f"""
        Units = AU
        Cavity {{Type = Gepol
                Area = {pcm_options.get("weight", 0.3)}}}
        Medium {{Solvertype = {pcm_options.get("pcm_method", "IEFPCM")}
                Nonequilibrium = {pcm_options.get("neq", True)}
                Solvent = {pcm_options.get("solvent", "Water")}}}""")

    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 adcc.backends.import_scf_results(wfn)
Exemplo n.º 4
0
def set_solvent_parameters(params, scf_obj=None):
    if (params.qm_program == "psi4"):
        psi4.pcm_helper("""
            Units = Angstrom
            Medium {
            SolverType = IEFPCM
            Solvent = %s
            }
            Cavity {
            RadiiSet = UFF
            Type = GePol
            Scaling = False
            Area = 0.3
            Mode = Implicit
            }
        """ % params.pcm_solvent)
        params.keywords['pcm'] = "true"
        params.keywords['pcm_scf_type'] = "total"
    if (params.qm_program == "pyscf"):
        solv_obj = scf_obj.DDCOSMO()
        solv_obj.with_solvent.eps = params.eps
        scf_obj = solv_obj
    return scf_obj
Exemplo n.º 5
0
    no_com
    """)

psi4.set_options({
    'basis': "sto-3g",
    'scf_type': 'pk',
    'e_convergence': 1e-10,
    'd_convergence': 1e-10,
    'pcm': True,
    'pcm_scf_type': "total"
})
psi4.pcm_helper("""
    Units = AU
    Cavity {
        Type = GePol
    }
    Medium {
        SolverType = IEFPCM
        Solvent = Water
        Nonequilibrium = True
    }
""")

psi4.core.set_num_threads(4)

scf_e, wfn = psi4.energy('scf', return_wfn=True)

# Run an ADC2 calculation with ptLR
state = adcc.adc2(wfn, n_singlets=5, conv_tol=1e-8, environment="ptlr")
print(state.describe())