forte2.jkbuilder.jkbuilder#

Module Contents#

class forte2.jkbuilder.jkbuilder.FockBuilder(system, store_B_nPm=True)#

Class to build the Fock matrix using the Cholesky decomposition of the auxiliary basis integrals. This class computes the atomic Coulomb (J) and exchange (K) matrices using the auxiliary basis functions.

Parameters:
systemSystem or ModelSystem

The system for which to build the Fock matrix. If a ModelSystem is provided, it will decompose the 4D ERI tensor using Cholesky decomposition with complete pivoting.

store_B_nPmbool, optional, default=True

If True, stores a (Nao, Naux, Nao)-shaped copy of the B tensor for faster K builds. This comes at the cost of doubling the memory footprint of the FockBuilder object.

Attributes:
B_PmnNDArray

The B tensor with shape (Naux, Nao, Nao). Lazily evaluated.

nauxint

The number of auxiliary basis functions.

nbfint

The number of basis functions in the system.

system#
metric_ortho_rtol#
nbf#
store_B_nPm = True#
property B_Pmn#
property B_nPm#
build_J(D)#
build_K(C)#
build_JK(C)#

Compute the Coulomb and exchange matrices for a given set of orbitals.

\[\begin{split}J_{\mu\nu} = \sum_{i}\sum_{\rho\sigma} (\mu\nu|\rho\sigma) C_{\sigma i} C^*_{\rho i}\\ K_{\mu\nu} = \sum_{i}\sum_{\rho\sigma} (\mu\sigma|\rho\nu) C_{\sigma i} C^*_{\rho i}\end{split}\]
Parameters:
Clist of NDArray

List of coefficient matrices for the orbitals.

Returns:
tuple(list[NDArray], list[NDArray])

A tuple containing the lists of Coulomb (J) and exchange (K) matrices.

build_JK_generalized(C, g1)#

Compute the generalized Coulomb and exchange matrices for a given set of orbitals. These are used in building the generalized Fock matrix in multi-reference methods. The generalized J and K matrices are defined as

\[\begin{split}J_{\mu\nu} = \sum_{uv}\sum_{\rho\sigma} (\mu\nu|\rho\sigma) C^*_{\rho u} C_{\sigma v} \gamma_{uv}\\ K_{\mu\nu} = \sum_{uv}\sum_{\rho\sigma} (\mu\sigma|\rho\nu) C^*_{\rho u} C_{\sigma v} \gamma_{uv}\end{split}\]
Parameters:
CNDArray

Coefficient matrix for the orbitals.

g1NDArray

One-electron density matrix (1-RDM) in the MO basis.

Returns:
tuple(NDArray, NDArray)

A tuple containing the generalized Coulomb (J) and exchange (K) matrices.

two_electron_integrals_gen_block(C1, C2, C3, C4)#

Compute the two-electron integrals for a given set of orbitals. This method is general and can handle different sets of orbitals for each index (p, q, r, s).

The resulting integrals are stored in a 4D array with the following convention: V[p,q,r,s] = \(\langle pq | rs \rangle\), where

\[\langle pq | rs \rangle = \iint \phi^*_p(r_1) \phi^*_q(r_2) \frac{1}{r_{12}} \phi_r(r_1) \phi_s(r_2) dr_1 dr_2\]
Parameters:
C1NDArray

Coefficient matrix for the first set of orbitals (index p).

C2NDArray

Coefficient matrix for the second set of orbitals (index q).

C3NDArray

Coefficient matrix for the third set of orbitals (index r).

C4NDArray

Coefficient matrix for the fourth set of orbitals (index s).

Returns:
VNDArray

The two-electron integrals in the form of a 4D array.

two_electron_integrals_block(C)#

Compute the two-electron integrals for a given set of orbitals.

The resulting integrals are stored in a 4D array with the following convention: V[p,q,r,s] = \(\langle pq | rs \rangle\), where

\[\langle pq | rs \rangle = \iint \phi^*_p(r_1) \phi^*_q(r_2) \frac{1}{r_{12}} \phi_r(r_1) \phi_s(r_2) dr_1 dr_2\]
Parameters:
CNDArray

Coefficient matrix for the set of orbitals.

Returns:
VNDArray

The two-electron integrals in the form of a 4D array.

two_electron_integrals_gen_block_spinor(C1, C2, C3, C4)#

Compute the two-electron integrals for a given set of orbitals. This method is general and can handle different sets of orbitals for each index (p, q, r, s).

