Fermionic systems

In this subsection, we list a series of functions useful for fermionic systems.


Basic functions for the creation of many-fermion systems

quantnbody.fermionic.tools.build_nbody_basis(n_mo, N_electron, S_z_cleaning=False)

Create a many-body basis as a list of slater-determinants. Here, these states are occupation numbersvectors taking the form of bitstrings (e.g. |1100⟩) describing how the electrons occupy the spin-orbitals.

Parameters:
  • n_mo (int) – Number of molecular orbitals

  • N_electron (int OR list) – Number of electrons or list of number of electrons

  • S_z_cleaning (bool, default=False) – Option if we want to get rid of the s_z != 0 states (default is False)

Returns:

nbody_basis – List of many-body states (occupation number vectors).

Return type:

array

Examples

>>> build_nbody_basis(2, 2, False)  # 2 electrons in 2 molecular orbitals
array([[1, 1, 0, 0],
       [1, 0, 1, 0],
       [1, 0, 0, 1],
       [0, 1, 1, 0],
       [0, 1, 0, 1],
       [0, 0, 1, 1]])
quantnbody.fermionic.tools.build_operator_a_dagger_a(nbody_basis, silent=True)

Create a matrix representation of the a_dagger_a operator in the many-body basis

Parameters:
  • nbody_basis (array) – List of many-body states (occupation number states)

  • silent (bool, default=True) – If it is True, function doesn’t print anything when it generates a_dagger_a

Returns:

a_dagger_a – Matrix representation of the a_dagger_a operators

Return type:

array

Examples

>>> nbody_basis = nbody_basis(2, 2)
>>> a_dagger_a = build_operator_a_dagger_a(nbody_basis, True)
>>> a_dagger_a[0,0] # Get access to the operator counting the electron in the first spinorbital


Many-body Hamiltonians and excitations operators

quantnbody.fermionic.tools.build_hamiltonian_quantum_chemistry(h_, g_, nbody_basis, a_dagger_a, S_2=None, S_2_target=None, penalty=100, cut_off_integral=1e-08)

Create a matrix representation of the electronic structure Hamiltonian in the many-body basis

Parameters:
  • h (array) – One-body integrals

  • g (array) – Two-body integrals

  • nbody_basis (array) – List of many-body states (occupation number states)

  • a_dagger_a (array) – Matrix representation of the a_dagger_a operator

  • S_2 (array, default=None) – Matrix representation of the S_2 operator (default is None)

  • S_2_target (float, default=None) – Value of the S_2 mean value we want to target (default is None)

  • penalty (float, default=100) – Value of the penalty term to penalize the states that do not respect the spin symmetry (default is 100).

Returns:

H_chemistry – Matrix representation of the electronic structure Hamiltonian in the many-body basis

Return type:

array

quantnbody.fermionic.tools.build_hamiltonian_fermi_hubbard(h_, U_, nbody_basis, a_dagger_a, S_2=None, S_2_target=None, penalty=100, v_term=None, cut_off_integral=1e-08)

Create a matrix representation of the Fermi-Hubbard Hamiltonian in the many-body basis.

Parameters:
  • h (array) – One-body integrals

  • U (array) – Two-body integrals

  • nbody_basis (array) – List of many-body states (occupation number states)

  • a_dagger_a (array) – Matrix representation of the a_dagger_a operator

  • S_2 (array, default=None)) – Matrix representation of the S_2 operator (default is None)

  • S_2_target (float, default=None) – Value of the S_2 mean value we want to target (default is None)

  • penalty (float, default=100) – Value of the penalty term to penalize the states that do not respect the spin symmetry (default is 100).

  • v_term (array, default=None) – dipolar interactions.

Returns:

H_fermi_hubbard – Matrix representation of the Fermi-Hubbard Hamiltonian in the many-body basis

Return type:

array

quantnbody.fermionic.tools.build_E_and_e_operators(a_dagger_a, n_mo)

Build the spin-free “E” and “e” excitation many-body operators for quantum chemistry

Parameters:
  • a_dagger_a (array) – Matrix representation of the a_dagger_a operator

  • n_mo (int) – Number of molecular orbitals considered

Returns:

  • E_ (array) – Spin-free “E” many-body operators

  • e_ (array) – Spin-free “e” many-body operators

Examples

>>> nbody_basis = qnb.build_nbody_basis(2, 2)
>>> a_dagger_a = qnb.build_operator_a_dagger_a(nbody_basis)
>>> build_E_and_e_operators(a_dagger_a, 2)


Spin operators

quantnbody.fermionic.tools.build_s2_sz_splus_operator(a_dagger_a)

Create a matrix representation of the spin operators s_2, s_z and s_plus in the many-body basis.

Parameters:

a_dagger_a (array) – matrix representation of the a_dagger_a operator in the many-body basis.

Returns:

  • s_2 (array) – matrix representation of the s_2 operator in the many-body basis.

  • s_plus (array) – matrix representation of the s_plus operator in the many-body basis.

  • s_z (array) – matrix representation of the s_z operator in the many-body basis.

quantnbody.fermionic.tools.build_local_s2_sz_splus_operator(a_dagger_a, list_mo_local)

Create a matrix representation of the spin operators s2, s_z and s_plus in the many-body basis projected into a local basis defined by list_mo_local.

Parameters:
  • a_dagger_a (array) – a_dagger_a operator.

  • list_mo_local (list) – indices of the local Molecular Orbitals.

Returns:

  • s2_local (array) – matrix representation of the s2_local operator (local spin squared) in the many-body basis.

  • s_z_local (array) – matrix representation of the s_z_local operator (local spin projection) in the many-body basis.

  • s_plus_local (array) – matrix representation of the s_plus_local operator (local spin ladder up) in the many-body basis.

quantnbody.fermionic.tools.build_sAsB_coupling(a_dagger_a, list_mo_local_A, list_mo_local_B)

Create a matrix representation of the product of two local spin operators s_A x s_B in the many-body basis. Each one being associated to a local set of molecular orbitals attached to two different “molecular fragments” A and B.

Parameters:
  • a_dagger_a (array) – matrix representation of the a_dagger_a operator in the many-body basis.

  • list_mo_local_A (array) – List of molecular orbital indices belonging to fragment A

  • list_mo_local_B (array) – List of molecular orbital indices belonging to fragment B

Returns:

sAsB_coupling – matrix representation of s_A x s_B in the many-body basis.

Return type:

array

quantnbody.fermionic.tools.build_spin_subspaces(S2_local, S2_local_target)

Create a projector over the many-body space spanning all the configurations which should be counted to produce a local spin s2_local of value given by s2_local_target.

Parameters:
  • s2_local (array) – Local spin operator associated to a restricted number of orbitals

  • s2_local_target (array) – Value of the local spin target to create the assoacited many-body subspace

Returns:

Projector_spin_subspace – Projector over the many-body sub-space targeted (i.e. outer product of the many-body states respecting the local spin symmetry demanded)

Return type:

array



Creating/manipulating/visualizing many-body wavefunctions

quantnbody.fermionic.tools.my_state(slater_determinant, nbody_basis)

Translate a Slater determinant (occupation number list) into a many-body state referenced into a given Many-body basis.

