User documentation for the HQS Spin Mapper

This is the user documentation for the HQS Spin Mapper package.

The intended purpose of HQS Spin Mapper is the investigation of first-principles Hamiltonians of real input materials for orbitals of spin-like character. The implemented scope allows for both solids and molecules as input materials. Once orbitals of spin-like characters have been identified, an effective spin-bath model description can be derived for this material. Here the spin-bath model is a system of spins embedded in a material-specific fermionic environment (or bath).

A potential use case is the study of materials with dominant spin physics (i.e. magnetism) on a quantum computer. For this purposes HQS Spin Mapper provides a method to derive an accurate material-specific effective spin-bath model description from first principles, which can be used in a computation on a quantum device.

calculation-scheme

The figure above shows schematically the high-level procedure.

  1. In the first step, the basis orbitals of spin-like character is identified based on their local parity. This local parity is obtained from the 1-RDM and 2-RDM, which are computed using correlated ab-initio methods (e.g. MP2/CCSD/CASSCF/...).

  2. Secondly, mapping of the original Hamiltonian to a spin-bath model is performed by utilizing the generalized Schrieffer-Wolff transformation.

For a detailed description of the full workflow please refer to the Theoretical background chapter.

Glossary

CASSCF Complete Active Space Self-Consistent Field
CCSD Coupled Cluster with Single and Double excitations
MP2 Møller-Plesset (Second Order)
1-RDM One Electron Reduced Density Matrix

Installation of the HQS Spin Mapper

Several packages need to be installed in a given environment as dependencies of the HQS Spin Mapper. If the HQS Spin Mapper is installed inside a conda environment, this preceding installation of dependencies is facilitated with the command:

conda install -y cxx-compiler boost cmake make hdf5 unzip mkl

The HQS Spin Mapper package is available on the HQS pypi server. To install it, use:

pip install --extra-index-url http://pypiserver.office.quantumsimulations.de/ --trusted-host pypiserver.office.quantumsimulations.de hqs_spin_mapper

Building from source code (for development purposes only!)

To build the package from source code inside a conda environment, the dependencies can be installed via:

conda install -y cxx-compiler boost cmake make hdf5 unzip mkl

If you are not installing the package inside a conda environment, check whether the corresponding packages have been installed on your system, including a sufficiently recent C++ compiler, i.e. g++ >= 10.

Building lattice_solver and lattice_functions (not required)

With the external dependencies installed, one needs to build the lattice_solver and lattice_functions packages. The lattice_solver and lattice_functions packages are dependencies required for the Schrieffer-Wolff transformation / Spin-bath model derivation functionality of Spin Mapper.

The lattice_solver contains the Krylov SVD solver needed for the Schrieffer-Wolff transformation functionality. The repository can be obtained from gitlab and installed via:

git clone https://gitlab.office.quantumsimulations.de/hqs-software/solver/lattice_solver
cd lattice_solver/
make pip_install

The lattice_functions contains the core functionality for handling the fermionic operator algebras used in the Schrieffer-Wolff transformation. The lattice_functions repository is available from gitlab via:

git clone git@gitlab.office.quantumsimulations.de:pschmitteckert/lattice_functions.git

Then enter the lattice_functions directory and verify that the CmakeLists.txt file contains the command set(HDF5_PREFER_PARALLEL TRUE) and add it otherwise.

Then perform:

pip install --extra-index-url http://pypiserver.office.quantumsimulations.de/ --trusted-host pypiserver.office.quantumsimulations.de .

Alternatively, there is a lattice_functions binary on the HQS pypi-server:

pip install --extra-index-url http://pypiserver.office.quantumsimulations.de/ --trusted-host pypiserver.office.quantumsimulations.de lattice_functions

Clone the lattice_2_spin repository and perform:

git clone https://gitlab.office.quantumsimulations.de/hqs-software/lattice/hqs_spin_mapper
cd hqs_spin_mapper/
make pip_install

Theory behind HQS Spin Mapper

In section Spin-like orbitals we

  • define the notion of spin-like orbitals,
  • propose the local parity as a metric for the spin-like character of orbitals,
  • and present our parity optimiziation procedure as a way to determine the spin-like orbitals of a system.

The section Hamilton transformation describes

  • the basic concept of the Schrieffer-Wolff transformation,
  • our proposed extended Schrieffer-Wolff transformation method,
  • and Schrieffer-Wolff transformation as a system of linear equations for unique block-offdiagonal operators.