The resulting integrals are stored in a 4D array with the following convention: V[p,q,r,s] = \(\langle pq | rs \rangle\), where

\[\langle pq | rs \rangle = \iint \phi^*_p(r_1) \phi^*_q(r_2) \frac{1}{r_{12}} \phi_r(r_1) \phi_s(r_2) dr_1 dr_2\]
Parameters:
C1NDArray

Coefficient matrix for the first set of orbitals (index p).

C2NDArray

Coefficient matrix for the second set of orbitals (index q).

C3NDArray

Coefficient matrix for the third set of orbitals (index r).

C4NDArray

Coefficient matrix for the fourth set of orbitals (index s).

Returns:
VNDArray

The two-electron integrals in the form of a 4D array.

two_electron_integrals_block_spinor(C)#

Compute the two-electron integrals for a given set of spin-orbitals.

The resulting integrals are stored in a 4D array with the following convention: V[p,q,r,s] = \(\langle pq | rs \rangle\), where

\[\langle pq | rs \rangle = \iint \phi^*_p(r_1) \phi^*_q(r_2) \frac{1}{r_{12}} \phi_r(r_1) \phi_s(r_2) dr_1 dr_2\]
Parameters:
CNDArray

Coefficient matrix for the set of spin-orbitals.

antisymmetrizebool, optional, default=False

Whether to antisymmetrize the integrals. If True, the integrals are antisymmetrized as: V[p,q,r,s] = \(\langle pq || rs \rangle = \langle pq | rs \rangle - \langle pq | sr \rangle\)

Returns:
VNDArray

The two-electron integrals in the form of a 4D array.

B_tensor_gen_block(C1, C2)#

Compute the MO basis B tensor for a given set of orbitals. This method is general and can handle different sets of orbitals for each index (p, q).

The resulting B tensor is stored in a 3D array with the following convention: B[P,m,n] = \((P | mn)\), where

\[(P | mn) = \iint \phi_P(r_1) \frac{1}{r_{12}} \phi_m(r_2) \phi_n(r_2)dr_1 dr_2\]
Parameters:
C1NDArray

Coefficient matrix for the first set of orbitals (index p).

C2NDArray

Coefficient matrix for the second set of orbitals (index q).

Returns:
BNDArray

The B tensor in the form of a 3D array.

B_tensor_gen_block_spinor(C1, C2)#

Compute the spinorbital basis B tensor for a given set of spin-orbitals. This method is general and can handle different sets of orbitals for each index (p, q).

The resulting B tensor is stored in a 3D array with the following convention: B[P,m,n] = \((P | mn)\), where

\[(P | mn) = \iint \phi_P(r_1) \frac{1}{r_{12}} \phi_m(r_2) \phi_n(r_2)dr_1 dr_2\]
Parameters:
C1NDArray

Coefficient matrix for the first set of spin-orbitals (index p).

C2NDArray

Coefficient matrix for the second set of spin-orbitals (index q).

Returns:
BNDArray

The B tensor in the form of a 3D array.

class forte2.jkbuilder.jkbuilder.FockBuilderOTF(system, jk_mem_thres_mb=4000, backend='auto')#

Class to build the Fock matrix on-the-fly without storing the B tensor. This is useful for large systems where storing the B tensor is not feasible.

Parameters:
systemSystem

The system for which to build the Fock matrix.

jk_mem_thres_mbfloat, optional, default=4000

The memory threshold in MB for deciding how to compute the J and K matrices. If the estimated memory requirement for storing the B tensor exceeds this threshold, the J and K matrices will be computed in a more memory-efficient way that does not require storing the B tensor.

backendstr, optional, default=”auto”

The backend to use for computing the three-center two-electron integrals. Options are “auto”, “libint2”, and “libcint”. If “auto”, the backend will be chosen based on the maximum angular momentum of the auxiliary basis.

backend = ''#
system#
nbf#
jk_mem_thres_mb = 4000#
auxbasis#
basis#
nshb#
naux#
nshaux#
aux_sh_offsets#
metric_ortho_rtol#
build_JK_generalized#
build_J(D)#
build_K(C)#
build_JK(C)#
B_tensor_gen_block(C1, C2)#
B_tensor_gen_block_spinor(C1, C2)#
two_electron_integrals_gen_block(C1, C2, C3, C4)#
two_electron_integrals_block(C)#
two_electron_integrals_gen_block_spinor(C1, C2, C3, C4)#
two_electron_integrals_block_spinor(C)#