Parameters:
  • slater_determinant (array) – occupation number list

  • nbody_basis (array) – List of many-body states (occupation number states)

Returns:

state – The slater determinant translated into the “kappa” many-body basis

Return type:

array

quantnbody.fermionic.tools.visualize_wft(WFT, nbody_basis, cutoff=0.005, ndets=8, atomic_orbitals=False, compact=False)

Print the decomposition of a given input wavefunction in a many-body basis.

Parameters:
  • WFT (array) – Reference wave function

  • nbody_basis (array) – List of many-body states (occupation number states)

  • cutoff (array) – Cut off for the amplitudes retained (default is 0.005)

  • ndets (int) – Maximum number of printed determinants

  • atomic_orbitals (Boolean) – If True then instead of 0/1 for spin orbitals we get 0/alpha/beta/2 for atomic orbitals

Return type:

Terminal printing of the wavefunction

quantnbody.fermionic.tools.build_projector_active_space(n_elec, frozen_indices, active_indices, virtual_indices, nbody_basis, show_states=False)

Build a many-body projector operator including all the many-body configurations respecting an active space structure such that :

Phi ⟩ = | frozen, active, virtual ⟩
Parameters:
  • n_elec (int,) – Total number of electron in the system

  • frozen_indices (array) – List of doubly occupied frozen orbitals

  • active_indices (array) – List of active orbitals

  • virtual_indices (array) – List of virtual unoccupied orbitals

  • nbody_basis (array) – List of many-body states (occupation number states)

Returns:

Proj_AS – Projector associated to the active-space defined

Return type:

array

quantnbody.fermionic.tools.weight_det(C_B2_B1, occ_spinorb_Det1, occ_spinorb_Det2)

Evaluate the overlap of two slater determinants expressed in two different orbital basis. This is actually given by the determinant of the overlap of the occupied spin orbital present in each slater determinant.

Parameters:
  • C_B2_B1 (array) – Coefficient matrix of the MO basis 1 expressed in the MO basis 2

  • occ_spinorb_Det1 (array) – Occupied spinorbital in the slater determinant 1 (bra)

  • occ_spinorb_Det2 (array) – occupied spinorbital in the slater determinant 2 (ket)

Returns:

Det_amplitude – resulting determinant of the occupied spinorbital from the two different basis

Return type:

float

quantnbody.fermionic.tools.scalar_product_different_MO_basis(Psi_A_MOB1, Psi_B_MOB2, C_MOB1, C_MOB2, nbody_basis)

Evaluate the non-trivial scalar product of two multi-configurational wavefunction expressed in two different molecular orbital basis.

Parameters:
  • Psi_A_MOB1 (array) – Wavefunction A (will be a Bra) expressed in the first orbital basis

  • Psi_B_MOB2 (array) – Wavefunction B (will be a Ket) expressed in the second orbital basis

  • C_MOB1 (array) – First basis’ Molecular orbital coefficient matrix

  • C_MOB2 (array) – Second basis’ Molecular orbital coefficient matrix

  • nbody_basis (array) – List of many-body state

Returns:

scalar_product – Amplitude of the scalar product

Return type:

float

quantnbody.fermionic.tools.transform_psi_MO_basis1_in_MO_basis2(Psi_A_MOB1, C_MOB1, C_MOB2, nbody_basis)

Transform a multi-configurational wavefunction originaly expressed in a molecular orbital basis B1 into another molecular orbital basis B2. Both basis are described respectively by two MO coefficient matrix which have to express their respetive basis MOs in a same common basis (e.g. AO or any other MO basis).

Parameters:
  • Psi_A_MOB1 (array) – Wavefunction A (will be a Bra) expressed in the first orbital basis

  • C_MOB1 (array) – First basis’ Molecular orbital coefficient matrix

  • C_MOB2 (array) – Second basis’ Molecular orbital coefficient matrix

  • nbody_basis (array) – List of many-body state

Returns:

Psi_A_MOB2 – Final shape of the multi-configurational wavefunction in the second MO basis B2

Return type:

array

quantnbody.fermionic.tools.scalar_product_different_MO_basis_with_frozen_orbitals(Psi_A_MOB1, Psi_B_MOB2, C_MOB1, C_MOB2, nbody_basis, frozen_indices=None)

Evaluate the non-trivial scalar product of two multi-configurational wavefunction expressed in two different moelcular orbital basis. Each of these wavefunction has a same number of doubly occupied (frozen) orbital.