Here, in subsection Full workflow we show how the described methods are combined into our workflow for deriving effective spin-bath model Hamiltonians for materials with relevant low-energy spin physics.

Full workflow

In the following, we outline the steps of the workflow that we use to derive an effective spin-bath model Hamiltonian from a first principles description of a material.

Computation of the required system information

We start with an ab-initio electronic structure calculation of the material to determine its ground state. The electronic structure method needs to be a post-Hartree-Fock or related method - this excludes density functional theory - to capture the effect of correlations in the two-particle reduced density matrix . From the electronic structure calculation we obtain the basis orbitals in which the Hamiltonian of the system is formulated, and the one-electron and two-electron integrals which specify the Hamiltonian description. For the ground state of the calculation we compute the one-particle and two-particle reduced density matrices and .

Determination of spin-like basis orbitals

We utilize the reduced density matrices to assign a local parity to the basis orbitals i. We then perform pairwise rotations of the basis orbitals to determine the basis in which the local parities of the basis orbitals are extremized. If there exist optimized basis orbitals with , where we typically choose , we proceed with the subsequent steps of the workflow. If no spin-like orbitals are found, we terminate the workflow.

Schrieffer-Wolff transformation of the Hamiltonian

We use our Schrieffer-Wolff transformation approach to integrate out the valid terms of the Hamiltonian that modify the electron density in the spin-like orbitals, which leads to renormalized couplings of the electron spins in the spin-like orbitals to the environment. The valid terms are the ones that couple subspaces of the Hilbert space between which there exists a significant energy gap.

Construction of the effective spin-bath Hamiltonian

The transformed Hamiltonian is projected to the particular subspace of the Hilbert space where the electron density of spin-like orbitals is fixed to . Utilizing the identity fermionic operators acting on the spin-like operators are substituted with the corresponding spin operators. The resulting Hamiltonian is the effective spin-bath representation of the material.

Representation on a device (optional)

The effective spin-bath model Hamiltonian is re-expressed in terms of the spin operators that are realized on the specific device.

Spin-like orbitals

In Definition we define the notion of spin-like orbitals and in Local parity we propose the local parity as a metric for the spin-like character of orbitals. In Local parity optimization of the orbital basis, we present our parity optimization procedure as a way to determine the spin-like orbitals of a system.

Definition

We consider an orbital as being spin-like only if the electron density contained in it is strictly equal to one. This requires that the average electron density in the orbital satisfies . It furthermore requires that the fluctuations around this average electron density satisfy . Negligible fluctuations around the average electron density imply that electron density of the orbital does not affect the low-energy dynamics of the system and vice versa. Just an average electron density places no restrictions on the orientation and dynamics of the electron spin in the orbital . When both requirements are simultaneously met by the states in the low-energy Hilbert space, the dynamics of the electron density in the orbital , often referred to as the charge degree of freedom, become superfluous to the description of the dynamics of the system. The electron density in the orbital consequently couples to the remainder of the system exclusively via its spin degree of freedom. It is then sufficient to represent the degrees of freedom of the electron density contained in the orbital as a pure spin degree of freedom and to employ the associated spin operator algebra. The local Hilbert space of a spin degree of freedom is half the size of the local Hilbert space of a fermionic orbital and is furthermore naturally represented on a qubit. We therefore aim to determine each spin-like basis orbital or linear combinations thereof meeting both stated requirements, so that they can be represented as spins.

Local parity

We propose the ground state local parity as a measure for the spin-like character of an orbital . The operator representation of the local parity reads where denotes the electron density in with electron spin quantum number and the electron density with quantum number respectively. The local Hilbert space of the orbital is spanned by the states,

and the action of the local parity parity operator on these states reads For states where the orbital contains a single electron, the local parity operator returns the eigenvalue . For the remaining two basis states, returns the eigenvalue . Any state in the local Hilbert space that contains contributions from non singly occupied basis states hence satisfies with , because the resulting fluctuations in the electron density manifest themselves in strictly positive contributions to the local parity. An alternative and more useful operator representation of the local parity reads and its corresponding expectation value with respect to the many-body state can be expressed as where denotes the one-electron reduced density matrix (1-RDM) and denotes the two-electron reduced density matrix (2-RDM) respectively. If we choose , with a good approximation of the ground state of the system, we can identify orbitals for which , with , as spin-like orbitals of the system. In general, the spin-like orbitals of the system do not coincide with the basis orbitals. We therefore require a method to determine the set of orthonormal linear combinations of basis orbitals, for which the local parities most closely approach .

