SCF Functions#
To use the Huzinaga projector with Projection-based embedding, it’s necessary to make some changes to Hartree-Fock and Kohn-Sham SCF functions.
Huzinaga SCF Methods#
Perform Huzinaga RHF with PySCF.
- nbed.scf.huzinaga_scf.calculate_hf_energy(scf_method, embedding_potential, density_matrix, vhf, huzinaga_op_occ) float[source]#
Calculate the Hartree-Fock Energy.
- Parameters:
scf_method (scf.hf.SCF) – PySCF HF method
embedding_potential (np.ndarray) – DFT embedding potential
density_matrix (np.ndarray) – Embedded region density matrix (updates each cycle)
vhf (np.ndarray) – Mean field potential
huzinaga_op_occ (np.ndarray) – Huzinaga Fock operator
- Returns:
Hartree-fock energy
- Return type:
float
- nbed.scf.huzinaga_scf.calculate_ks_energy(scf_method, embedding_potential, density_matrix, huzinaga_op_occ) float[source]#
Calculate the Hartree-Fock Energy.
- Parameters:
scf_method (scf.hf.SCF) – PySCF Kohn-sham method
embedding_potential (np.ndarray) – DFT embedding potential
density_matrix (np.ndarray) – Embedded region density matrix (updates each cycle)
huzinaga_op_occ (np.ndarray) – Huzinaga Fock operator
- Returns:
Kohn-sham energy
- Return type:
float
- nbed.scf.huzinaga_scf.get_huzinaga_operator(fock: ndarray, dm_occ_S: ndarray, dm_virt_S: ndarray) ndarray[source]#
Return the huzinaga operator.
occupied :$-(S P_{occ} F + F P_{occ} S)$ virtuall :$-(S P_{virt} F+F P_{virt} S) + 2 S P_{virt} F P_{virt} S$
- Parameters:
fock (np.ndarray) – The Fock operator.
dm_occ_S (np.ndarray) – The density matrix (projector onto) the occupied environment orbitals.
dm_virt_S (np.ndarray) – The density matrix (projector onto) the virtual environment orbitals.
- nbed.scf.huzinaga_scf.huzinaga_scf(scf_method: SCF, embedding_potential: ndarray, dm_environment_occupied: ndarray, dm_environment_virtual: ndarray | None = None, dm_conv_tol: float = 1e-06, dm_initial_guess: ndarray | None = None, use_DIIS: bool | None = True) tuple[ndarray, ndarray, ndarray, ndarray, bool][source]#
Manual RHF calculation that is implemented using the huzinaga operator.
Note this function uses lowdin (symmetric) orthogonalization only! (PySCF sometimes uses meta-lowdin and NAO). Also the intial density matrix guess is based on the modified core Hamilotnian (containing projector and DFT potential) PySCF has other methods for initial guess that aren’t available here. Manual guess can also be given). TODO: make a subclass from PySCF RHF object. Can include all this functionality there. Problems in this function can occur due to DIIS and other clever PySCF methods not being available.
- Parameters:
scf_method (scf.hf.SCFy) – PySCF RHF object (containing info about max cycles and convergence tolerence)
embedding_potential (np.ndarray) – DFT active and environment two body terms - DFT active environemnt two body term
dm_environment_occupied (np.ndarray) – Density matrix of the environment occupied orbitals.
dm_environment_virtual (np.ndarray | None) – Density matrix of the environment virtual orbitals.
dm_conv_tol (float) – density matrix convergence tolerance.
dm_initial_guess (np.ndarray) – Optional initial guess density matrix.
use_DIIS (bool) – whether to use Direct Inversion in the Iterative Subspace (DIIS) method
- Returns:
Optimized C_matrix (columns are optimized moelcular orbtials) mo_energy (np.ndarray): 1D array of molecular orbital energies density_matrix (np.ndarray): Converged density matrix huzinaga_op_occ (np.ndarray): Huzinaga operator in standard basis (same basis as Fock operator). conv_flag (bool): Flag to indicate whether SCF has converged or not
- Return type:
mo_coeff_std (np.ndarray)
Embedded hcore Functions#
Functions from PySCF that need to be tweeked to allow our hack of adding Vemb to Hcore.
- nbed.scf.embedded_hcore_funcs.energy_elec(mf, dm=None, h1e=None, vhf=None) tuple[float, float][source]#
Electronic energy of Unrestricted Hartree-Fock.
Note this function has side effects which cause mf.scf_summary updated.
- Parameters:
mf (pyscf.scf.hf.HF) – Hartree-Fock object
dm (np.ndarray) – Density matrix
h1e (np.ndarray) – Core Hamiltonian
vhf (np.ndarray) – 2-electron contribution to effective potential
- Returns:
Hartree-Fock electronic energy e_coul (np.ndarray): 2-electron contribution to electronic energy
- Return type:
e_elec (np.ndarray)