Parameters:
  • Psi_A_MOB1 (Wavefunction A (will be a Bra) expressed in the first orbital basis) –

  • Psi_B_MOB2 (Wavefunction B (will be a Ket) expressed in the second orbital basis) –

  • C_MOB1 (First basis' Molecular orbital coefficient matrix) –

  • C_MOB2 (Second basis' Molecular orbital coefficient matrix) –

  • nbody_basis (List of many-body state) –

Returns:

scalar_product

Return type:

Amplitude of the scalar product



Reduced density matrices

quantnbody.fermionic.tools.build_1rdm_alpha(WFT, a_dagger_a)

Create a spin-alpha 1 RDM for a given wave function

Parameters:
  • WFT (array) – Wave function for which we want to build the 1-RDM (expressed in the numerical basis)

  • a_dagger_a (array) – Matrix representation of the a_dagger_a operator

Returns:

one_rdm_alpha – spin-alpha 1-RDM

Return type:

array

quantnbody.fermionic.tools.build_1rdm_beta(WFT, a_dagger_a)

Create a spin-beta 1 RDM for a given wave function

Parameters:
  • WFT (array) – Wave function for which we want to build the 1-RDM

  • a_dagger_a (array) – Matrix representation of the a_dagger_a operator

Returns:

one_rdm_beta – Spin-beta 1-RDM

Return type:

array

quantnbody.fermionic.tools.build_1rdm_spin_free(WFT, a_dagger_a)

Create a spin-free 1 RDM for a given wave function

Parameters:
  • WFT (array) – Wave function for which we want to build the 1-RDM

  • a_dagger_a (array) – Matrix representation of the a_dagger_a operator

Returns:

one_rdm – Spin-free 1-RDM

Return type:

array

quantnbody.fermionic.tools.build_2rdm_fh_on_site_repulsion(WFT, a_dagger_a, mask=None)

Create a 2-RDM for a given wave function following the structure of the Fermi Hubbard on-site repulsion operator (u[i,j,k,l] corresponds to a^+_i↑ a_j↑ a^+_k↓ a_l↓)

Parameters:
  • WFT (array) – Wave function for which we want to build the 2-RDM

  • a_dagger_a (array) – Matrix representation of the a_dagger_a operator

  • mask (array, default=None) – 4D array is expected. Function is going to calculate only elements of 2rdm where mask is not 0. For default None the whole 2RDM is calculated. If we expect 2RDM to be very sparse (has only a few non-zero elements) then it is better to provide array that ensures that we won’t calculate elements that are not going to be used in calculation of 2-electron interactions.

Returns:

two_rdm_fh – 2-RDM associated to the on-site-repulsion operator

Return type:

array

quantnbody.fermionic.tools.build_2rdm_fh_dipolar_interactions(WFT, a_dagger_a, mask=None)

Create a spin-free 2 RDM for a given Fermi Hubbard wave function for dipolar interaction operator it corresponds to <psi|(a^+_i↑ a_j↑ + a^+_i↓ a_j↓)(a^+_k↑ a_l↑ + a^+_k↓ a_l↓)|psi>

Parameters:
  • WFT (array) – Wave function for which we want to build the 1-RDM

  • a_dagger_a (array) – Matrix representation of the a_dagger_a operator

  • mask (array) – 4D array is expected. Function is going to calculate only elements of 2rdm where mask is not 0. For default None the whole 2RDM is calculated. If we expect 2RDM to be very sparse (has only a few non-zero elements) then it is better to provide array that ensures that we won’t calculate elements that are not going to be used in calculation of 2-electron interactions.

Returns:

two_rdm_fh – 2-RDM associated to the dipolar interaction operator

Return type:

array

quantnbody.fermionic.tools.build_2rdm_spin_free(WFT, a_dagger_a)

Create a spin-free 2 RDM for a given wave function

Parameters:
  • WFT (array:) – Wave function for which we want to build the spin-free 2-RDM

  • a_dagger_a (array) – Matrix representation of the a_dagger_a operator

Returns:

two_rdm – Spin-free 2-RDM

Return type:

array

quantnbody.fermionic.tools.build_1rdm_and_2rdm_spin_free(WFT, a_dagger_a)

Create both spin-free 1- and 2-RDMs for a given wave function

Parameters:
  • WFT (array) – Wave function for which we want to build the 1-RDM

  • a_dagger_a (array) – Matrix representation of the a_dagger_a operator

Returns:

  • one_rdm (array) – Spin-free 1-RDM

  • two_rdm (array) – Spin-free 2-RDM

quantnbody.fermionic.tools.build_hybrid_1rdm_alpha_beta(WFT, a_dagger_a)

Create a hybrid alpha-beta 1 RDM for a given wave function (Note : alpha for the lines, and beta for the columns)

Parameters:
  • WFT (array) – Wave function for which we want to build the 1-RDM

  • a_dagger_a (array) – Matrix representation of the a_dagger_a operator

Returns:

one_rdm_alpha_beta – spin-alpha-beta 1-RDM (alpha for the lines, and beta for the columns)

Return type:

array

quantnbody.fermionic.tools.build_transition_1rdm_alpha(WFT_A, WFT_B, a_dagger_a)

Create a spin-alpha transition 1 RDM for a given wave function

Parameters:
  • WFT_A (array) – Left Wave function will be used for the Bra

  • WFT_B (array) – Right Wave function will be used for the Ket

  • a_dagger_a (array) – Matrix representation of the a_dagger_a operator

Returns:

transition_one_rdm_alpha – transition spin-alpha 1-RDM

Return type:

array

quantnbody.fermionic.tools.build_transition_1rdm_beta(WFT_A, WFT_B, a_dagger_a)

Create a spin-beta transition 1 RDM for a given wave function

Parameters:
  • WFT_A (array) – Left Wave function will be used for the Bra

  • WFT_B (array) – Right Wave function will be used for the Ket

  • a_dagger_a (array) – Matrix representation of the a_dagger_a operator

Returns:

transition_one_rdm_beta – transition spin-beta 1-RDM

Return type:

array

quantnbody.fermionic.tools.build_transition_1rdm_spin_free(WFT_A, WFT_B, a_dagger_a)

Create a spin-free transition 1 RDM out of two given wave functions

Parameters:
  • WFT_A (array) – Left Wave function will be used for the Bra

  • WFT_B (array) – Right Wave function will be used for the Ket

  • a_dagger_a (array) – Matrix representation of the a_dagger_a operator

Returns:

transition_one_rdm – spin-free transition 1-RDM

Return type:

array

quantnbody.fermionic.tools.build_transition_2rdm_spin_free(WFT_A, WFT_B, a_dagger_a)

Create a spin-free transition 2 RDM out of two given wave functions

Parameters:
  • WFT_A (array) – Left Wave function will be used for the Bra

  • WFT_B (array) – Right Wave function will be used for the Ket

  • a_dagger_a (array) – Matrix representation of the a_dagger_a operator

Returns:

transition_two_rdm – Spin-free transition 2-RDM

Return type:

array

quantnbody.fermionic.tools.build_full_mo_1rdm_and_2rdm_for_AS(WFT, a_dagger_a, frozen_indices, active_indices, n_mo_total)

Create a full representation of the spin-free 1- and 2-electron reduced density matrices for a system with an active space. The wavefunction provided here describes ONLY the electronic strcuture within the active space.

Parameters:
  • WFT (array) – Reference wavefunction describing the electornic strcure in the active space ONLY.

  • a_dagger_a (array) – Matrix representation of the a_dagger_a operator

  • frozen_indices (array) – List of frozen indices

  • active_indices (array) – List of active indices

  • n_mo_total (int) – Total number of molecular orbitals

Returns:

  • one_rdm (array) – 1-electron reduced density matrix of the wavefunction

  • two_rdm (array) – 2-electron reduced density matrix of the wavefunction



Functions to manipulate fermionic integrals

quantnbody.fermionic.tools.transform_1_2_body_tensors_in_new_basis(h_b1, g_b1, C)

Transform electronic integrals from an initial basis “B1” to a new basis “B2”. The transformation is realized thanks to a passage matrix noted “C” linking both basis like

\[| B2_l \rangle = \sum_p | B1_p \rangle C_{pl}\]

with \(| B2_l \rangle\) and \(| B2_p \rangle\) are vectors of the basis B1 and B2 respectively.

Parameters:
  • h_b1 (array) – 1-electron integral given in basis B1

  • g_b1 (array) – 2-electron integral given in basis B1

  • C (array) – Transfer matrix from the B1 to the B2 basis

Returns:

  • h_b2 (array) – 1-electron integral given in basis B2

  • g_b2 (array) – 2-electron integral given in basis B2

quantnbody.fermionic.tools.fh_get_active_space_integrals(h_MO, U_MO, frozen_indices=None, active_indices=None)

Restricts a Fermi-Hubbard system at a spatial orbital level to an active space. This active space may be defined by a list of active indices and doubly occupied indices. Note that one_body_integrals and two_body_integrals must be defined in an orthonormal basis set (MO like).

Parameters:
  • h_MO (array) – 1 body integrals

  • U_MO (array) – 2 body integrals (coulomb interactions)

  • frozen_indices (array) – A list of spatial orbital indices indicating which orbitals should be considered doubly occupied

  • active_indices (array) – A list of spatial orbital indices indicating which orbitals should be considered active

Returns:

  • core_energy (float) – Adjustment to constant shift in Hamiltonian from integrating out core orbitals

  • h_act (array) – effective one-electron integrals over active space

  • U_MO_active (array) – two-electron integrals over active space (coulomb interactions)

quantnbody.fermionic.tools.fh_get_active_space_integrals_with_V(h_MO, U_MO, V_MO, frozen_indices=None, active_indices=None)

Similar function as before but with an additional dipolar term V when considering a Fermi-Hubbard system. Restricts the system at a spatial orbital level to an active space. This active space may be defined by a list of active indices and doubly occupied indices. Note that one_body_integrals and two_body_integrals must be defined in an orthonormal basis set (MO like).

Parameters:
  • h_MO (array) – 1 body integrals

  • U_MO (array) – 2 body elecronic integrals (coulomb interaction)

  • V_MO (array) – 2 body electronic integrals (dipolar interaction)

  • frozen_indices (array) – A list of spatial orbital indices indicating which orbitals should be considered doubly occupied

  • active_indices (array) – A list of spatial orbital indices indicating which orbitals should be considered active

Returns:

  • core_energy (float) – Adjustment to constant shift in Hamiltonian from integrating out core orbitals

  • h_act (array) – effective one-electron integrals over active space

  • U_MO_active (array) – two-electron integrals over active space (coulomb interactions)

  • V_MO_active (array) – two-electron integrals over active space (dipolar interactions)

quantnbody.fermionic.tools.qc_get_active_space_integrals(h_MO, g_MO, frozen_indices=None, active_indices=None)

Restricts an ab initio electronic structure system at a spatial orbital level to an active space. This active space may be defined by a list of active indices and doubly occupied indices. Note that one_body_integrals and two_body_integrals must be defined in an orthonormal basis set (MO like).

Parameters:
  • h_MO (array) – 1 body integrals

  • g_MO (array) – 2 body integrals

  • frozen_indices (array) – A list of spatial orbital indices indicating which orbitals should be considered doubly occupied

  • active_indices (array) – A list of spatial orbital indices indicating which orbitals should be considered active

Returns:

  • core_energy (float) – Adjustment to constant shift in Hamiltonian from integrating out core orbitals

  • h_act (array) – effective one-electron integrals over active space

  • g_MO_active (array) – two-electron integrals over active space



Quantum embedding transformations (Householder)

quantnbody.fermionic.tools.householder_transformation(M)

Householder transformation transforming a squared matrix ” M ” into a block-diagonal matrix ” M_BD ” such that

\[M_BD = P M P\]

where ” P ” represents the Householder transformation built from the vector “v” such that

\[P = I - 2 v . v^T\]

Note

This returns a 2x2 block on left top corner

Parameters:

M (array) – Squared matrix to be transformed

Returns:

  • P (array) – Transformation matrix

  • v (array) – Householder vector

quantnbody.fermionic.tools.block_householder_transformation(M, size)

Block Householder transformation transforming a square matrix ” M ” into a block-diagonal matrix ” M_BD ” such that

\[M_{BD} = H(V) M H(V)\]

where ” H(V) ” represents the Householder transformation built from the matrix “V” such that

\[H(V) = I - 2 V(V^{T} V)^{-1}V^{T}\]

Note

Depending on the size of the block needed (unchanged by the transformation), this returns a (2 x size)*(2 x size) block on left top corner

See also

Article
  1. Rotella, I. Zambettakis, Block Householder Transformation for Parallel QR Factorization, Applied Mathematics Letter 12 (1999) 29-34

Parameters:
  • M (array) – Square matrix to be transformed

  • size (array) – size of the block ( must be > 1)

Returns:

  • P (array) – Transformation matrix

  • moore_penrose_inv (array) – Moore Penrose inverse of Householder matrix



Psi4 calculation helper

quantnbody.fermionic.tools.get_info_from_psi4(string_geometry, basisset, molecular_charge=0, TELL_ME=False)

Simple Psi4 interface to obtain relevant information for a quantum chemistry problem. Function to realise an Hartree-Fock calculation on a given molecule and to return all the associated information for further correlated wavefunction calculation for QuantNBody.

Parameters:
  • string_geometry (str) – XYZ file for the calculation

  • basisset (str) – name of the basis we want to use

  • molecular_charge (int) – value of the charge we want to attribute to the molecule (default is 0)

  • TELL_ME (Boolean) – In case we want the output (default is False)

Returns:

  • overlap_AO (array) – Overlap matrix in the AO basis

  • h_AO (array) – one-body integrals in the AO basis

  • g_AO (array) – two-body integrals in the AO basis

  • C_RHF (array) – HF Molecular orbital coefficient matrix

  • E_HF (float) – HF energy

  • E_rep_nuc (float) – Energy of the nuclei repulsion

quantnbody.fermionic.tools.generate_h_chain_geometry(N_atoms, dist_HH)

A function to build a Hydrogen chain geometry (on the x-axis)

Parameters:
  • N_atoms (int) – Total number of Hydrogen atoms

  • dist_HH (float) – Distance between two consecutive atom of the ring

Returns:

h_chain_geometry – XYZ string encoding the geometry of the ring chain

Return type:

str

quantnbody.fermionic.tools.generate_h_ring_geometry(N_atoms, radius)

A function to build a Hydrogen ring geometry (in the x-y plane)

Parameters:
  • N_atoms (int) – Total number of Hydrogen atoms

  • radius (float) – Radius of the ring

Returns:

h_ring_geometry – XYZ string encoding the geometry of the hydrogen ring

Return type:

str

quantnbody.fermionic.tools.generate_h4_geometry(radius, angle)

A function to build a Hydrogen rectangle geometry (in the x-y plane)

Parameters:
  • angle (float) – angle between the two right (and left) couple of atoms

  • radius (float) – Radius of the ring

Returns:

h_ring_geometry – XYZ string encoding the geometry of the hydrogen ring

Return type:

str



Orbital optimization

Note

The following functions have been developed for a specific application to the ab initio electronic structure problem (i.e. quantum chemistry). Their use for the Fermi-Hubbard model may not be appropriate!

quantnbody.fermionic.tools.transform_vec_to_skewmatrix(Vec_k, n_mo)

Create the anti-symmetric K matrix necessary for the orbital optimization based on a vector k encoding the kappa (i.e. orbital rotation parameters)

Parameters:
  • Vec_k (array) – vector encoding the orbital rotation parameters

  • n_mo (int) – number of orbital

Returns:

Skew_Matrix_K – Anti-symmetric K matrix for the orbital optimization

Return type:

array

quantnbody.fermionic.tools.transform_vec_to_skewmatrix_with_active_space(Vec_k, n_mo, frozen_indices, active_indices, virtual_indices)

Build from a vector containing the rotation parameters the skew-matrix (Anti-Symmetric) generator matrix K for the orbital rotations genetor exp(K).

Parameters:
  • Vec_k (array) – vector containing the kappa amplitude

  • n_mo (int) – number of orbital

  • frozen_indices (array) – list of frozen indices

  • active_indices (array) – list of active indices

  • virtual_indices (array) – list of virtual indices

Returns:

Skew_Matrix_K – Final matrix K to be exponentiated

Return type:

array

quantnbody.fermionic.tools.prepare_vector_k_orbital_rotation_with_active_space(n_mo, frozen_indices, active_indices, virtual_indices)

Prepare the initial vector of kappa parameters (size and amplitude) for orbital optimization. The initialization is realized with zeros.

Parameters:
  • n_mo (int) – Number of orbital

  • frozen_indices (array) – list of frozen indices

  • active_indices (array) – list of active indices

  • virtual_indices (array) – list of virtual indices

Returns:

Vec_k – final vector prepared with zeros

Return type:

array

quantnbody.fermionic.tools.energy_cost_function_orbital_optimization(Vec_k, one_rdm, two_rdm, h, g, E_rep_nuc, frozen_indices, active_indices, virtual_indices)

Energy cost function for a brute force orbital optimization with scipy (based on spin-free RDMs and ab initio problem)

Parameters:
  • Vec_k (array) – vector containing all the orbital rotation parameters

  • one_rdm (array) – 1-electron reduced density matrix

  • two_rdm (array) – 2-electron reduced density matrix

  • h (array) – 1-electron integral to be transformed by orbital rotation

  • g (array) – 2-electron integral to be transformed by orbital rotation

  • E_rep_nuc (float) – Energy of repulsion between the nuclei

  • frozen_indices (array) – list of frozen indices

  • active_indices (array) – list of active indices

  • virtual_indices (array) – list of virtual indices

Returns:

E_new – Final energy after playing with the orbital rotation parameters

Return type:

float

quantnbody.fermionic.tools.brute_force_orbital_optimization(one_rdm, two_rdm, h, g, E_rep_nuc, C_ref, frozen_indices, active_indices, virtual_indices, max_iteration=1000, method_name='BFGS', grad_tolerance=1e-06, show_me=False, SAD_guess=False)

Method implementing a brute force orbtial optimization using scipy optimizer (based on spin-free RDMs and ab initio problem)

Parameters:
  • one_rdm (array) – 1-electron reduced density matrix

  • two_rdm (array) – 2-electron reduced density matrix

  • h (array) – 1-electron integral to be transformed

  • g (array) – 2-electron integral to be transformed

  • E_rep_nuc (float) – Energy of repulsion between the nuclei

  • C_ref (array) – Inital coefficient matrix for the molecular orbital (to be rotated)

  • frozen_indices (array) – List of frozen indices

  • active_indices (array) – List of active indices

  • virtual_indices (array) – List of virtual indices

  • max_iteration (int) – Maximum number of iteration for the optimization. The default is 1000.

  • method_name (str) – Method name for the orbital optimization. (The default is ‘BFGS’)

  • grad_tolerance (float) – Gradient threshold for the convergence of the optmization. The default is 1e-6.

  • show_me (boolean) – To show the evolution of the optimizaiton process. The default is False.

  • SAD_guess (boolean) – Guess orbital (important for HF orbital optimization) implementing a ” Superposition of Atomic Density”(SAD guess). (The default is False.)

Returns:

  • C_OO (array) – Orbital-optimized molecular orbital coefficient matrix

  • E_new (float) – Final energy after orbital optimizaiton

  • h_OO (array) – Orbital-optimized 1-electron integrals

  • g_OO (array) – Orbital-optimized 2-electron integrals

quantnbody.fermionic.tools.sa_build_mo_hessian_and_gradient(n_mo_OPTIMIZED, active_indices, frozen_indices, virtual_indices, h_MO, g_MO, F_SA, one_rdm_SA, two_rdm_SA)

Create the molecular orbital gradient and hessian necessary for orbital optimization with Newton-Raphson methods

Parameters:
  • n_mo_OPTIMIZED (int) – number of molecular orbital to be optimized

  • frozen_indices (array) – List of frozen indices

  • active_indices (array) – List of active indices

  • virtual_indices (array) – List of virtual indices

  • h_MO (array) – 1-electron integrals

  • g_MO (array) – 2-electron integrals

  • F_SA (array) – State-averaged generalized Fock matrix

  • one_rdm_SA (array) – State-averaged 1-electron reduced density matrix

  • two_rdm_SA (array) – State-averaged 2-electron reduced density matrix

Returns:

  • gradient_SA (array) – state-averaged molecular orbital gradient

  • hessian_SA (array) – state-averaged molecular orbital Hessian

quantnbody.fermionic.tools.build_mo_gradient(n_mo_OPTIMIZED, active_indices, frozen_indices, virtual_indices, h_MO, g_MO, one_rdm, two_rdm)

Create a molecular orbital gradient for an active space problem.

Parameters:
  • n_mo_OPTIMIZED (int) – number of molecular orbital to be optimized

  • frozen_indices (array) – List of frozen indices

  • active_indices (array) – List of active indices

  • virtual_indices (array) – List of virtual indices

  • h_MO (array) – 1-electron integrals

  • g_MO (array) – 2-electron integrals

  • one_rdm (array) – 1-electron reduced density matrix

  • two_rdm (array) – 2-electron reduced density matrix

Returns:

gradient – molecular orbital gradient

Return type:

array

quantnbody.fermionic.tools.orbital_optimisation_newtonraphson(one_rdm_SA, two_rdm_SA, active_indices, frozen_indices, virtual_indices, C_transf, E_rep_nuc, h_AO, g_AO, n_mo_optimized, OPT_OO_MAX_ITER=100, Grad_threshold=1e-06, TELL_ME=True)

Orbital optimization with a Newton-Raphson method for an active space problem.

Parameters:
  • one_rdm_SA (array) – State-averaged 1-electron reduced density matrix

  • two_rdm_SA (array) – State-averaged 2-electron reduced density matrix

  • frozen_indices (array) – List of frozen indices

  • active_indices (array) – List of active indices

  • virtual_indices (array) – List of virtual indices

  • C_transf (array) – Initial MO coeff matrix

  • E_rep_nuc (array) – Energy of the nuclei repulsion

  • h_AO (array) – 1-electron integrals in the AO basis

  • g_AO (array) – 2-electron integrals in the AO basis

  • n_mo_optimized (int) – Number of molecular orbitaled to be optimized

  • OPT_OO_MAX_ITER (int) – Maximum number of Newton-Raphson iterations (i.e. steps). The default is 100.

  • Grad_threshold (float) – Thershold of the gradient to define the optimization convergence. The default is 1e-6.

  • TELL_ME (boolean) –

    To show or not the evolution of the optimization process.

    The default is True.

Returns:

  • C_transf_best_OO (array) – Orbital optimized orbital coefficient matrix

  • E_best_OO (float) – Orbital optimized energy

  • h_best (array) – Orbital optimized 1-electron orbital integral

  • g_best (array) – Orbital optimized 2-electro integral

quantnbody.fermionic.tools.orbital_optimisation_newtonraphson_no_active_space(one_rdm_SA, two_rdm_SA, C_transf, E_rep_nuc, h_AO, g_AO, n_mo_optimized, OPT_OO_MAX_ITER, Grad_threshold, TELL_ME=True)

Similar function as before but for the specific case of full active space !

Parameters:
  • one_rdm_SA (array) – State-averaged 1-electron reduced density matrix

  • two_rdm_SA (array) – State-averaged 2-electron reduced density matrix

  • C_transf (array) – Initial MO coeff matrix

  • E_rep_nuc (float) – Energy of the nucleic repulsion

  • h_AO (array) – 1-electron integrals in the AO basis

  • g_AO (array) – 2-electron integrals in the AO basis

  • n_mo_optimized (int) – Number of molecular orbitaled to be optimized

  • OPT_OO_MAX_ITER (int) – Maximum number of Newton-Raphson iterations (i.e. steps). The default is 100.

  • Grad_threshold (float) – Thershold of the gradient to define the optimization convergence. The default is 1e-6.

  • TELL_ME (boolean) – To show or not the evolution of the optimization process. The default is True.

Returns:

  • C_transf_best_OO (array) – Orbital optimized orbital coefficient matrix

  • E_best_OO (array) – Orbital optimized energy

  • h_best (array) – Orbital optimized 1-electron orbital integral

  • g_best (array) – Orbital optimized 2-electro integral

quantnbody.fermionic.tools.build_generalized_fock_matrix(Num_MO, h_MO, g_MO, one_rdm, two_rdm)

Create the generalized fock matrix with no assumption of active space (i.e. full treatment with no simplifcation in the building)

Parameters:
  • Num_MO (int) – Number of molecular orbital

  • h_MO (array) – 1-electron integrals

  • g_MO (array) – 2-electron integrals

  • one_rdm (array) – 1-electron reduced density matrix

  • two_rdm (array) – 2-electron reduced density matrix

Returns:

F – Generalized Fock matrix

Return type:

array

quantnbody.fermionic.tools.build_generalized_fock_matrix_active_space_adapted(Num_MO, h_MO, g_MO, one_rdm, two_rdm, active_indices, frozen_indices)

Create a generalized fock matrix for a system with an active space. It makes it possible to use lots of simplification in this specific case.

Parameters:
  • Num_MO (array) – Number of molecular orbital

  • h_MO (array) – 1-electron integrals

  • g_MO (array) – 2-electron integrals

  • one_rdm (array) – 1-electron redcued density matrix

  • two_rdm (array) – 2-electron redcued density matrix

  • active_indices (array) – List of active space indices

  • frozen_indices (array) – List of frozen space indices

Returns:

F – Generalized fock matrix

Return type:

array






Bosonic systems

In this subsection, we list a series of functions useful for bosonic systems.

Basic functions for the creation of many-boson systems

quantnbody.bosonic.tools.build_nbody_basis(n_mode, n_boson)

Create a many-body basis formed by a list of fock-state with a conserved total number of bosons

Parameters:
  • n_mode (int) – Number of modes in total

  • N_boson (int) – Number of bosons in total

Returns:

nbody_basis – List of many-body states (occupation number states)

Return type:

array

quantnbody.bosonic.tools.build_operator_a_dagger_a(nbodybasis, silent=True)

Create a matrix representation of the a_dagger_a operator in the many-body basis

Parameters:
  • nbody_basis (array) – List of many-body states (occupation number states) (occupation number states)

  • silent (Boolean) – If it is True, function doesn’t print anything when it generates a_dagger_a

Returns:

a_dagger_a – Matrix representation of the a_dagger_a operator in the many-body basis

Return type:

array



Many-body Hamiltonians and excitations operators

quantnbody.bosonic.tools.build_hamiltonian_bose_hubbard(h_, U_, nbodybasis, a_dagger_a)

Create a matrix representation of the Fermi-Hubbard Hamiltonian in any extended many-body basis.

Parameters:
  • h (array) – One-body integrals

  • U (array) – Two-body integrals

  • nbody_basis (array) – List of many-body states (occupation number states)

  • a_dagger_a (array) – Matrix representation of the a_dagger_a operator

Returns:

H_bose_hubbard – Matrix representation of the Bose-Hubbard Hamiltonian in the many-body basis

Return type:

array



Creating/manipulating/visualizing many-body wavefunctions

quantnbody.bosonic.tools.my_state(fockstate, nbodybasis)

Translate a fockstate (occupation number list) into a many-body state referenced into a given many-body basis.

Parameters:
  • fock_state (array) – list of occupation number in each mode

  • nbodybasis (array) – List of many-body states (occupation number states)

Returns:

state – The fockstate referenced in the many-body basis

Return type:

array

quantnbody.bosonic.tools.visualize_wft(WFT, nbodybasis, cutoff=0.005)

Print the decomposition of a given input wave function in a many-body basis.

Parameters:
  • WFT (array) – Reference wave function

  • nbody_basis (array) – List of many-body states (occupation number states)

  • cutoff (array) – Cut off for the amplitudes retained (default is 0.005)

Return type:

Terminal printing of the wave function



Reduced density matrices

quantnbody.bosonic.tools.build_1rdm(WFT, a_dagger_a)

Create a 1 RDM for a given wave function associated to a Bose-Hubbard system

Parameters:
  • WFT (array) – Wave function for which we want to build the 1-RDM

  • a_dagger_a (array) – Matrix representation of the a_dagger_a operator

Returns:

one_rdm – 1-RDM (Bose-Hubbard system)

Return type:

array

quantnbody.bosonic.tools.build_2rdm(WFT, a_dagger_a)

Create a 2 RDM for a given wave function associated to a Bose-Hubbard system

Parameters:
  • WFT (array) – Wave function for which we want to build the 1-RDM

  • a_dagger_a (array) – Matrix representation of the a_dagger_a operator

Returns:

two_rdm – 2-RDM (Bose-Hubbard system)

Return type:

array



Functions to manipulate bosonic integrals

quantnbody.bosonic.tools.transform_1_2_body_tensors_in_new_basis(h_b1, g_b1, C)

Transform electronic integrals from an initial basis “B1” to a new basis “B2”. The transformation is realized thanks to a passage matrix noted “C” linking both basis like

\[| B2_l \rangle = \sum_p | B1_p \rangle C_{pl}\]

with \(| B2_l \rangle\) and \(| B2_p \rangle\) are vectors of the basis B1 and B2 respectively.

Parameters:
  • h_b1 (array) – 1-boson integrals given in basis B1

  • g_b1 (array) – 2-boson integrals given in basis B1

  • C (array) – Transfer matrix

Returns:

  • h_b2 (array) – 1-boson integrals given in basis B2

  • g_b2 (array) – 2-boson integrals given in basis B2






Fermionic-Bosonic hybrid systems

In this subsection, we list a series of functions useful for fermionic-bosonic hybrid systems.

Basic functions for the creation of many-fermion/boson hybrid systems

quantnbody.hybrid_fermionic_bosonic.tools.build_nbody_basis(n_mode, list_N_boson, n_mo, n_electron, S_z_cleaning=False)

Create a many-body basis formed by a list of fock-state with a conserved total number of bosons

Parameters:
  • n_mode (int) – Number of modes in total

  • N_boson (int) – Number of bosons in total

Returns:

nbody_basis – List of many-body states (occupation number states)

Return type:

array

quantnbody.hybrid_fermionic_bosonic.tools.build_boson_anihilation_operator_b(nbodybasis, n_mode, silent=True)

Create a matrix representation of the a_dagger_a operator in the many-body basis

Parameters:
  • nbody_basis (array) – List of many-body states (occupation number states) (occupation number states)

  • silent (Boolean) – If it is True, function doesn’t print anything when it generates a_dagger_a

Returns:

a_dagger_a – Matrix representation of the a_dagger_a operator in the many-body basis

Return type:

array

quantnbody.hybrid_fermionic_bosonic.tools.build_fermion_operator_a_dagger_a(nbody_basis, n_mode, silent=True)

Create a matrix representation of the a_dagger_a operator in the many-body basis

Parameters:
  • nbody_basis (array) – List of many-body states (occupation number states)

  • silent (bool, default=True) – If it is True, function doesn’t print anything when it generates a_dagger_a

Returns:

a_dagger_a – Matrix representation of the a_dagger_a operators

Return type:

array

Examples

>>> nbody_basis = nbody_basis(2, 2)
>>> a_dagger_a = build_operator_a_dagger_a(nbody_basis, True)
>>> a_dagger_a[0,0] # Get access to the operator counting the electron in the first spinorbital
quantnbody.hybrid_fermionic_bosonic.tools.build_E_and_e_operators(a_dagger_a, n_mo)

Build the spin-free “E” and “e” excitation many-body operators for quantum chemistry

Parameters:
  • a_dagger_a (array) – Matrix representation of the a_dagger_a operator

  • n_mo (int) – Number of molecular orbitals considered

Returns:

  • E_ (array) – Spin-free “E” many-body operators

  • e_ (array) – Spin-free “e” many-body operators

Examples

>>> nbody_basis = qnb.build_nbody_basis(2, 2)
>>> a_dagger_a = qnb.build_operator_a_dagger_a(nbody_basis)
>>> build_E_and_e_operators(a_dagger_a, 2)


Many-body Hamiltonians and excitations operators

quantnbody.hybrid_fermionic_bosonic.tools.build_hamiltonian_hubbard_holstein(h_fermion, U_fermion, a_dagger_a, h_boson, b, Coupling_fermion_boson, nbody_basis, S_2=None, S_2_target=None, penalty=100, v_term=None, cut_off_integral=1e-08)

Create a matrix representation of the Fermi-Hubbard Hamiltonian in the many-body basis.

Parameters:
  • h (array) – One-body integrals

  • U (array) – Two-body integrals

  • nbody_basis (array) – List of many-body states (occupation number states)

  • a_dagger_a (array) – Matrix representation of the a_dagger_a operator

  • S_2 (array, default=None)) – Matrix representation of the S_2 operator (default is None)

  • S_2_target (float, default=None) – Value of the S_2 mean value we want to target (default is None)

  • penalty (float, default=100) – Value of the penalty term to penalize the states that do not respect the spin symmetry (default is 100).

  • v_term (array, default=None) – dipolar interactions.

Returns:

H_fermi_hubbard – Matrix representation of the Fermi-Hubbard Hamiltonian in the many-body basis

Return type:

array

quantnbody.hybrid_fermionic_bosonic.tools.build_hamiltonian_hubbard_QED(h_fermion, U_fermion, a_dagger_a, omega_cav, lambda_coupling, dipole_integrals, b, nbody_basis, S_2=None, S_2_target=None, penalty=100, v_term=None, cut_off_integral=1e-08)

Create a matrix representation of the Fermi-Hubbard Hamiltonian in the many-body basis.

Parameters:
  • h (array) – One-body integrals

  • U (array) – Two-body integrals

  • nbody_basis (array) – List of many-body states (occupation number states)

  • a_dagger_a (array) – Matrix representation of the a_dagger_a operator

  • S_2 (array, default=None)) – Matrix representation of the S_2 operator (default is None)

  • S_2_target (float, default=None) – Value of the S_2 mean value we want to target (default is None)

  • penalty (float, default=100) – Value of the penalty term to penalize the states that do not respect the spin symmetry (default is 100).

  • v_term (array, default=None) – dipolar interactions.

