HF.hartree_fock#
functions to perform a Hartree-Fock computation on the lattice
Functions
|
Computes the Hartree-Fock energy for a given density dens and Hamiltonian consisting of one-body term op1, two-body term op2, and three-body term op3 :param op1: list of one-body matrix elements :type op1: list[list[int,int, float]] :param op2: list of two-body matrix elements :type op2: list[list[int,int,int,int, float]] :param op3: list of three-body matrix elements :type op3: list[list[int,int,int,int,int,int, float]] :param dens: density matrix (same shape as op1) :type dens: numpy.array((:,:), dtype=float) :param w3_sparse: :return: Hartree-Fock energy :rtype: float |
|
Performs one iteration of the Hartree-Fock procedure |
|
takes list of two-body matrix elements and contracts them with the density to get a one-body operator |
|
takes list of three-body matrix elements and contracts them with the density to get a one-body operator |
|
takes list of three-body matrix elements and contracts them with the density to get a one-body operator :param csr: matrix of three-body elements :type csr: scipy.sparse.csr_array :param dens: square density matrix :type dens: numpy.array((:,:), dtype=float) :return: one-body operator of the same shape as the density matrix dens :rtype: numpy.array((:,:), dtype=float) |
|
takes the list of one-body matrix elements and turns it into a square matrix |
|
creates a density matrix of dimension nstat x nstat given the hole information |
|
takes Hamiltonian consisting of one-body operator op1, two-body operator op2, and three-body operator op3, and the density matrix and returns the Hartree-Fock Hamiltonian. |
|
Solve the Hartree-Fock problem |
- HF.hartree_fock.get_1body_matrix(myTkin, nstat, dtype=<class 'float'>)#
takes the list of one-body matrix elements and turns it into a square matrix
- Parameters:
nstat (int) – dimension of matrix, i.e. the number of 1-body states
dtype (numpy.dtype, i.e. np.float64 or float or np.complex128 or complex) – data type of returned object
myTkin (list[list[int,int, float]]) – list of one-body matrix elements [[p1,q1,value1], [p2,q2,value2], …]
- Returns:
nstat x nstat matrix of the list of matrix elements
- Return type:
numpy.array((:,:), dtype=float)
- HF.hartree_fock.contract_2nf(v2, dens)#
takes list of two-body matrix elements and contracts them with the density to get a one-body operator
- Parameters:
v2 (list[list[int,int,int,int, float]]) – list of two-body matrix elements [p,q,r,s,value]
dens (numpy.array((:,:), dtype=float)) – square density matrix
- Returns:
one-body operator of the same shape as the density matrix dens
- Return type:
numpy.array((:,:), dtype=float)
- HF.hartree_fock.contract_3nf(w3, dens)#
takes list of three-body matrix elements and contracts them with the density to get a one-body operator
- Parameters:
w3 (list[list[int,int,int,int,int,int, float]]) – list of two-body matrix elements [p,q,r,s,value]
dens (numpy.array((:,:), dtype=float)) – square density matrix
- Returns:
one-body operator of the same shape as the density matrix dens
- Return type:
numpy.array((:,:), dtype=float)
- HF.hartree_fock.make_HF_ham(op1, op2, op3, dens)#
takes Hamiltonian consisting of one-body operator op1, two-body operator op2, and three-body operator op3, and the density matrix and returns the Hartree-Fock Hamiltonian.
- Parameters:
op1 (list[list[int,int, float]]) – list of one-body matrix elements
op2 (list[list[int,int,int,,int, float]]) – list of two-body matrix elements
op3 (list[list[int,int,int,int,int,int, float]]) – list of three-body matrix elements
dens (numpy.array((:,:), dtype=float)) – density matrix (same shape as op1)
- Returns:
matrix in the shape of op1 and dens that is the Hartree-Fock Hamiltonian
- Return type:
numpy.array((:,:), dtype=float)
- HF.hartree_fock.init_density(nstat, hole, dtype=<class 'float'>)#
creates a density matrix of dimension nstat x nstat given the hole information
- Parameters:
nstat (int) – dimension of single-particle basis
dtype (numpy.dtype, i.e. np.float64 or float or np.complex128 or complex) – data type of returned object
hole (tuple(int, int, ... )) – tuple of occupied single-particle states, as numbers from 0 … A-1
- Returns:
density matrix where hole states are occupied (1) and all others not (0)
- Return type:
numpy.array((nstat,nstat), dtype = float)
- HF.hartree_fock.HF_iter(op1, op2, op3, dens, mix=0.5)#
Performs one iteration of the Hartree-Fock procedure
- Parameters:
op1 (list[list[int,int, float]]) – list of one-body matrix elements
op2 (list[list[int,int,int,,int, float]]) – list of two-body matrix elements
op3 (list[list[int,int,int,int,int,int, float]]) – list of three-body matrix elements
dens (numpy.array((:,:), dtype=float)) – density matrix (same shape as op1)
mix (float) – returned density matrix is mix*new_density + (1-mix)*old_density
- Returns:
energy, density, vecs as the current HF energy, current density matrix, and orthogonal transformation matrix that diagonalizes the HF Hamiltonian
- Return type:
float, numpy.array((:,:), dtype=float), numpy.array((:,:), dtype=float)
- HF.hartree_fock.solve_HF(op1, op2, op3, dens, mix=0.5, eps=1e-08, max_iter=100, verbose=False)#
Solve the Hartree-Fock problem
- Parameters:
op1 (list[list[int,int, float]]) – list of one-body matrix elements
op2 (list[list[int,int,int,,int, float]]) – list of two-body matrix elements
op3 (list[list[int,int,int,int,int,int, float]]) – list of three-body matrix elements
dens (numpy.array((:,:), dtype=float)) – density matrix (same shape as op1)
mix (float) – parameter used in the mixing: mix*new_density + (1-mix)*old_density
eps (float) – converegence of energy
max_iter (float) – maximum number of HF iterations
- Returns:
energy, orthogonal transformation matrix that diagonalizes the HF Hamiltonian (the first A columns are occupied), converged
- Return type:
float, numpy.array((:,:), dtype=float), boolean
- HF.hartree_fock.HF_energy(op1, op2, op3, dens, w3_sparse=False)#
Computes the Hartree-Fock energy for a given density dens and Hamiltonian consisting of one-body term op1, two-body term op2, and three-body term op3 :param op1: list of one-body matrix elements :type op1: list[list[int,int, float]] :param op2: list of two-body matrix elements :type op2: list[list[int,int,int,int, float]] :param op3: list of three-body matrix elements :type op3: list[list[int,int,int,int,int,int, float]] :param dens: density matrix (same shape as op1) :type dens: numpy.array((:,:), dtype=float) :param w3_sparse: :return: Hartree-Fock energy :rtype: float
- HF.hartree_fock.contract_3nf_sparse(csr, dens)#
takes list of three-body matrix elements and contracts them with the density to get a one-body operator :param csr: matrix of three-body elements :type csr: scipy.sparse.csr_array :param dens: square density matrix :type dens: numpy.array((:,:), dtype=float) :return: one-body operator of the same shape as the density matrix dens :rtype: numpy.array((:,:), dtype=float)