Local parity optimization of the orbital basis

We propose an iterative procedure to determine the particular orbital basis in which the local parities are extremal. For this we attempt a sequence of unitary pairwise rotations of the orbital fermionic operators given by with the same rotation being performed for the hermitian conjugates of the operators. From the reduced density matrices and , we can compute the local parity of an orbital , which results from the linear combination of orbitals and , as . The local parity is an analytic, -periodic function of the rotation angle . We find extremal points of the function in the domain from and select solutions that satisfy If a solution exists which satisfies and , we accept the rotation attempt and with rotation angle and we reject the rotation attempt otherwise. By repeating the procedure for each pair of basis orbitals and , we arrive at at an orthonormal basis in which the local parities have taken up extremal values. We then identify the orbitals of the resulting basis for which , with an arbitrary small, positive value, as the spin-like orbitals of the system. Basis orbitals with a local parity can be regarded as beneficial for the purpose of separating the system's spin degrees of freedom and their respective environment since they experience exclusively even number particle transfer, such that the spin degree of freedom of electrons occupying the orbitals becomes insignificant.

Hamilton transformation

We discuss the basic concept of the Schrieffer-Wolff transformation in Perturbative similarity transformation. We detail our proposed extended Schrieffer-Wolff transformation method in sections Symmetry specification of block-offdiagonal operators and Schrieffer-Wolff transformation as a system of linear equations for unique block-offdiagonal operators .

Perturbative similarity transformation

In principle, any Hamiltonian can be completely diagonalized by means of a particular unitary transformation . In practice, finding the particular unitary transformation often requires a complete diagonalization of the Hamiltonian to begin with. Here we recap how a perturbative similarity transformation, namely the Schrieffer-Wolff transformation, can be used to determine an approximate transformation operator , or the generator thereof, which does not diagonalize the Hamiltonian fully, but yields a block-diagonal Hamiltonian instead. These blocks consist of the orthonormal states in the Hilbert space that share the a given choice of characteristics, e.g. the local particle quantum number . We will denote the set of terms in the Hamiltonian that are already block-diagonal in the initial basis as . The remaining terms connect different blocks, i.e are block-offdiagonal, and are denoted . The complete Hamiltonian thus reads A unitary similarity transformation of the Hamiltonian is given by where is an anti-hermitian operator. One refers to it as the generator of the Schrieffer-Wolff transformation. The key problem of the Schrieffer-Wolff transformation is finding the generator such that the transformed Hamiltonian becomes entirely block-diagonal. In order to arrive at an equation for one makes use of the Campbell-Baker-Hausdorff formula to expand where for generators satisfying , with a suitable norm, one can approximate the expression as Considering that commutators of pairs of block-diagonal operators or pairs of block-offdiagonal operators respectively generally become block-diagonal, while the commutators of block-diagonal operators with block-offdiagonal operators become block-offdiagonal, one chooses the equation by which one can determine the generator which removes the block-offdiagonal terms of the Hamiltonian. If a solution exists, one can use to simplify the expression for the transformed Hamiltonian where the terms originating from contain the perturbative corrections arising from the consecutive application of two block-offdiagonal operators. A subsequent projection to the subspaces yields the block-diagonal Hamiltonian where denotes the distinct blocks of the Hilbert space.

Symmetry specification of block-offdiagonal operators

The block-offdiagonal part of the Hamiltonian consists of a sum of block-offdiagonal terms. These in turn comprise products of individually block-offdiagonal operators . In the following we detail a method to decompose generic block-offdiagonal operators into distinct components. Each of the components exclusively connects two distinct blocks of the Hilbert space , often associated with distinct quantum numbers of a symmetry of the system. A given block-offdiagonal operator satisfies where denotes an arbitrary scalar and an arbitrary operator. Let be a diagonal operator in the initial basis. It can be identical to the symmetry operator differentiating the blocks of the Hilbert space, but it is not required to be. One can use the spectrum of to expand the operator as where the different couple the target subspace associated with the eigenvalue of to other subspaces of the Hilbert space. If the operator satisfies then both subspaces, initial and final, coupled via are specified by the eigenvalue . This is possible for the fermionic creation and annihilation operators and . The coefficients are solutions to the equation The symmetry-specified block-offdiagonal operators satisfy where the operator denotes the hermitian conjugate of the operator .

Schrieffer-Wolff transformation as a system of linear equations for unique block-offdiagonal operators