Returns:

H_fermi_hubbard – Matrix representation of the Fermi-Hubbard Hamiltonian in the many-body basis

Return type:

array



Spin operators

quantnbody.hybrid_fermionic_bosonic.tools.build_s2_sz_splus_operator(a_dagger_a)

Create a matrix representation of the spin operators s_2, s_z and s_plus in the many-body basis.

Parameters:

a_dagger_a (array) – matrix representation of the a_dagger_a operator in the many-body basis.

Returns:

  • s_2 (array) – matrix representation of the s_2 operator in the many-body basis.

  • s_plus (array) – matrix representation of the s_plus operator in the many-body basis.

  • s_z (array) – matrix representation of the s_z operator in the many-body basis.



Creating/manipulating/visualizing many-body wavefunctions

quantnbody.hybrid_fermionic_bosonic.tools.my_state(many_body_state, nbody_basis)

Translate a many_body_state (occupation number list) into a many-body state referenced into a given Many-body basis.

Parameters:
  • many_body_state (array) – occupation number list

  • nbody_basis (array) – List of many-body states (occupation number states)

Returns:

state – The many body state translated into the “kappa” many-body basis

Return type:

array

quantnbody.hybrid_fermionic_bosonic.tools.visualize_wft(WFT, nbody_basis, n_mode, cutoff=0.005, atomic_orbitals=False, compact=False)

