Beispiel #1
0
def _core_jk_build(orbital_basis: core.BasisSet, aux: core.BasisSet = None, jk_type: str = None, do_wK: bool = None, memory: int = None) -> core.JK:
    """
    Constructs a Psi4 JK object from an input basis.

    Parameters
    ----------
    orbital_basis
        Orbital basis to use in the JK object.
    aux
        Optional auxiliary basis set for density-fitted tensors. Defaults
        to the DF_BASIS_SCF if set, otherwise the correspond JKFIT basis
        to the passed in `orbital_basis`.
    jk_type
        Type of JK object to build (DF, Direct, PK, etc). Defaults to the
        current global SCF_TYPE option.

    Returns
    -------
    JK
        Uninitialized JK object.

    Example
    -------

    jk = psi4.core.JK.build(bas)
    jk.set_memory(int(5e8)) # 4GB of memory
    jk.initialize()

    ...

    jk.C_left_add(matirx)
    jk.compute()
    jk.C_clear()

    ...

    """

    optstash = optproc.OptionsState(["SCF_TYPE"])

    if jk_type is not None:
        core.set_global_option("SCF_TYPE", jk_type)

    if aux is None:
        if core.get_global_option("SCF_TYPE") == "DF":
            aux = core.BasisSet.build(orbital_basis.molecule(), "DF_BASIS_SCF", core.get_option("SCF", "DF_BASIS_SCF"),
                                      "JKFIT", orbital_basis.name(), orbital_basis.has_puream())
        else:
            aux = core.BasisSet.zero_ao_basis_set()

    if (do_wK is None) or (memory is None):
        jk = core.JK.build_JK(orbital_basis, aux)
    else:
        jk = core.JK.build_JK(orbital_basis, aux, bool(do_wK), int(memory))

    optstash.restore()
    return jk
Beispiel #2
0
    def __init__(self, scf, df_basis_name=''):
        self.df_basis_name = df_basis_name
        self.nocc, self.ntot, self.e, self.gao, self.E_scf, self.molecule = scf.nocc, scf.ntot, scf.e, scf.g, scf.E_scf, scf.molecule

        if self.df_basis_name:
            df_basis = BasisSet.build(self.molecule, 'DF_BASIS_MP2', df_basis_name, puream=0)
            self.gmo = transform_integrals_df(scf.C, scf.basis, df_basis, bool(scf.spin))
        else:
            if scf.spin != 0 and len(scf.H) == len(self.gao):
                self.gao = block_tei(self.gao)
            self.gmo = transform_integrals(scf.C, self.gao)
Beispiel #3
0
def modeVectorsQCDB(mol, hessian, modesToReturn=None, print_lvl=1, pr=print):
    Natom = mol.natom()
    geom = mol.geometry().to_array()
    masses = np.asarray([mol.mass(at) for at in range(Natom)])
    atom_symbols = [mol.symbol(at) for at in range(Natom)] 

    pr("\n\tCalculating normal modes; Input coordinates (bohr)\n")
    for i in range(Natom):
        pr("\t{:5s}{:10.5f}{:15.10f}{:15.10f}{:15.10f}\n".format(
           atom_symbols[i],masses[i],geom[i,0],geom[i,1],geom[i,2]))

    basis = BasisSet.build(mol) # dummy bs to lookup symmetry info
    irrep_lbls = mol.irrep_labels() # labels of IRREPs if molecule has symmetry
    dipder = None  # unneeded dipole-moment derivatives unless we add intensities

    vibinfo, vibtext = qcdb.vib.harmonic_analysis(hessian, geom, masses, basis,
                        irrep_lbls, dipder, project_trans=True, project_rot=True)

    # pr(vibtext)
    freqs = vibinfo['omega'].data.real
    # modes from vibinfo are unmass-weighted, not normalized, returned as cols
    # in amu^-1/2 ; convert here to au^-1/2
    modes = sqrt(pc_au2amu) * vibinfo['w'].data.T

    # Resort from high to low freqs
    modes[:] = np.flip(modes, axis=0)
    freqs[:] = np.flip(freqs)

    pr("\n\t----------------------\n")
    pr("\t Mode #   Harmonic      \n")
    pr("\t          Freq. (cm-1)  \n")
    pr("\t------------------------\n")
    for i in range(0,3*Natom):
        if freqs[i] < 0.0:
            pr("\t  %3d   %10.2fi\n" % (i, abs(freqs[i])))
        else:
            pr("\t  %3d   %10.2f \n" % (i, freqs[i]))

    selected_modes = np.zeros( (len(modesToReturn),3*Natom))
    selected_freqs = np.zeros( len(modesToReturn) )

    for i, mode in enumerate(modesToReturn):
        selected_modes[i,:] = modes[mode,:]
        selected_freqs[i] = freqs[mode]

    pr("\nFrequencies (with modes) returned from modeVectorsPsi4.\n")
    pr(str(selected_freqs)+'\n')

    if print_lvl > 1:
        pr("\nVectors returned from modeVectorsPsi4 are rows.\n")
        pr(str(selected_modes)+'\n')

    return (selected_modes, selected_freqs)
Beispiel #4
0
def eri(bs1, bs2, bs3=0, bs4=0):
    """
    Electron repulsion integral helper function
    Automatically forms any needed zero basis and squezes the result
    """
    zero = BasisSet.zero_ao_basis_set()
    mints = MintsHelper(bs1)

    if not bs3:
        res = mints.ao_eri(bs1, zero, bs2, zero)
    elif not bs4:
        res = mints.ao_eri(bs1, bs2, bs3, zero)

    return np.squeeze(res)
Beispiel #5
0
    def __init__(self, scf, df_basis_name=''):
        self.df_basis_name = df_basis_name
        self.nocc, self.ntot, self.e, self.gao, self.E_scf, self.molecule = scf.nocc, scf.ntot, scf.e, scf.g, scf.E_scf, scf.molecule

        if self.df_basis_name:
            df_basis = BasisSet.build(self.molecule,
                                      'DF_BASIS_MP2',
                                      df_basis_name,
                                      puream=0)
            self.gmo = transform_integrals_df(scf.C, scf.basis, df_basis,
                                              bool(scf.spin))
        else:
            if scf.spin != 0 and len(scf.H) == len(self.gao):
                self.gao = block_tei(self.gao)
            self.gmo = transform_integrals(scf.C, self.gao)