Following the procedure outlined in the section Perturbative similarity transformation we separate the Hamiltonian of the system into its block-diagonal and block-offdiagonal contributions as The block-offdiagonal contribution comprises each block-offdiagonal term where denotes sequences of individually block-offdiagonal operators, denotes sequences of individually block-diagonal operators, and denotes the symmetry-specified components of the operator . We introduce a vector spaces and , for which each unique pair of hermitian, or anti-hermitian respectively, symmetry-specified operator sequences in corresponds to a unique orthonormal basis vector where denotes the hermitian vector space and the anti-hermitian vector space. We define the linear map where the action of the linear map on a vector is given by where with since includes additional unique operator sequences generated by . In the vector spaces , we can translate the equation for the generator of the Schrieffer-Wolff transformation to with and . Determining the generator of the Schrieffer-Wolff transformation becomes equivalent to solving the set of linear equations. In general one finds and there is consequently no unique solution to the set of equations. It is intuitive that the terms of approximately bring about transitions between distinct eigenstates of belonging to different blocks of the Hilbert space. This is reflected by where denotes the eigenvalue difference between the two eigenstates of and denotes an arbitrary sequence of individually block-diagonal operators. From the previous equations we can approximate which highlights the necessity for a significant energy gap between the separate subspaces of the Hilbert space coupled by in order for the series expansion of to to be considered a good approximation. We consider terms for which to be the resonant terms of which should be retained in the transformed Hamiltonian . To identify these resonant terms of , we employ a singular value decomposition (SVD) of the linear map and arrive at where comprises the singular values where denotes the number of terms . We define the Moore-Penrose pseudoinverse of that acts exclusively on the gapped, i.e. non-resonant, terms in as where denotes the pseudoinverse of . In the absence of a unique solution to , the closest approximate solution is given by and the resulting transformed Hamiltonian reads where and .

Applications of the HQS Spin Mapper

Outline

Applications of the HQS Spin Mapper software package

The HQS Spin Mapper software package contains a selection of modules which provide two major functionalities. The first functionality is the identification of orbital bases containing spin-like orbitals, i.e. orbitals with an occupancy of strictly a single electron. The second one derives effective spin-bath model Hamiltonians for the determined spin-like orbitals. The remaining modules handle input and output tasks.

1.1 Accepted input formats (hqs_spin_mapper.transformables)

HQS Spin Mapper currently accepts several different input formats for the Hamiltonian descriptions of a system (i.e. crystals and molecules). Some of the input formats store additional information about the system, which is, for example, needed for the determination of spin-like orbital bases or to reduce the computational of the spin-bath model derivation. There is also the possibility for the user to provide their own input format through the use of the supplied protocols.

Currently supported by default are:

  • LatticeBuilder configuration object instances
  • LatticeBuilder configuration data files as *.yml
  • Struqture FermionHamiltonianSystem object instances
  • Data container (Transformable_QuantumChemistry) including the one- and two-particle integrals specifying the Hamiltonian stored as numpy binary *.npy files
  • Data container (Transformable_Matrices) including the single particle picture matrices of the Hamiltonian as numpy array instances

For each default input format, we provide a specific class derived from the Transformable class. The Transformable object serves as the necessary input argument of the essential methods of the HQS Spin Mapper package and are manipulated by these methods. The Transformable classes satisfy the Supports_SW_Transformation protocol. Any object satisfying the Supports_SW_Transformation protocol can be used with the HQS Spin Mapper functions.

LatticeBuilder object instances and data files (Transformable_LatticeBuilder)

Given an instance of a LatticeBuilder object, it is easy to instantiate a Transformable_LatticeBuilder object from, which can then be used as the input for the subsequent functions. To instantiate the Transformable_LatticeBuilder object, use:

from hqs_spin_mapper.transformables import Transformable_LatticeBuilder

system = Transformable_LatticeBuilder(input_builder)

If the LatticeBuilder description of the system is stored in a valid *.yml file, the Transformable_LatticeBuilder object is instantiated in the same way.

from hqs_spin_mapper.transformables import Transformable_LatticeBuilder

system = Transformable_LatticeBuilder(input_lattice_builder_yaml)

Struqture FermionHamiltonianSystem instances (Transformable_Struqture)

A Transformable_Struqture object can be directly instantiated from a struqture_py.fermions.FermionHamiltonianSystem instance.

from hqs_spin_mapper.transformables import Transformable_Struqture

system = Transformable_Struqture(input_struqture)

Hamiltonians as numpy array instances (Transformable_Matrices)