Print the decomposition of a given input wavefunction in a many-body basis.

Parameters:
  • WFT (array) – Reference wave function

  • nbody_basis (array) – List of many-body states (occupation number states)

  • cutoff (array) – Cut off for the amplitudes retained (default is 0.005)

  • atomic_orbitals (Boolean) – If True then instead of 0/1 for spin orbitals we get 0/alpha/beta/2 for atomic orbitals

Return type:

Terminal printing of the wavefunction



Reduced density matrices

quantnbody.hybrid_fermionic_bosonic.tools.build_bosonic_anihilation_rdm(WFT, b)

Create a hybrid alpha-beta 1 RDM for a given wave function (Note : alpha for the lines, and beta for the columns)

Parameters:
  • WFT (array) – Wave function for which we want to build the 1-RDM

  • a_dagger_a (array) – Matrix representation of the a_dagger_a operator

Returns:

one_rdm_alpha_beta – spin-alpha-beta 1-RDM (alpha for the lines, and beta for the columns)

Return type:

array

quantnbody.hybrid_fermionic_bosonic.tools.build_bosonic_1rdm(WFT, b)

Create a hybrid alpha-beta 1 RDM for a given wave function (Note : alpha for the lines, and beta for the columns)

Parameters:
  • WFT (array) – Wave function for which we want to build the 1-RDM

  • a_dagger_a (array) – Matrix representation of the a_dagger_a operator

