Basis set

A basis set is the collection of matrix elements and associated functions.

class quantum_systems.BasisSet(l, dim, np=None, includes_spin=False, anti_symmetrized_u=False)

Class serving as a container for matrix elements for various systems. The purpose of BasisSet after a set has been constructed is to be passed to a subclass of QuantumSystem. From there on the QuantumSystem takes ownership of the matrix elements and provides methods and functionality to be used by second-quantized many-body methods.

Parameters
  • l (int) – Number of basis functions.

  • dim (int) – Dimensionality of the systems.

  • np (module) – Matrix and linear algebra module. Currently only numpy is supported.

  • includes_spin (bool) – Toggle to determine if the basis set to be created includes explicitly in the basis functions. By default we assume that BasisSet only contains spatial orbitals thus there are no explicit spin-dependence in the elements.

  • anti_symmetrized_u (bool) – Toggle to determine if the two-body matrix elements have been anti_symmetrized. By default we assume that this is not the case.

anti_symmetrize_two_body_elements()

Function making the two-body matrix elements anti-symmetric. This corresponds to

\[\langle \phi_p \phi_q \rvert \hat{u} \lvert \phi_r \phi_s \rangle_{AS} \equiv \langle \phi_p \phi_q \rvert \hat{u} \lvert \phi_r \phi_s \rangle - \langle \phi_p \phi_q \rvert \hat{u} \lvert \phi_s \phi_r \rangle.\]
cast_to_complex()

Function converting all matrix elements to np.complex128, where np is the member array module.

change_basis(C, C_tilde=None)

Function using coefficient matrices to change basis of the matrix elements and the single-particle functions. This function also supports rectangular coefficient matrices meaning that the number of basis functions can be updated. Let :math`lvert chi_{alpha} rangle` (\(\langle \tilde{\chi}_{\alpha} \rvert\)) be the current basis set with \(\alpha \in \{1, \dots, N_{\alpha}\}\), and \(\lvert \phi_p \rangle\) (\(\langle \tilde{\phi}_p \rvert\))the new basis with \(p \in \{1, \dots, N_p\}\). Then, for a given coefficient matrix \(C \in \mathbb{C}^{N_{p}\times N_{\alpha}}\) (\(\tilde{C} \in \mathbb{C}^{N_{\alpha} \times N_p}\)) the basis change for a single particle state is given by

\[\lvert \phi_p \rangle = C^{\alpha}_{p} \lvert\chi_{\alpha}\rangle,\]

where the Einstein summation convention is assumed. Similarly for the dual state we have

\[\langle\tilde{\phi}_p\rvert = \tilde{C}^{p}_{\alpha} \langle\tilde{\chi}_{\alpha}\rvert.\]

In case of a Hermitian basis we have \(\tilde{C} = C^{\dagger}\), and the dual states are the Hermitian adjoint of one another.

Parameters
  • C (np.ndarray) – Coefficient matrix for “ket”-states.

  • C_tilde (np.ndarray) – Coefficient matrix for “bra”-states, by default C_tilde is None and we treat C_tilde as the Hermitian conjugate of C.

change_module(np)

Function converting all matrix elements to a new module.

Parameters

np (module) – Array- and linalg-module.

change_to_general_orbital_basis(a=[1, 0], b=[0, 1], anti_symmetrize=True)

Function converting a spatial orbital basis set to a general orbital basis. That is, the function duplicates every element by adding a spin-function to each spatial orbital. This leads to an orbital-restricted spin-orbital where each spatial orbital is included in each spin-direction.

\[\phi_p(\mathbf{r}) \to \psi_p(x) = \phi_p(\mathbf{r}) \sigma(m_s),\]

where \(x = (\mathbf{r}, m_s)\) is a generalized coordinate of both position \(\mathbf{r}\) and spin \(m_s\). Here \(\phi_p(\mathbf{r})\) is a spatial orbital and \(\sigma(m_s)\) a spin-function with \(\sigma \in \{\alpha, \beta\}\). The conversion happens in-place.

Parameters
  • a (list, np.array) – The \(\alpha\) (up) spin basis vector. Default is \(\alpha = (1, 0)^T\).

  • b (list, np.array) – The \(\beta\) (down) spin basis vector. Default is \(\beta = (0, 1)^T\). Note that a and b are assumed orthonormal.

  • anti_symmetrize (bool) – Whether or not to anti-symmetrize the elements in the two-body Hamiltonian. By default we perform an anti-symmetrization.