The description of the Hamiltonian of a given system can be provided as a collection of matrices or tensors respectively, in the single particle picture. The matrices and tensors first need to be stored in a data container class called Hamiltonian_Matrices.

from hqs_spin_mapper.spin_mapper_protocols import Hamiltonian_Matrices

hamiltonian_matrices = Hamiltonian_Matrices(H0_uu=H0_uu,
                                            H0_dd=H0_dd,
                                            H0_ud=H0_ud,
                                            HU=HU,
                                            Jz=None,
                                            Jp=None,
                                            Jc=None)

The spin indices of the quadratic fermionic terms H0_uu, H0_dd, H0_ud indicate the spin component of the electrons. If provided as a matrix, HU denotes density-density interaction terms. If HU is provided as a tensor, more complex four index interaction terms can be specified. The matrix Jz specifies interactions, Jp specifies interactions, and Jc specifies interactions.

The quadratic Hamiltonian matrices H0_uu, H0_dd, H0_ud have to follow the convention The matrices H0_uu, H0_dd, H0_ud have to be provided for three different spin direction combinations , i.e. , and .

If provided as a matrix, a HU has to conform to and if provided as a tensor as

Using the Hamiltonian_Matrices instance, one can instantiate a Transformable_Matrices object that satisfies the Supports_SW_Transformation protocol via

from hqs_spin_mapper.transformables import Transformable_Matrices

system = Transformable_Matrices(hamiltonian_matrices)

Electron integrals from electronic structure codes (Transformable_QuantumChemistry)

If the output of a preceding electronic structure calculations contains the one-electron and two-electron integrals specifying the Hamiltonian stored as numpy binary *.npy files, one can construct a Transformable from the corresponding matrices via instantiation of a Transformable_Matrices object as shown in the previous section.

from hqs_spin_mapper.spin_mapper_protocols import Hamiltonian_Matrices
from hqs_spin_mapper.transformables import Transformable_Matrices

H0_uu = np.load('h0_uu.npy')
H0_dd = np.load('h0_dd.npy')
H0_ud = np.load('h0_ud.npy')
HU = np.load('hu.npy')

hamiltonian_matrices = Hamiltonian_Matrices(H0_uu=H0_uu,
                                            H0_dd=H0_dd,
                                            H0_ud=H0_ud,
                                            HU=HU,
                                            Jz=None,
                                            Jp=None,
                                            Jc=None)

system = Transformable_Matrices(hamiltonian_matrices)

If the results from the preceding electronic structure calculations also include the one-electron density matrix (1-RDM) and the two-electron density matrix (2-RDM), one can also instantiate a Transformable_QuantumChemistry object. The Transformable_QuantumChemistry object also satisfies the Supports_Spin_Optimization protocol. This means that the object can be used as the input argument for the spin basis optimization functionality of Spin Mapper.

from hqs_spin_mapper.transformables import Transformable_QuantumChemistry
from hqs_spin_mapper.spin_mapper_protocols import Hamiltonian_Matrices

hamiltonian_matrices = Hamiltonian_Matrices(H0_uu=H0_uu,
                                            H0_dd=H0_dd,
                                            H0_ud=H0_ud,
                                            HU=HU,
                                            Jz=None,
                                            Jp=None,
                                            Jc=None)

rdm1_uu = np.load('rdm1_uu.npy')
rdm1_dd = np.load('rdm1_dd.npy')
rdm1_ud = np.load('rdm1_ud.npy')
rdm2 = np.load('rdm2.npy')

system = Transformable_QuantumChemistry(hamiltonian_matrices,
                                        rdm1=(rdm1_uu, rdm1_dd, rdm1_ud),
                                        rdm2=rdm2,
                                        tolerance=1e-1)

The input reduced density matrices have to adhere to specific conventions. The spin orbital optimization will otherwise yield non-physical results. We expect the following conventions for the reduced density matrices:

  • single 1-RDM:

  • spin-resolved 1-RDMs:

  • single 2-RDM:

Input exclusively for spin-like orbital optimization (SpinFinder)

If the spin-bath model derivation functionality is not required, the user can instantiate a SpinFinder object, which is the valid minimum input for the functions pertaining to the determination of the spin-like orbital basis.

from hqs_spin_mapper.transformables import SpinFinder

rdm1_uu = np.load('rdm1_uu.npy')
rdm1_dd = np.load('rdm1_dd.npy')
rdm1_ud = np.load('rdm1_ud.npy')
rdm2 = np.load('rdm2.npy')