Returns:

one_rdm_alpha_beta – spin-alpha-beta 1-RDM (alpha for the lines, and beta for the columns)

Return type:

array

quantnbody.hybrid_fermionic_bosonic.tools.build_fermionic_1rdm_alpha(WFT, a_dagger_a)

Create a spin-alpha 1 RDM for a given wave function

Parameters:
  • WFT (array) – Wave function for which we want to build the 1-RDM (expressed in the numerical basis)

  • a_dagger_a (array) – Matrix representation of the a_dagger_a operator

Returns:

one_rdm_alpha – spin-alpha 1-RDM

Return type:

array

quantnbody.hybrid_fermionic_bosonic.tools.build_fermionic_1rdm_beta(WFT, a_dagger_a)

Create a spin-beta 1 RDM for a given wave function

Parameters:
  • WFT (array) – Wave function for which we want to build the 1-RDM

  • a_dagger_a (array) – Matrix representation of the a_dagger_a operator

Returns:

one_rdm_beta – Spin-beta 1-RDM

Return type:

array

quantnbody.hybrid_fermionic_bosonic.tools.build_fermionic_1rdm_spin_free(WFT, a_dagger_a)

Create a spin-free 1 RDM for a given wave function

Parameters:
  • WFT (array) – Wave function for which we want to build the 1-RDM

  • a_dagger_a (array) – Matrix representation of the a_dagger_a operator