compute_particle_density(rho_qp, C=None, C_tilde=None)

Function computing the particle density for a given one-body density matrix. This function (optionally) changes the basis of the single-particle states for given coefficient matrices. The one-body density is given by

\[\rho(\mathbf{r}) = \tilde{\phi}_{q}(\mathbf{r}) \rho^{q}_{p} \phi_{p}(\mathbf{r}),\]

where \(\rho^{q}_{p}\) is the one-body density matrix, \(\phi_p(\mathbf{r})\) the spin-orbitals, and \(\tilde{\phi}_p(\mathbf{r})\) the dual spin-orbital.

Parameters
  • rho_qp (np.ndarray) – One-body density matrix

  • C (np.ndarray) – Coefficient matrix for basis change. Default is None and hence no transformation occurs.

  • C_tilde (np.ndarray) – Bra-state coefficient matrix. Default is None which leads to one of two situations. If C != None C_tilde is assumed to be the conjugated transpose of C. Otherwise, no transformation occurs.

Returns

Particle density with the same dimensions as the grid.

Return type

np.ndarray

copy_basis()

Function creating a deep copy of the current basis. This function is a hack as we have to temporarily remove the stored module before using Python’s copy.deepcopy-function.

Returns

A deep copy of the current basis.

Return type

BasisSet

static setup_pauli_matrices(a, b, np)

Static method computing matrix elements of the Pauli spin-matrices in a given orthonormal basis of spin functions \(\{\alpha, \beta\}\).

\[(\sigma_i)^{\rho}_{\gamma} = \langle \rho \rvert \hat{\sigma}_i \lvert \gamma \rangle,\]

where \(\rho, \gamma \in \{\alpha, \beta\}\) and \(i \in \{x, y, z\}\) for the three Pauli matrices.

Parameters
  • a (np.ndarray) – The \(\alpha\) basis vector as a column vector.

  • b (np.ndarray) – The \(\beta\) basis vector as a column vector. Note that the two basis vectors are assumed to be orthonormal.

  • np (module) – An appropriate array and linalg module.

Returns

The three Pauli matrices in the order \(\sigma_x, \sigma_y, \sigma_z\).

Return type

tuple

Example

>>> import numpy as np
>>> a = np.array([1, 0]).reshape(-1, 1)
>>> b = np.array([0, 1]).reshape(-1, 1)
>>> sigma_x, sigma_y, sigma_z = BasisSet.setup_pauli_matrices(a, b, np)
>>> print(sigma_x)
[[0.+0.j 1.+0.j]
 [1.+0.j 0.+0.j]]
>>> print(sigma_y)
[[0.+0.j 0.-1.j]
 [0.+1.j 0.+0.j]]
>>> print(sigma_z)
[[ 1.+0.j  0.+0.j]
 [ 0.+0.j -1.+0.j]]
static setup_spin_squared_operator(spin_x, spin_y, spin_z, overlap, np)

Static method computing the matrix elements of the one- and two-body spin squared operator, \(\hat{S}^2\). The operator is computed by

\[\hat{S}^2 = \hat{S}_x^2 + \hat{S}_y^2 + \hat{S}_z^2,\]

where each squared direction \(\hat{S}_i^2\) can be written

\[\hat{S}_i^2 = (S_i)^{p}_{r} (S_i)^{r}_{q} \hat{c}^{\dagger}_{p} \hat{c}_{q} + (S_i)^{p}_{r} (S_i)^{q}_{s} \hat{c}^{\dagger}_{p} \hat{c}^{\dagger}_{q} \hat{c}_{s} \hat{c}_{r},\]

in the second quantization formulation.

Parameters
  • spin_x (np.ndarray) – Spin-matrix in \(x\)-direction including orbital overlap.

  • spin_y (np.ndarray) – Spin-matrix in \(y\)-direction including orbital overlap.

  • spin_z (np.ndarray) – Spin-matrix in \(z\)-direction including orbital overlap.

  • overlap (np.ndarray) – The overlap matrix elements between the spin-orbitals.

  • np (module) – An appropriate array and linalg module.

Returns

The spin-squared operator as two arrays on the form (l, l) and (l, l, l, l), where l is the number of spin-orbitals. The former corresponds to the one-body part of the spin-squared operator whereas the latter is the two-body part.

Return type

(np.ndarray, np.ndarray)