system = SpinFinder(rdm1=(rdm1_uu, rdm1_dd, rdm1_ud),
                    rdm2=rdm2)

Keyworded constructor arguments for Transformable objects

Fields described by the Supports_SW_Transformation protocol:

  • system_size: Optional[int] = None: Number of orbitals in the system. This is automatically derived from the model description. (available for Transformable_Matrices, Transformable_QuantumChemistry)
  • rotation_matrix: Optional[numpy.ndarray] = None: Basis transformation matrix between different orbital bases. The index denotes the orbital in the old basis and the orbital in the new basis. Default is the identity. (available for Transformable_LatticeBuilder, Transformable_Matrices, Transformable_QuantumChemistry)
  • prefactor_cutoff: float = 1e-6: Terms of the Hamiltonian with coupling constant of absolute value smaller than the chosen value are discarded in the derivation of the spin-bath model (Schrieffer-Wolff transformation). (available for Transformable_LatticeBuilder, Transformable_Struqture, Transformable_Matrices, Transformable_QuantumChemistry)
  • site_type: str = "spinful_fermions": Type of particles occupying the orbitals. (available for Transformable_Matrices, Transformable_QuantumChemistry)
  • spin_indices: Optional[Set[int]] = None: User choice of orbitals to be treated as spin-like. The spin-like orbital optimization will add indices to this set. (available for Transformable_LatticeBuilder, Transformable_Struqture, Transformable_Matrices, Transformable_QuantumChemistry)

Fields described by the Supports_Spin_Optimization protocol:

  • tolerance: float = 1e-1: Chosen discrepancy used in for a basis orbital to be considered spin-like, where denotes the local parity. (available for Transformable_QuantumChemistry, SpinFinder)
  • optimization_steps: int = 4: Number of optimization loops to be performed. Parities are typically converged after 4 loops. (available for Transformable_QuantumChemistry, SpinFinder)

Other mutable fields of Transformable objects

Fields described by the Supports_SW_Transformation protocol:

  • generator: Union[ExpressionSpinful, ExpressionSpinful_complex]: Result for the generator of the Schrieffer-Wolff transformation.
  • transformed_hamiltonian: Union[ExpressionSpinful, ExpressionSpinful_complex]: Result for the transformed fermionic Hamiltonian.

Fields described by the Supports_Spin_Optimization protocol:

  • immutable_indices: Set[int]: Indices of orbitals that are exempt from parity optimization.

Custom Transformable objects (hqs_spin_mapper.spin_mapper_protocols)

The user can create their own custom input format by implementing a class that satisfies the protocols Supports_Spin_Optimization and/or Supports_SW_Transformation.

1.2 Functionality: Spin-like orbital basis optimization (hqs_spin_mapper.orbital_optimization)

HQS Spin Mapper provides the functionality to determine the optimal single-particle orbital basis, in which a subset of the basis orbitals exhibits the maximum possible spin-like character. We quantify the spin-like character of basis orbitals on the basis of their local parity . For more details about the use of the local parity as a measure for spin-like character, please consult the Theory section. An orbital in the optimized basis is stored as spin-like if its local parity satisfies , where corresponds to the value stored in the tolerance field of the Transformable.

The spin_orbital_optimization function in the orbital_optimization module determines a basis transformation which would optimize the local parities and stores the corresponding (proposed) basis transformation in the rotation_matrix field of the Transformable. The respective indices of the spin-like orbitals in this optimized basis are stored in the spin_indices field of the Transformable. The spin_orbital_optimization function requires Transformable objects that satisfy the Supports_Spin_Optimization protocol.

from hqs_spin_mapper.orbital_optimization import spin_orbital_optimization

spin_orbital_optimization(system)

Keyworded arguments

  • space_reduction: bool = True: If flag is set, the optimization is restricted to the indices not contained in the immutable_indices field of the Transformable.
  • fast_mode: bool = False: If flag is set, the rotations of the 2-RDM are performed approximately to reduce computation time.
  • target: str = "minimum": Type of extremum to be searched for. Options are: minimum, maximum, extremum.
  • _delta_sufficiently_spin_like: float = 1e-3: Exclude orbitals with initial parities and from the optimization procedure.

The function spin_orbital_optimization rotates the rdm1 and rdm2 to the optimized basis (in order to save memory), but not the matrix descriptions of the Hamiltonians.

The results of the optimized system can subsequently be accessed via:

spin_indices = system.spin_indices
rotation_matrix = system.rotation_matrix

rdm1 = system.rdm1
rdm2 = system.rdm2

2.1 Preparation of input data for the Schrieffer-Wolff transformation (hqs_spin_mapper.preconditioning)

For the derivation of the spin-bath model, the spin_indices: Set[int] field of the Transformable instance first requires a finite amount of indices. If the spin orbital optimization feature was used, spin_indices of the Transformable have been set to feature the obtained spin orbitals automatically. Otherwise spin_indices needs to be set manually by the user as in:

spin_like_orbital_indices: Set[int] = {4, 9}

system.spin_indices = spin_like_orbital_indices

An intuitive choice for spin-like orbitals are the orbitals with particularly strong repulsive on-site interactions .

The necessary preconditioning of the input data is done automatically by calling the preconditioning function on the Transformable once.

from hqs_spin_mapper.preconditioning import preconditioning

preconditioning(system)

The following tasks are performed by the preconditioning function:

  • Generalization of the input interaction terms HU, Jz, Jp, Jc to a four index tensor description.

  • Rotation of the matrix and tensor descriptions to the optimized basis by rotation with the rotation_matrix .

  • Mean-field decoupling (if Supports_Spin_Optimization) / Removal of bath exclusive interaction terms (if apply_pre_diagonalization = True).

  • Diagonalization of the quadratic bath Hamiltonian and rotation of the remaining Hamiltonians to the diagonal basis (if apply_pre_diagonalization = True).

  • Placing the spin indices in the middle of the system at (if apply_cross_geometry = True), with defined as