Returns:

one_rdm – Spin-free 1-RDM

Return type:

array

quantnbody.hybrid_fermionic_bosonic.tools.build_fermionic_2rdm_fh_on_site_repulsion(WFT, a_dagger_a, mask=None)

Create a 2-RDM for a given wave function following the structure of the Fermi Hubbard on-site repulsion operator (u[i,j,k,l] corresponds to a^+_i↑ a_j↑ a^+_k↓ a_l↓)

Parameters:
  • WFT (array) – Wave function for which we want to build the 2-RDM

  • a_dagger_a (array) – Matrix representation of the a_dagger_a operator

  • mask (array, default=None) – 4D array is expected. Function is going to calculate only elements of 2rdm where mask is not 0. For default None the whole 2RDM is calculated. If we expect 2RDM to be very sparse (has only a few non-zero elements) then it is better to provide array that ensures that we won’t calculate elements that are not going to be used in calculation of 2-electron interactions.

Returns:

two_rdm_fh – 2-RDM associated to the on-site-repulsion operator

Return type:

array

quantnbody.hybrid_fermionic_bosonic.tools.build_fermionic_2rdm_fh_dipolar_interactions(WFT, a_dagger_a, mask=None)

Create a spin-free 2 RDM for a given Fermi Hubbard wave function for dipolar interaction operator it corresponds to <psi|(a^+_i↑ a_j↑ + a^+_i↓ a_j↓)(a^+_k↑ a_l↑ + a^+_k↓ a_l↓)|psi>

Parameters:
  • WFT (array) – Wave function for which we want to build the 1-RDM

  • a_dagger_a (array) – Matrix representation of the a_dagger_a operator

  • mask (array) – 4D array is expected. Function is going to calculate only elements of 2rdm where mask is not 0. For default None the whole 2RDM is calculated. If we expect 2RDM to be very sparse (has only a few non-zero elements) then it is better to provide array that ensures that we won’t calculate elements that are not going to be used in calculation of 2-electron interactions.

Returns:

two_rdm_fh – 2-RDM associated to the dipolar interaction operator

Return type:

array

quantnbody.hybrid_fermionic_bosonic.tools.build_fermionic_2rdm_spin_free(WFT, a_dagger_a)

Create a spin-free 2 RDM for a given wave function

Parameters:
  • WFT (array:) – Wave function for which we want to build the spin-free 2-RDM

  • a_dagger_a (array) – Matrix representation of the a_dagger_a operator

Returns:

two_rdm – Spin-free 2-RDM

Return type:

array

quantnbody.hybrid_fermionic_bosonic.tools.build_fermionic_1rdm_and_2rdm_spin_free(WFT, a_dagger_a)

Create both spin-free 1- and 2-RDMs for a given wave function

Parameters:
  • WFT (array) – Wave function for which we want to build the 1-RDM

  • a_dagger_a (array) – Matrix representation of the a_dagger_a operator

Returns:

  • one_rdm (array) – Spin-free 1-RDM

  • two_rdm (array) – Spin-free 2-RDM

quantnbody.hybrid_fermionic_bosonic.tools.build_fermionic_hybrid_1rdm_alpha_beta(WFT, a_dagger_a)

Create a hybrid alpha-beta 1 RDM for a given wave function (Note : alpha for the lines, and beta for the columns)

Parameters:
  • WFT (array) – Wave function for which we want to build the 1-RDM

  • a_dagger_a (array) – Matrix representation of the a_dagger_a operator

Returns:

one_rdm_alpha_beta – spin-alpha-beta 1-RDM (alpha for the lines, and beta for the columns)

Return type:

array

quantnbody.hybrid_fermionic_bosonic.tools.build_fermionic_transition_1rdm_alpha(WFT_A, WFT_B, a_dagger_a)

Create a spin-alpha transition 1 RDM for a given wave function

Parameters:
  • WFT_A (array) – Left Wave function will be used for the Bra

  • WFT_B (array) – Right Wave function will be used for the Ket

  • a_dagger_a (array) – Matrix representation of the a_dagger_a operator

Returns:

transition_one_rdm_alpha – transition spin-alpha 1-RDM

Return type:

array

quantnbody.hybrid_fermionic_bosonic.tools.build_fermionic_transition_1rdm_beta(WFT_A, WFT_B, a_dagger_a)

Create a spin-beta transition 1 RDM for a given wave function

Parameters:
  • WFT_A (array) – Left Wave function will be used for the Bra

  • WFT_B (array) – Right Wave function will be used for the Ket

  • a_dagger_a (array) – Matrix representation of the a_dagger_a operator

Returns:

transition_one_rdm_beta – transition spin-beta 1-RDM

Return type:

array

quantnbody.hybrid_fermionic_bosonic.tools.build_fermionic_transition_1rdm_spin_free(WFT_A, WFT_B, a_dagger_a)

Create a spin-free transition 1 RDM out of two given wave functions

Parameters:
  • WFT_A (array) – Left Wave function will be used for the Bra

  • WFT_B (array) – Right Wave function will be used for the Ket

  • a_dagger_a (array) – Matrix representation of the a_dagger_a operator

Returns:

transition_one_rdm – spin-free transition 1-RDM

Return type:

array

quantnbody.hybrid_fermionic_bosonic.tools.build_fermionic_transition_2rdm_spin_free(WFT_A, WFT_B, a_dagger_a)

Create a spin-free transition 2 RDM out of two given wave functions

Parameters:
  • WFT_A (array) – Left Wave function will be used for the Bra

  • WFT_B (array) – Right Wave function will be used for the Ket

  • a_dagger_a (array) – Matrix representation of the a_dagger_a operator

Returns:

transition_two_rdm – Spin-free transition 2-RDM

Return type:

array



Functions to manipulate fermionic-bosonic hybrid integrals

quantnbody.hybrid_fermionic_bosonic.tools.transform_1_2_body_tensors_in_new_basis(h_b1, g_b1, C)

Transform electronic integrals from an initial basis “B1” to a new basis “B2”. The transformation is realized thanks to a passage matrix noted “C” linking both basis like

\[| B2_l \rangle = \sum_p | B1_p \rangle C_{pl}\]

with \(| B2_l \rangle\) and \(| B2_p \rangle\) are vectors of the basis B1 and B2 respectively.

Parameters:
  • h_b1 (array) – 1-electron integral given in basis B1

  • g_b1 (array) – 2-electron integral given in basis B1

  • C (array) – Transfer matrix from the B1 to the B2 basis

Returns:

  • h_b2 (array) – 1-electron integral given in basis B2

  • g_b2 (array) – 2-electron integral given in basis B2