x0 = (system.system_size // 2) - (len(system.spin_indices) // 2)

Keyworded arguments

  • apply_pre_diagonalization: bool = False: Perform simplification of bath exclusive interactions and diagonalization of the resulting quadratic bath Hamiltonian.
  • apply_cross_geometry: bool = False: Move the spin indices to the center of the system (speeds up subsequent DMRG calculations).

2.2 Functionality: Effective spin-bath model derivation (hqs_spin_mapper.schrieffer_wolff)

With the input data prepared, the effective spin-bath model derivation becomes a simple call of schrieffer_wolff on the Transformable object.

from hqs_spin_mapper.schrieffer_wolff import schrieffer_wolff

schrieffer_wolff(system)

The results of the derivation, namely the transformed Hamiltonian and the generator of the transformation in are stored in the Transformable object instances as:

transformed_hamiltonian = system.transformed_hamiltonian
generator = system.generator

Keyworded arguments

  • _max_length: int = 5: Size limit for the terms included in the generator.
  • _vector_space_cap: int = 1500000: Size limit of the vector space that the generator is determined from.
  • _max_krylov_space_dimension: int = 200: Size restriction of the Krylov space used in the SVD.
  • rdm2: Optional[numpy.ndarray] = None: 2RDM for use in decoupling (currently not activated).

2.3 Extract tensor descriptions for the spin-bath model (hqs_spin_mapper.extract_couplings)

Using the functions contained in the extract_couplings module, one can retrieve the matrix/tensor description of the spin-bath model Hamiltonian.

from hqs_spin_mapper.extract_couplings import extract_quadratic, extract_quartic

(H0_uu, H0_dd, H0_ud) = extract_quadratic(system)
HU = extract_quartic(system)

The matrices and tensor only contain the quadratic/quartic terms of the Hamiltonian. The terms containing more fermionic operators are not extracted!

2.4 Serialize the spin-bath model Hamiltonian with struqture (hqs_spin_mapper.struqture_interface)

The transformed Hamiltonian can be exported to an instance of struqture_py.mixed_systems.MixedHamiltonianSystem for use in other HQS software or for storage in a file.

from hqs_spin_mapper.struqture_interface import get_struqture_description

struqture_description = get_struqture_description(system)

Best practices for the HQS Spin Mapper

The HQS Spin Mapper software package contains a selection of modules which provide two major functionalities that are described in the Applications section in details. On a high level, the first functionality is the identification of orbital bases containing spin-like orbitals, i.e. orbitals with an occupancy of strictly a single electron. The second one derives effective spin-bath model Hamiltonians for the determined spin-like orbitals. The remaining modules handle input and output tasks.

This section describes the best practices for the applications of HQS Spin Mapper.

Avoiding local extrema in the orbital optimization

Depending on the initial basis, it is possible that a single call to spin_orbital_optimization fails to determine the true parity optimized basis. The pairwise optimization algorithm can get stuck in local parity extrema of the parameter manifold. This behavior can be discouraged by using the following procedure:

  • Call the spin_orbital_optimization function on the input data with target="minimum".
  • Add the orbital indices that became spin-like to the immutable_indices of the Transformable instance.
  • Call the spin_orbital_optimization function a second time on the updated input data with either target="extremum" or target="maximum".
  • Call the spin_orbital_optimization function on the input data a final time with target="minimum".

Choosing a sensible value for prefactor_cutoff (Important to avoid memory overflow!)

To limit the system memory required for the Schrieffer-Wolff transformation, we recommend adjusting the value of prefactor_cutoff. The terms of the input Hamiltonian in the optimized basis with an absolute coupling constant smaller than prefactor_cutoff will be dropped from the Hamiltonian prior to the Schrieffer-Wolff transformation step. This is done because a large number of small coupling constant terms slows down the SVD step of the transformation significantly, while not significantly changing the result. In the evaluation of the commutators that yield the transformed Hamiltonian, a larger number of terms can cause memory usage to exceed the system memory and resulting in a fatal error. We recommend inspecting the size of the coupling constants of the input Hamiltonian and choosing a value of prefactor_cutoff larger than the coupling constants that can be considered insignificant. When in doubt, choose a larger value for prefactor_cutoff first and then rerun the calculation with a slightly smaller value of prefactor_cutoff to check whether the result is sensitive to the change in prefactor_cutoff. If the result remains sensitive, we recommend gradually decreasing prefactor_cutoff and observing the memory usage.

We recommend to run the scripts or notebooks using the HQS Spin Mapper in an environment with a set ulimit. The ulimit can be set in the terminal before running the python interpreter via:

ulimit -v {maximum_desired_memory_in_kilobytes}

This way the process gets safely terminated without potentially crashing the system.

Estimation of the required memory

We provide a method for a rough estimate of the required memory to perform the Schrieffer-Wolff transformation at the currently set prefactor_cutoff. The function can be called on the Transformable object using:

from hqs_spin_mapper.preconditioning import (
    estimate_required_memory
)

estimate_required_memory(data)

The function estimate_required_memory prints an estimate of the necessary memory in GB. If the estimated value exceeds the realistically available system memory, we recommended to raise the value of the field prefactor_cutoff and to check the estimated memory requirement again.

Post-processing of the transformed Hamiltonian

The result of the model Hamiltonian derivation is stored as an ExpressionSpinful object. These objects offer a set of methods that can be used for further manipulation of the transformed Hamiltonian. Here we list some useful methods of the ExpressionSpinful class.

  • normalize(eps = 0.0): Orders the operators in the terms of the Hamiltonian in a standardized fashion and removes terms with an absolute prefactor smaller than eps.
  • normal_order: Rewrites operators as creators and annihilators and normal orders them (creators to the left of annihilators).
  • sort_descending: Sorts the terms in the expression by the absolute value of the coupling constants in descending order.
  • sort_ascending: Sorts the terms in the expression by the absolute value of the coupling constants in ascending order.
  • find(fermion): Returns the prefactor of the term containing the input operator.
  • project_on_local_hilbert_subspace(x, condition): Projects the Hamiltonian on a subspace of the Hilbert space where the condition is satisfied for site x. condition is the integer corresponding to a bit string, where the 1-bit indicates the x-local state, the 2-bit indicates , the 4-bit indicates , and the 8-bit indicates . The argument condition=6=4+2 thus corresponds to , namely the singly occupied site x.
  • convert_to_spin_model(positions): Replace fermionic operators acting on the positions with spin operators assuming the identity .

A simple script to convert the transformed fermionic Hamiltonian to a true spin-bath Hamiltonian description is given by:

spin_bath_system = system.transformed_hamiltonian

for n in cast(List[int], system.spin_indices):
    spin_bath_system.project_on_local_hilbert_subspace(n, 6)

spin_bath_system = spin_bath_system.convert_to_spin_model(system.spin_indices)

Examples

Some example python scripts of a spin-bath model derivation for the well-known Single Impurity Anderson Model (SIAM) and the Hubbard Model are provided in the examples folder.

For the real valued SIAM:

cd ./examples
python3 siam_example.py

For the complex valued SIAM:

cd ./examples
python3 complex_siam_example.py

For the real valued Hubbard model:

cd ./examples
python3 hubbard_example.py

For a Kondo lattice chain model

cd ./examples
python3 kondo_lattice_example.py