Module Hamiltonians
This module contains definitions of Hamiltonians, in particular specific physical models of interest. These are organised by means of an interface around the abstract type AbstractHamiltonian, in the spirit of the AbstractArray interface as discussed in the Julia Documentation.
The Hamiltonians can be used for projector quantum Monte Carlo with ProjectorMonteCarloProblem or for exact diagonalization with ExactDiagonalizationProblem, see Exact Diagonalization.
Rimu.Hamiltonians — ModuleThe module Rimu.Hamiltonians defines types and functions for working with Hamiltonians.
Exported concrete Hamiltonian types
Real space Hubbard models
Momentum space Hubbard models
Harmonic oscillator models
Other
- GutzwillerSampling
- GuidingVectorSampling
- ParitySymmetry
- TimeReversalSymmetry
- Stoquastic
- HamiltonianProduct
- ScaledHamiltonian
- HamiltonianSum
- ParticleNumberOperator
- G2RealCorrelator
- G2MomCorrelator
- G2RealSpace
- DensityMatrixDiagonal
- SingleParticleExcitation
- TwoParticleExcitation
- Momentum
- AxialAngularMomentumHO
Interface for working with Hamiltonians
- AbstractHamiltonian: defined in the module- Interfaces
Here is a list of fully implemented model Hamiltonians. There are several variants of the Hubbard model in real and momentum space, as well as some other models.
Real space Hubbard models
Rimu.Hamiltonians.HubbardReal1D — TypeHubbardReal1D(address; u=1.0, t=1.0)Implements a one-dimensional Bose Hubbard chain in real space.
\[\hat{H} = - \sum_i \left(t a_i^† a_{i+1} + t^* a_{i+1}^† a_i \right) + \frac{u}{2}\sum_i n_i (n_i-1)\]
Arguments
- address: the starting address, defines number of particles and sites.
- u: the interaction parameter.
- t: the hopping strength.
See also
Rimu.Hamiltonians.HubbardReal1DEP — TypeHubbardReal1DEP(address; u=1.0, t=1.0, v_ho=1.0)Implements a one-dimensional Bose Hubbard chain in real space with external potential.
\[\hat{H} = - \sum_i \left(t a_i^† a_{i+1} + t^* a_{i+1}^† a_i \right) + \sum_i ϵ_i n_i + \frac{u}{2}\sum_i n_i (n_i-1)\]
Arguments
- address: the starting address, defines number of particles and sites.
- u: the interaction parameter.
- t: the hopping strength.
- v_ho: strength of the external harmonic oscillator potential $ϵ_i = v_{ho} i^2$.
The first index is i=0 and the maximum of the potential occurs in the centre of the lattice.
See also
Rimu.Hamiltonians.HubbardRealSpace — TypeHubbardRealSpace(address; geometry=PeriodicBoundaries(M,), t=1, u=0, w=0, v=0) <:
    AbstractHamiltonianHubbard model in real space. Supports single or multi-component Fock state addresses (with C components) and various (rectangular) lattice geometries in D dimensions.
\[ Ĥ = -∑_{⟨i,j⟩,σ} t_{i,σ} a^†_{i,σ} a_{j,σ} + ½ ∑_{i,σ,σ'} u_{σ,σ'} n_{i,σ} (n_{i,σ'} - δ_{σ,σ'}) + ∑_{⟨i,j⟩,σ,σ'} w_{σ,σ'} n_{i,σ} n_{j,σ'}\]
If v is nonzero then this calculates $\hat{H} + \hat{V}$ by adding the harmonic trapping potential
\[ V̂ = ∑_{i,σ,d} v_{σ,d} x_{d,i}² n_{i,σ}\]
where $x_{d,i}$ is the distance of site $i$ from the centre of the trap along dimension $d$.
Address types
- BoseFS: Single-component Bose-Hubbard model.
- FermiFS: Single-component Fermi-Hubbard model.
- CompositeFS: For multi-component models.
Note that a single component of fermions cannot interact with itself. A warning is produced if addressis incompatible with the interaction parameters u.
Geometries
Implemented CubicGrids for keyword geometry
Default is geometry=PeriodicBoundaries(M,), i.e. a one-dimensional lattice with the number of sites M inferred from the number of modes in address.
Other parameters
- t: the hopping strengths. Must be a matrix of size- C × Dor a vector of length- C. The (- i,- j)-th element of the matrix corresponds to the hopping strength of the- i-th component and- j-th direction.
- u: the on-site interaction parameters. Must be a symmetric matrix of size- C × C.- u[i, j]corresponds to the interaction between the- i-th and- j-th component.- u[i, i]corresponds to the interaction of a component with itself. Note that the self interaction will have no effect on fermionic components.
- w: the nearest neighbour interaction parameters. Must be a symmetric matrix of size- C × C.- w[i, j]corresponds to the interaction between the- i-th and- j-th component.- w[i, i]corresponds to the interaction of a component with itself.
- v: the trap potential strengths. Must be a matrix of size- C × D.- v[i,j]is the strength of the trap for component- iin the- jth dimension.
Rimu.Hamiltonians.ExtendedHubbardReal1D — TypeExtendedHubbardReal1D(address; u=1.0, v=1.0, t=1.0, boundary_condition=:periodic, power=nothing)Implements the extended Hubbard model on a one-dimensional chain in real space. This Hamiltonian can be either real or complex, depending on the choice of boundary_condition.
\[\hat{H} = - \sum_i \left(t a_i^† a_{i+1} + t^* a_{i+1}^† a_i \right) + \frac{u}{2}\sum_i n_i (n_i-1) + v \sum_{i,j>i} f_{j-i} n_i n_j\]
Arguments
- address: the starting address.
- u: on-site interaction parameter
- v: the next-neighbor interaction
- t: the hopping strength
- boundary_conditionThe following values are supported:- :periodic: usual period boundary condition realising a ring geometry.
- :hard_wall: hopping over the boundary is not allowed.
- :twisted: like- :periodicbut hopping over the boundary incurs an additional factor of- -1.
- θ <: Number: like- :periodicand- :twistedbut hopping over the boundary incurs a factor $\exp(iθ)$ for a hop to the right and $\exp(−iθ)$ for a hop to the left. With this choice the Hamiltonian will have a complex- eltypewhereas otherwise the- eltypeis determined by the type of the parameters- t,- u, and- v.
 
- power: the interaction type. The following values are supported:- nothing: nearest neighbour interaction (default), i.e. $f_{j-i} = δ_{j-i,1}$.
- p<:Number: inverse distance interaction, i.e. $f_{j-i} = (j-i)^{-p}$.
 
See also HubbardRealSpace.
Momentum space Hubbard models
Rimu.Hamiltonians.HubbardMom1D — TypeHubbardMom1D(address; u=1.0, t=1.0, dispersion=hubbard_dispersion)Implements a one-dimensional Bose Hubbard chain in momentum space.
\[\hat{H} = \sum_{k} ϵ_k n_k + \frac{u}{M}\sum_{kpqr} a^†_{r} a^†_{q} a_p a_k δ_{r+q,p+k}\]
Arguments
- address: the starting address, defines number of particles and sites.
- u: the interaction parameter.
- t: the hopping strength.
- dispersion: defines $ϵ_k =$- dispersion(t, k)- hubbard_dispersion: $ϵ_k = -2(\Re(t) \cos(k) + \Im(t) \sin(k))$
- continuum_dispersion: $ϵ_k = \Re(t) k^2 - 2 \Im(t) k$
 
See also
Rimu.Hamiltonians.HubbardMom1DEP — TypeHubbardMom1DEP(address; u=1.0, t=1.0, v_ho=1.0, dispersion=hubbard_dispersion)Implements a one-dimensional Bose Hubbard chain in momentum space with harmonic external potential.
\[Ĥ = \sum_{k} ϵ_k n_k + \frac{u}{M}\sum_{kpqr} a^†_{r} a^†_{q} a_p a_k δ_{r+q,p+k} + V̂_\mathrm{ho} ,\]
where
\[\begin{aligned} V̂_\mathrm{ho} & = \frac{1}{M} \sum_{p,q} \mathrm{DFT}[V_{ext}]_{p-q} \, a^†_{p} a_q ,\\ V_\mathrm{ext}(x) &= v_\mathrm{ho} \,x^2 , \end{aligned}\]
is an external harmonic potential in momentum space, $\mathrm{DFT}[…]_k$ is a discrete Fourier transform performed by fft()[k%M + 1], and M == num_modes(address).
Arguments
- address: the starting address, defines number of particles and sites.
- u: the interaction parameter.
- t: the hopping strength.
- dispersion: defines $ϵ_k =$- dispersion(t, k)- hubbard_dispersion: $ϵ_k = -2[\Re(t) \cos(k) + \Im(t) \sin(k)]$
- continuum_dispersion: $ϵ_k = \Re(t) k^2 - 2 \Im(t) k$
 
- v_ho: strength of the external harmonic oscillator potential $v_\mathrm{ho}$.
See also HubbardMom1D, HubbardReal1DEP, Transcorrelated1D, Hamiltonians.
Rimu.Hamiltonians.ExtendedHubbardMom1D — TypeExtendedHubbardMom1D(
    address; 
    u=1.0, t=1.0, v=1.0, dispersion=hubbard_dispersion, boundary_condition = 0.0
)Implements a one-dimensional extended Hubbard chain, also known as the $t - V$ model, in momentum space.
\[\hat{H} = \sum_{k} ϵ_k n_k + \frac{1}{2M} \sum_{kpqr} (u + 2v \cos(q-p)) a^†_{r} a^†_{q} a_p a_k δ_{r+q,p+k}\]
Arguments
- address: the starting address, defines number of particles and sites.
- u: the interaction parameter.
- t: the hopping strength.
- boundary_condition:- θ <: Number: hopping over the boundary incurs a factor $\exp(iθ)$ for a hop to the right and $\exp(−iθ)$ for a hop to the left.
- dispersion: defines $ϵ_k =$- dispersion(t, k + θ)- hubbard_dispersion: $ϵ_k = -2 (\Re(t) \cos(k + θ) + \Im(t) \sin(k + θ))$
- continuum_dispersion: $ϵ_k = \Re(t) (k + θ)^2 - 2 \Im(t) (k + θ)$
 
See also
Harmonic oscillator models
Rimu.Hamiltonians.HOCartesianContactInteractions — TypeHOCartesianContactInteractions(addr; S, η, g = 1.0, interaction_only = false, block_by_level = true)Implements a bosonic harmonic oscillator in Cartesian basis with contact interactions
\[\hat{H} = \sum_{i} \epsilon_\mathbf{i} n_\mathbf{i} + \frac{g}{2}\sum_\mathbf{ijkl} V_\mathbf{ijkl} a^†_\mathbf{i} a^†_\mathbf{j} a_\mathbf{k} a_\mathbf{l}.\]
For a $D$-dimensional harmonic oscillator indices $\mathbf{i}, \mathbf{j}, \ldots$ are $D$-tuples. The energy scale is defined by the first dimension i.e. $\hbar \omega_x$ so that single particle energies are
\[ \frac{\epsilon_\mathbf{i}}{\hbar \omega_x} = (i_x + 1/2) + \eta_y (i_y+1/2) + \ldots.\]
The factors $\eta_y, \ldots$ allow for anisotropic trapping geometries and are assumed to be greater than 1 so that $\omega_x$ is the smallest trapping frequency.
By default the offdiagonal elements due to the interactions are consistent with first-order degenerate perturbation theory
\[ V_{\mathbf{ijkl}} = \delta_{\epsilon_\mathbf{i} + \epsilon_\mathbf{j}} ^{\epsilon_\mathbf{k} + \epsilon_\mathbf{l}} \prod_{d \in x, y,\ldots} \mathcal{I}(i_d,j_d,k_d,l_d),\]
where the $\delta$ function indicates that the total noninteracting energy is conserved meaning all states with the same noninteracting energy are connected by this interaction and the Hamiltonian blocks according to noninteracting energy levels. Setting block_by_level = false will disable this restriction and allow coupling between basis states of any noninteracting energy level, leading to many more offdiagonals and fewer but larger blocks (the blocks are still distinguished by parity of basis states). Alternatively, see HOCartesianEnergyConservedPerDim for a model with the stronger restriction that conserves energy separately per spatial dimension. The integral $\mathcal{I}(a,b,c,d)$ is of four one dimensional harmonic oscillator basis functions, implemented in four_oscillator_integral_general.
Arguments
- addr: the starting address, defines number of particles and total number of modes.
- S: Tuple of the number of levels in each dimension, including the groundstate. The allowed couplings between states is defined by the aspect ratio of- S .- 1. Defaults to a 1D spectrum with number of levels matching modes of- addr. Will be sorted to make the first dimension the largest.
- η: Define a custom aspect ratio for the trapping potential strengths, instead of deriving from- S .- 1. This will only affect the single particle energy scale and not the interactions. The values are always scaled relative to the first dimension, which sets the energy scale of the system, $\hbar\omega_x$.
- g: the (isotropic) bare interaction parameter. The value of- gis assumed to be in trap units.
- interaction_only: if set to- truethen the noninteracting single-particle terms are ignored. Useful if only energy shifts due to interactions are required.
- block_by_level: if set to false will allow the interactions to couple all states without comparing their noninteracting energy.
num_offdiagonals is a bad estimate for this Hamiltonian. Take care when building a matrix or using QMC methods. Use get_all_blocks first then pass option col_hint = block_size to BasisSetRep to safely build the matrix.
Rimu.Hamiltonians.HOCartesianEnergyConservedPerDim — TypeHOCartesianEnergyConservedPerDim(addr; S, η, g = 1.0, interaction_only = false)Implements a bosonic harmonic oscillator in Cartesian basis with contact interactions
\[\hat{H} = \sum_{i} ϵ_i n_i + \frac{g}{2}\sum_{ijkl} V_{ijkl} a^†_i a^†_j a_k a_l,\]
with the additional restriction that the interactions only couple states with the same energy in each dimension separately. See HOCartesianContactInteractions for a model that conserves total energy.
For a $D$-dimensional harmonic oscillator indices $\mathbf{i}, \mathbf{j}, \ldots$ are $D$-tuples. The energy scale is defined by the first dimension i.e. $\hbar \omega_x$ so that single particle energies are
\[ \frac{\epsilon_\mathbf{i}}{\hbar \omega_x} = (i_x + 1/2) + \eta_y (i_y+1/2) + \ldots.\]
The factors $\eta_y, \ldots$ allow for anisotropic trapping geometries and are assumed to be greater than 1 so that $\omega_x$ is the smallest trapping frequency.
Matrix elements $V_{\mathbf{ijkl}}$ are for a contact interaction calculated in this basis using first-order degenerate perturbation theory.
\[ V_{\mathbf{ijkl}} = \prod_{d \in x, y,\ldots} \mathcal{I}(i_d,j_d,k_d,l_d) \delta_{i_d + j_d}^{k_d + l_d},\]
where the $\delta$-function indicates that the noninteracting energy is conserved along each dimension. The integral $\mathcal{I}(a,b,c,d)$ is of four one dimensional harmonic oscillator basis functions, see four_oscillator_integral_general, with the additional restriction that energy is conserved in each dimension.
Arguments
- addr: the starting address, defines number of particles and total number of modes.
- S: Tuple of the number of levels in each dimension, including the groundstate. Defaults to a 1D spectrum with number of levels matching modes of- addr. Will be sorted to make the first dimension the largest.
- η: Define a custom aspect ratio for the trapping potential strengths, instead of deriving from- S .- 1. The values are always scaled relative to the first dimension, which sets the energy scale of the system, $\hbar\omega_x$.
- g: the (isotropic) interparticle interaction parameter. The value of- gis assumed to be in trap units.
- interaction_only: if set to- truethen the noninteracting single-particle terms are ignored. Useful if only energy shifts due to interactions are required.
Rimu.Hamiltonians.HOCartesianCentralImpurity — TypeHOCartesianCentralImpurity(addr; kwargs...)Hamiltonian of non-interacting particles in an arbitrary harmonic trap with a delta-function potential at the centre, with strength g,
\[\hat{H}_\mathrm{rel} = \sum_\mathbf{i} ϵ_\mathbf{i} n_\mathbf{i} + g\sum_\mathbf{ij} V_\mathbf{ij} a^†_\mathbf{i} a_\mathbf{j}.\]
For a $D$-dimensional harmonic oscillator indices $\mathbf{i}, \mathbf{j}, \ldots$ are $D$-tuples. The energy scale is defined by the first dimension i.e. $\hbar \omega_x$ so that single particle energies are
\[ \frac{\epsilon_\mathbf{i}}{\hbar \omega_x} = (i_x + 1/2) + \eta_y (i_y+1/2) + \ldots.\]
The factors $\eta_y, \ldots$ allow for anisotropic trapping geometries and are assumed to be greater than 1 so that $\omega_x$ is the smallest trapping frequency.
Matrix elements $V_{\mathbf{ij}}$ are for a delta function potential calculated in this basis
\[ V_{\mathbf{ij}} = \prod_{d \in x, y,\ldots} \psi_{i_d}(0) \psi_{j_d}(0).\]
Only even parity states feel this impurity, so all $i_d$ are even. Note that the matrix representation of this Hamiltonian for a single particle is completely dense in the even-parity subspace.
Arguments
- addr: the starting address, defines number of particles and total number of modes.
- max_nx = num_modes(addr) - 1: the maximum harmonic oscillator index number in the $x$-dimension. Must be even. Index number for the harmonic oscillator groundstate is- 0.
- ηs = (): a tuple of aspect ratios for the remaining dimensions- (η_y, ...). Should be empty for a 1D trap or contain values greater than- 1.0. The maximum index in other dimensions will be the largest even number less than- M/η_y.
- S = nothing: Instead of- max_nx, manually set the number of levels in each dimension, including the groundstate. Must be a- Tupleof- Ints.
- g = 1.0: the strength of the delta impurity in ($x$-dimension) trap units.
- impurity_only=false: if set to- truethen the trap energy terms are ignored. Useful if only energy shifts due to the impurity are required.
Due to use of `SpecialFunctions` with large arguments the matrix representation of
this Hamiltonian may not be strictly symmetric, but is approximately symmetric within
machine precision.See also HOCartesianContactInteractions andHOCartesianEnergyConservedPerDim.
Other model Hamiltonians
Rimu.Hamiltonians.MatrixHamiltonian — TypeMatrixHamiltonian(
    mat::AbstractMatrix{T};
    starting_address::Int = findmin(real.(diag(mat)))[2]
) <: AbstractHamiltonian{T}Wrap an abstract matrix mat as an AbstractHamiltonian object. Works with stochastic methods of ProjectorMonteCarloProblem() and DVec. Optionally, a valid index can be provided as the starting_address.
Specialised methods are implemented for sparse matrices of type AbstractSparseMatrixCSC. One based indexing is required for the matrix mat.
Rimu.Hamiltonians.Transcorrelated1D — TypeTranscorrelated1D(address; t=1.0, v=1.0, v_ho=0.0, cutoff=1, three_body_term=true)Implements a transcorrelated Hamiltonian for contact interactions in one dimensional momentum space from Jeszenski et al. (2018). Currently limited to two component fermionic addresses.
\[\begin{aligned} \tilde{H} &= t \sum_{kσ}k^2 n_{k,σ} \\ &\quad + \sum_{pqkσσ'} T_{pqk} a^†_{p-k,σ} a^†_{q+k,σ'} a_{q,σ'} a_{p,σ} \\ &\quad + \sum_{pqskk'σσ'} Q_{kk'}a^†_{p-k,σ} a^†_{q+k,σ} a^†_{s+k-k',σ'} a_{s,σ'} a_{q,σ} a_{p,σ} \\ &\quad + V̂_\mathrm{ho} \end{aligned}\]
where
\[\begin{aligned} \tilde{u}(k) &= \begin{cases} -\frac{2}{k^2} &\mathrm{if\ } |k| ≥ k_c\\ 0 & \mathrm{otherwise} \end{cases} \\ T_{pqk} &= \frac{v}{M} + \frac{2v}{M}\left[k^2\tilde{u}(k) - (p - q)k\tilde{u}(k)\right] + \frac{2v^2}{t}W(k)\\ W(k) &= \frac{1}{M^2}\sum_{q} (k - q)q\, \tilde{u}(q)\,\tilde{u}(k - q) \\ Q_{kl} &= -\frac{v^2}{t M^2}k \tilde{u}(k)\,l\tilde{u}(l), \end{aligned}\]
Arguments
- address: The starting address, defines number of particles and sites.
- v: The interaction parameter.
- t: The kinetic energy prefactor.
- v_ho: Strength of the external harmonic oscillator potential $V̂_\mathrm{ho}$. See- HubbardMom1DEP.
- cutoffcontrols $k_c$ in equations above. Note: skipping generating off-diagonal elements below the cutoff is not implemented - zero-valued elements are returned instead.
- three_body_term: If set to false, generating three body excitations is skipped. Note: when disabling three body terms, cutoff should be set to a higher value for best results.
See also
Rimu.Hamiltonians.FroehlichPolaron — TypeFroehlichPolaron(address::OccupationNumberFS{M}; kwargs...) <: AbstractHamiltonianThe Froehlich polaron Hamiltonian for a 1D lattice with M momentum modes is given by
\[H = (p̂_f - p)^2/m + ωN̂ - v Σₖ(âₖ^† + â₋ₖ)\]
where $p$ is the total momentum, $p̂_f = Σ_k k âₖ^† âₖ$ is the momentum operator for the bosons, and $k$ part of the momentum lattice with separation $2π/l$. $N̂$ is the number operator for the bosons.
Keyword Arguments
- p=0.0: the total momentum $p$.
- v=1.0: the coupling strength $v$.
- mass=1.0: the particle mass $m$.
- omega=1.0: the oscillation frequency of the phonons $ω$.
- l=1.0: the box size in real space $l$. Provides scale parameter of the momentum lattice.
- momentum_cutoff=nothing: the maximum boson momentum allowed for an address.
- mode_cutoff: the maximum number of bosons in each momentum mode. Defaults to the maximum value supported by the address type- OccupationNumberFS.
Examples
julia> fs = OccupationNumberFS(0,0,0)
OccupationNumberFS{3, UInt8}(0, 0, 0)
julia> ham = FroehlichPolaron(fs; v=0.5)
FroehlichPolaron(fs"|0 0 0⟩{8}"; v=0.5, mass=1.0, omega=1.0, l=1.0, p=0.0, mode_cutoff=255)
julia> dimension(ham)
16777216
julia> dimension(FroehlichPolaron(fs; v=0.5, mode_cutoff=5))
216See also OccupationNumberFS, dimension, AbstractHamiltonian.
Rimu.Hamiltonians.MolecularHamiltonian — TypeMolecularHamiltonian(
    fcidump_path::String;
    starting_address::Union{Nothing,FermiFS2C}=nothing,
    specifier::String="",
) <: AbstractHamiltonian
MolecularHamiltonian(
    fd::ElemCo.FciDumps.FDump;
    starting_address::Union{Nothing,FermiFS2C}=nothing,
    specifier::String="",
) <: AbstractHamiltonianImplements an electronic ab-initio Hamiltonian based on electron overlap integrals in FCIDUMP format. It can be used to describe the electronic structure of a molecule with fixed nuclear positions (i.e. under the Born-Oppenheimer approximation).
The expression for the Hamiltonian is
\[\begin{aligned} Ĥ & = h₀ + Ĥ₁ + Ĥ₂, \\ Ĥ₁ & = \sum_{i,j,σ} h_{ji} a^†_{j,σ} a_{i,σ}, \\ Ĥ₂ & = ½ \sum_{k,l,i,j,σ,τ} V_{klij} a^†_{k,σ} a^†_{l,τ} a_{j,τ} a_{i,σ}. \end{aligned}\]
where the constants $h₀$, $h_{ji}$, and $V_{klji}$ are provided by the FCIDUMP fd. See the documentation of ElemCo.jl for generating FCIDUMP information with a Hartree-Fock calculation, or parsing them from a file.
Arguments
- fcidump_path: Path to the FCIDUMP file of overlap integrals. This can be generated with standard quantum chemistry packages
- fd: Struct containing FCIDUMP information defined in ElemCo.jl.
Keyword Arguments
- starting_address::FermiFS2C=nothing: The starting address (configuration) defines number of alpha and beta electrons and orbitals.
- specifier::String="": Arbitrary identifier. It may store the path to the FCIDUMP file or a user specified name.
See also FermiFS2C
Requires the ElemCo.jl package to be loaded with using ElemCo.
Convenience functions
Rimu.Hamiltonians.rayleigh_quotient — Functionrayleigh_quotient(H, v)Return the Rayleigh quotient of the linear operator H and the vector v:
\[\frac{⟨ v | H | v ⟩}{⟨ v|v ⟩}\]
Rimu.Hamiltonians.momentum — Functionmomentum(ham::AbstractHamiltonian)Momentum as a linear operator in Fock space. Pass a Hamiltonian ham in order to convey information about the Fock basis. Returns an AbstractHamiltonian that represents the momentum operator.
Note: momentum is currently only defined on HubbardMom1D.
Example
julia> add = BoseFS((1, 0, 2, 1, 2, 1, 1, 3));
julia> ham = HubbardMom1D(add; u = 2.0, t = 1.0);
julia> mom = momentum(ham);
julia> diagonal_element(mom, add) # calculate the momentum of a single configuration
-1.5707963267948966
julia> v = DVec(add => 10; capacity=1000);
julia> rayleigh_quotient(mom, v) # momentum expectation value for state vector `v`
-1.5707963267948966Part of the AbstractHamiltonian interface.
Rimu.Hamiltonians.hubbard_dispersion — Functionhubbard_dispersion(t, k)Dispersion relation for HubbardMom1D. Returns $-2(\Re(t) \cos(k) + \Im(t) \sin(k))$.
See also continuum_dispersion.
Rimu.Hamiltonians.continuum_dispersion — Functioncontinuum_dispersion(t, k)Dispersion relation for HubbardMom1D. Returns $\Re(t) k^2 - 2 \Im(t) k$.
See also hubbard_dispersion.
Rimu.Hamiltonians.shift_lattice — Functionshift_lattice(is)Circular shift contiguous indices is in interval [M÷2, M÷2) such that set starts with 0, where M=length(is).
Inverse operation: shift_lattice_inv. Used in HubbardReal1DEP and HubbardMom1DEP
Rimu.Hamiltonians.shift_lattice_inv — Functionshift_lattice_inv(js)Circular shift indices starting with 0 into a contiguous set in interval [M÷2, M÷2), where M=length(js).
Inverse operation of shift_lattice. Used in HubbardReal1DEP and HubbardMom1DEP
Hamiltonian wrappers
The following Hamiltonians are constructed from an existing Hamiltonian instance and change its behaviour:
Rimu.Hamiltonians.GutzwillerSampling — TypeGutzwillerSampling(H::AbstractHamiltonian; g)Wrapper over any AbstractHamiltonian that implements Gutzwiller sampling. In this importance sampling scheme the Hamiltonian is modified as follows
\[\tilde{H}_{ij} = H_{ij} e^{-g(H_{ii} - H_{jj})} .\]
This way off-diagonal spawns to higher-energy configurations are discouraged and spawns to lower-energy configurations encouraged for positive g while keeping the spectrum of the Hamiltonian intact.
Constructor
- GutzwillerSampling(::AbstractHamiltonian, g)
- GutzwillerSampling(::AbstractHamiltonian; g)
After construction, we can access the underlying Hamiltonian with G.hamiltonian and the g parameter with G.g.
Example
julia> H = HubbardMom1D(BoseFS(1,1,1); u=6.0, t=1.0)
HubbardMom1D(fs"|1 1 1⟩"; u=6.0, t=1.0)
julia> G = GutzwillerSampling(H, g=0.3)
GutzwillerSampling(HubbardMom1D(fs"|1 1 1⟩"; u=6.0, t=1.0); g=0.3)
julia> Matrix(H; sort=true)
4×4 Matrix{Float64}:
 9.0      0.0       4.89898  0.0
 0.0      0.0       4.89898  0.0
 4.89898  4.89898  12.0      4.89898
 0.0      0.0       4.89898  9.0
julia> Matrix(G; sort=true)
4×4 Matrix{Float64}:
 9.0      0.0        12.0495  0.0
 0.0      0.0       179.294   0.0
 1.99178  0.133858   12.0     1.99178
 0.0      0.0        12.0495  9.0
julia> eigen(Matrix(H)).values
4-element Vector{Float64}:
 -2.3661456273236645
  4.9594958589580465
  8.999999999999996
 18.406649768365643
julia> eigen(Matrix(G)).values
4-element Vector{Float64}:
 -2.366145627323686
  4.959495858958046
  8.999999999999998
 18.40664976836564Observables
See AllOverlaps for calculation of observables with a transformed Hamiltonian.
Rimu.Hamiltonians.GuidingVectorSampling — TypeGuidingVectorSamplingWrapper over any AbstractHamiltonian that implements guided vector a.k.a. guided wave function sampling. In this importance sampling scheme the Hamiltonian is modified as follows.
\[\tilde{H}_{ij} = v_i H_{ij} v_j^{-1}\]
and where v is the guiding vector. v_i and v_j are also thresholded to avoid dividing by zero (see below).
Constructors
- GuidingVectorSampling(::AbstractHamiltonian, vector, eps)
- GuidingVectorSampling(::AbstractHamiltonian; vector, eps)
eps is a thresholding parameter used to avoid dividing by zero; all values below eps are set to eps. It is recommended that eps is in the same value range as the guiding vector. The default value is set to eps=norm(v, Inf) * 1e-2
After construction, we can access the underlying hamiltonian with G.hamiltonian, the eps parameter with G.eps, and the guiding vector with G.vector.
Example
julia> H = HubbardMom1D(BoseFS(1,1,1); u=6.0, t=1.0);
julia> v = DVec(starting_address(H) => 10);
julia> G = GuidingVectorSampling(H, v, 0.1);
julia> Matrix(H; sort=true)
4×4 Matrix{Float64}:
 9.0      0.0       4.89898  0.0
 0.0      0.0       4.89898  0.0
 4.89898  4.89898  12.0      4.89898
 0.0      0.0       4.89898  9.0
julia> Matrix(G; sort=true)
4×4 Matrix{Float64}:
   9.0      0.0     0.0489898    0.0
   0.0      0.0     0.0489898    0.0
 489.898  489.898  12.0        489.898
   0.0      0.0     0.0489898    9.0
julia> eigen(Matrix(H)).values
4-element Vector{Float64}:
 -2.3661456273236645
  4.9594958589580465
  8.999999999999996
 18.406649768365643
julia> eigen(Matrix(G)).values
4-element Vector{Float64}:
 -2.366145627323689
  4.9594958589580465
  8.999999999999998
 18.406649768365643Observables
See AllOverlaps for calculation of observables with a transformed Hamiltonian.
Rimu.Hamiltonians.ParitySymmetry — TypeParitySymmetry(ham::AbstractHamiltonian{T}; even=true) <: AbstractHamiltonian{T}Impose even or odd parity on all states and the Hamiltonian ham as controlled by the keyword argument even. Parity symmetry of the Hamiltonian is assumed. For some Hamiltonians, ParitySymmetry reduces the size of the Hilbert space by half.
ParitySymmetry performs a unitary transformation, leaving the eigenvalues unchanged and preserving the LOStructure. This is achieved by changing the basis set to states with defined parity. Effectively, a non-even address $|α⟩$ is replaced by $\frac{1}{√2}(|α⟩ ± |ᾱ⟩)$ for even and odd parity, respectively, where ᾱ == reverse(α).
Notes
- This modifier currently only works on starting_addresss with an odd number of modes.
- For odd parity, the starting_addressof the underlying Hamiltonian cannot be symmetric.
- If parity is not a symmetry of the Hamiltonian hamthen the result is undefined.
- ParitySymmetryworks by modifying the- offdiagonalsiterator.
julia> ham = HubbardReal1D(BoseFS(0,2,1))
HubbardReal1D(fs"|0 2 1⟩"; u=1.0, t=1.0)
julia> size(Matrix(ham))
(10, 10)
julia> size(Matrix(ParitySymmetry(ham)))
(6, 6)
julia> size(Matrix(ParitySymmetry(ham; odd=true)))
(4, 4)
julia> eigvals(Matrix(ham))[1] ≈ eigvals(Matrix(ParitySymmetry(ham)))[1]
trueSee also TimeReversalSymmetry.
Rimu.Hamiltonians.TimeReversalSymmetry — TypeTimeReversalSymmetry(ham::AbstractHamiltonian{T}; even=true) <: AbstractHamiltonian{T}Impose even or odd time reversal on all states and the Hamiltonian ham as controlled by the keyword argument even. If time reversal is a symmetry of the Hamiltonian it will block (reducing Hilbert space dimension) preserving the eigenvalues and LOStructure.
Notes
- This modifier only works two component starting_addresses.
- For odd time reversal symmetry, the starting_addressof the underlying Hamiltonian must not be symmetric.
- If time reversal is not a symmetry of the Hamiltonian hamthen the result is undefined.
- TimeReversalSymmetryworks by modifying the- offdiagonalsiterator.
julia> ham = HubbardMom1D(FermiFS2C((1,0,1),(0,1,1)));
julia> size(Matrix(ham))
(3, 3)
julia> size(Matrix(TimeReversalSymmetry(ham)))
(2, 2)
julia> size(Matrix(TimeReversalSymmetry(ham, even=false)))
(1, 1)
julia> eigvals(Matrix(TimeReversalSymmetry(ham)))[1] ≈ eigvals(Matrix(ham))[1]
trueSee also ParitySymmetry.
Rimu.Hamiltonians.Stoquastic — TypeStoquastic(ham <: AbstractHamiltonian) <: AbstractHamiltonianA wrapper for an AbstractHamiltonian that replaces all off-diagonal matrix elements v by -abs(v), thus making the new Hamiltonian stoquastic.
A stoquastic Hamiltonian does not have a Monte Carlo sign problem. For a hermitian ham the smallest eigenvalue of Stoquastic(ham) is ≤ the smallest eigenvalue of ham.
Rimu.Hamiltonians.TransformUndoer — TypeTransformUndoer(transform::AbstractHamiltonian, op::AbstractObservable) <: AbstractHamiltonianCreate a new operator for the purpose of calculating overlaps of transformed vectors, which are defined by some transformation transform. The new operator should represent the effect of undoing the transformation before calculating overlaps, including with an optional operator op.
Not exported; transformations should define all necessary methods and properties, see AbstractHamiltonian. An ArgumentError is thrown if used with an unsupported transformation.
Example
A similarity transform $\hat{G} = f \hat{H} f^{-1}$ has eigenvector $d = f \cdot c$ where $c$ is an eigenvector of $\hat{H}$. Then the overlap $c' \cdot c = d' \cdot f^{-2} \cdot d$ can be computed by defining all necessary methods for TransformUndoer(G) to represent the operator $f^{-2}$ and calculating dot(d, TransformUndoer(G), d).
Observables in the transformed basis can be computed by defining TransformUndoer(G, A) to represent $f^{-1} A f^{-1}$.
Supported transformations
Rimu.Hamiltonians.HamiltonianProduct — TypeHamiltonianProduct(A::AbstractHamiltonian, B::AbstractHamiltonian; commuting=A==B)
*(A::AbstractHamiltonian, B::AbstractHamiltonian)The product of two AbstractHamiltonians, acting from right to left. The two Hamiltonians must act on the same address space. Set commuting to true if A and B commute.
See also ScaledHamiltonian, HamiltonianSum, AbstractHamiltonian.
Rimu.Hamiltonians.ScaledHamiltonian — TypeScaledHamiltonian(H::AbstractHamiltonian, α) <: AbstractHamiltonian
scale(H, α)
α * HThe product of the Hamiltonian H with the scalar α.
See also HamiltonianSum, HamiltonianProduct, AbstractHamiltonian.
Rimu.Hamiltonians.HamiltonianSum — TypeHamiltonianSum(A::AbstractHamiltonian, B::AbstractHamiltonian; weight=0.5) <: AbstractHamiltonian
add(A::AbstractHamiltonian, B::AbstractHamiltonian, [a=1, b=1]; weight=0.5) -> HamiltonianSum
+(A::AbstractHamiltonian, B::AbstractHamiltonian)The sum of two AbstractHamiltonians, $A + B$. The two Hamiltonians must act  on the same address space. The keyword argument weight affects random spawning with random_offdiagonal and determines the probability of random spawns  from A, with 1 - weight the probability of spawning from B.
If coefficients a and b are given, the Hamiltonians are scaled with ScaledHamiltonian, to represent $aA + bB$.
See also ScaledHamiltonian, HamiltonianProduct, AbstractHamiltonian.
Observables
Rimu.jl offers two other supertypes for operators that are less restrictive than AbstractHamiltonian. AbstractObservable and AbstractOperators both can represent a physical observable. Their expectation values can be sampled during a ProjectorMonteCarloProblem simulation by passing them into a suitable ReplicaStrategy, e.g. AllOverlaps. Some observables are also AbstractHamiltonians. The full type hierarchy is
AbstractHamiltonian{T} <: AbstractOperator{T} <: AbstractObservable{T}Rimu.Hamiltonians.IdentityOperator — TypeIdentityOperator() <: AbstractOperator{Float64}The diagonal operator with 1.0 along its diagonal.
Rimu.Hamiltonians.ParticleNumberOperator — TypeParticleNumberOperator() <: AbstractOperator{Float64}The number operator in Fock space. This operator is diagonal in the Fock basis and returns the number of particles in the Fock state. It works with any address type that is a subtype of AbstractFockAddress.
julia> p = ExactDiagonalizationProblem(FroehlichPolaron(fs"|0 0⟩{}"; mode_cutoff=5, v=3));
julia> gs = solve(p).vectors[1]; # normalised ground state vector
julia> dot(gs, ParticleNumberOperator(), gs) # particle number expectation value
2.8823297252925917See also AbstractHamiltonian.
Rimu.Hamiltonians.G2RealCorrelator — TypeG2RealCorrelator(d::Int) <: AbstractOperator{Float64}Two-body operator for density-density correlation between sites separated by d with 0 ≤ d < M.
\[ \hat{G}^{(2)}(d) = \frac{1}{M} \sum_i^M \hat{n}_i (\hat{n}_{i+d} - \delta_{0d}).\]
Assumes a one-dimensional lattice with periodic boundary conditions where
\[ \hat{G}^{(2)}(-M/2 \leq d < 0) = \hat{G}^{(2)}(|d|),\]
\[ \hat{G}^{(2)}(M/2 < d < M) = \hat{G}^{(2)}(M - d),\]
and normalisation
\[ \sum_{d=0}^{M-1} \langle \hat{G}^{(2)}(d) \rangle = \frac{N (N-1)}{M}.\]
For multicomponent basis, calculates correlations between all particles equally, equivalent to stacking all components into a single Fock state.
Arguments
- d::Integer: distance between sites.
See also
Rimu.Hamiltonians.G2RealSpace — TypeG2RealSpace(geometry::CubicGrid, σ=1, τ=1; sum_components=false) <: AbstractOperator{SArray}Two-body operator for density-density correlation for all Displacements $d⃗$ in the specified geometry.
\[ \hat{G}^{(2)}_{σ,τ}(d⃗) = \frac{1}{M} ∑_{i⃗} n̂_{σ,i⃗} (n̂_{τ,i⃗+d⃗} - δ_{0⃗,d⃗}δ_{σ,τ}).\]
For multicomponent addresses, σ and τ control the components involved. Alternatively, sum_components can be set to true, which treats all particles as belonging to the same component.
Examples
julia> geom = CubicGrid(2, 2);
julia> g2 = G2RealSpace(geom)
G2RealSpace(CubicGrid((2, 2), (true, true)), 1,1)
julia> diagonal_element(g2, BoseFS(2,0,1,1))
2×2 StaticArraysCore.SMatrix{2, 2, Float64, 4} with indices SOneTo(2)×SOneTo(2):
 0.5  1.0
 0.5  1.0
julia> g2_cross = G2RealSpace(geom, 1, 2)
G2RealSpace(CubicGrid((2, 2), (true, true)), 1,2)
julia> g2_sum = G2RealSpace(geom, sum_components=true)
G2RealSpace(CubicGrid((2, 2), (true, true)); sum_components=true)
julia> diagonal_element(g2, fs"|⇅⋅↓↑⟩")
2×2 StaticArraysCore.SMatrix{2, 2, Float64, 4} with indices SOneTo(2)×SOneTo(2):
 0.0  0.0
 0.0  0.5
julia> diagonal_element(g2_cross, fs"|⇅⋅↓↑⟩")
2×2 StaticArraysCore.SMatrix{2, 2, Float64, 4} with indices SOneTo(2)×SOneTo(2):
 0.25  0.25
 0.25  0.25
julia> diagonal_element(g2_sum, fs"|⇅⋅↓↑⟩")
2×2 StaticArraysCore.SMatrix{2, 2, Float64, 4} with indices SOneTo(2)×SOneTo(2):
 0.5  1.0
 0.5  1.0See also
Rimu.Hamiltonians.G2MomCorrelator — TypeG2MomCorrelator(d::Int) <: AbstractOperator{ComplexF64}Two-body correlation operator representing the density-density correlation at distance d. It returns a Complex value.
Correlation within a single component:
\[\hat{G}^{(2)}(d) = \frac{1}{M}\sum_{spqr=1}^M e^{-id(p-q)2π/M} a^†_{s} a^†_{p} a_q a_r δ_{s+p,q+r}\]
The diagonal element, where (p-q)=0, is
\[\frac{1}{M}\sum_{k,p=1}^M a^†_{k} b^†_{p} b_p a_k .\]
Arguments
- d::Integer: the distance between two particles.
See also
Rimu.Hamiltonians.SuperfluidCorrelator — TypeSuperfluidCorrelator(d::Int) <: AbstractOperator{Float64}Operator for extracting superfluid correlation between sites separated by a distance d with 0 ≤ d < M:
\[ \hat{C}_{\text{SF}}(d) = \frac{1}{M} \sum_{i}^{M} a_{i}^{\dagger} a_{i + d}\]
Assumes a one-dimensional lattice with $M$ sites and periodic boundary conditions. $M$ is also the number of modes in the Fock state address.
Usage
Superfluid correlations can be extracted from a Monte Carlo calculation by wrapping SuperfluidCorrelator with AllOverlaps and passing into ProjectorMonteCarloProblem with the replica keyword argument. For an example with a similar use of G2RealCorrelator see G2 Correlator Example.
See also HubbardReal1D, G2RealCorrelator, AbstractOperator, and AllOverlaps.
Rimu.Hamiltonians.StringCorrelator — TypeStringCorrelator(d::Int; address=nothing, type=nothing) <: AbstractOperator{T}Operator for extracting string correlation between lattice sites on a one-dimensional Hubbard lattice separated by a distance d with 0 ≤ d < M
\[ Ĉ_{\text{string}}(d) = \frac{1}{M} \sum_{j}^{M} δ n̂_j (e^{i π \sum_{j ≤ k < j + d} δ n̂_k}) δ n̂_{j+d}\]
Here, $δ n̂_j = n̂_j - n̄$ is the boson number deviation from the mean filling number and $n̄ = N/M$ is the mean filling number of lattice sites with $N$ particles and $M$ lattice sites (or modes).
Assumes a one-dimensional lattice with periodic boundary conditions. For usage see SuperfluidCorrelator and AllOverlaps.
The default element type T is ComplexF64. This can be overridden with the type keyword argument. If an address is provided, then T is calculated from the address type. It is set to ComplexF64 for non-integer filling numbers, and to Float64 for integer filling numbers or if d==0.
See also HubbardReal1D, G2RealCorrelator, SuperfluidCorrelator, AbstractOperator, and AllOverlaps.
Rimu.Hamiltonians.DensityMatrixDiagonal — TypeDensityMatrixDiagonal(mode; component=0) <: AbstractHamiltonianRepresent a diagonal element of the single-particle density:
\[\hat{n}_{i,σ} = \hat a^†_{i,σ} \hat a_{i,σ}\]
where $i$ is the mode and $σ$ is the component. If component is zero, the sum over all components is computed.
See also
Rimu.Hamiltonians.SingleParticleExcitation — TypeSingleParticleExcitation(i, j) <: AbstractOperatorRepresent the ${i,j}$ element of the single-particle reduced density matrix:
\[ρ̂^{(1)}_{i,j} = â^†_{i} â_{j}\]
where i <: Int and j <: Int specify the mode numbers.
See also
Rimu.Hamiltonians.TwoParticleExcitation — TypeTwoParticleExcitation(i, j, k, l) <: AbstractOperatorRepresent the ${ij, kl}$ element of the two-particle reduced density matrix:
\[ρ̂^{(2)}_{ij, kl} = â^†_{i} â^†_{j} â_{l} â_{k}\]
where i, j, k, and l (all <: Int) specify the mode numbers.
See also
Rimu.Hamiltonians.ReducedDensityMatrix — TypeReducedDensityMatrix{T=Float64}(p) <: AbstractObservable{Matrix{T}}A matrix-valued operator that can be used to calculate the p-particle reduced density matrix. The matrix elements are defined as:
\[\hat{ρ}^{(p)}_{j_1,...,j_1,k_1,...,k_p} = \prod_{i=1}^{p} â^†_{j_i} \prod_{l=p}^{1} â_{k_{l}}\]
The integer indices j_i and k_i represent single particle modes. For efficiency they are chosen to be distinct and ordered:
\[j_1 < j_2 < \ldots < j_{p} \quad \land \quad k_1 < k_2 < \ldots < k_{p}\]
ReducedDensityMatrix can be used to construct the single-particle reduced density matrix (with p == 1) for fermionic and bosonic Fock spaces with address types <: SingleComponentFockAddress. For higher order reduced density matrices with p > 1 only fermionic Fock addresses (FermiFS) are supported due to the ordering of indices.
ReducedDensityMatrix can be used with dot or AllOverlaps to calculate the whole matrix in one go.
Examples
julia> dvec_b = PDVec(BoseFS(1,1) => 0.5, BoseFS(2,0) => 0.5)
2-element PDVec: style = IsDeterministic{Float64}()
  fs"|2 0⟩" => 0.5
  fs"|1 1⟩" => 0.5
julia> Op1 = ReducedDensityMatrix(1)
ReducedDensityMatrix{Float64}(1)
julia> dot(dvec_b, Op1, dvec_b)
2×2 Matrix{Float64}:
 0.75      0.353553
 0.353553  0.25
julia> Op2 = ReducedDensityMatrix{Float32}(2)
ReducedDensityMatrix{Float32}(2)
julia> dvec_f = PDVec(FermiFS(1,1,0,0) => 0.5, FermiFS(0,1,1,0) => 0.5)
2-element PDVec: style = IsDeterministic{Float64}()
  fs"|↑↑⋅⋅⟩" => 0.5
  fs"|⋅↑↑⋅⟩" => 0.5
julia> dot(dvec_f, Op2, dvec_f)
6×6 Matrix{Float32}:
 0.25  0.0  0.25  0.0  0.0  0.0
 0.0   0.0  0.0   0.0  0.0  0.0
 0.25  0.0  0.25  0.0  0.0  0.0
 0.0   0.0  0.0   0.0  0.0  0.0
 0.0   0.0  0.0   0.0  0.0  0.0
 0.0   0.0  0.0   0.0  0.0  0.0See also single_particle_density, SingleParticleDensity, SingleParticleExcitation, TwoParticleExcitation.
Rimu.Hamiltonians.Momentum — TypeMomentum(component=0; fold=true) <: AbstractHamiltonianThe momentum operator $P̂$.
The component argument controls which component of the address is taken into consideration. A value of 0 sums the contributions of all components. If fold is true, the momentum is folded into the Brillouin zone.
julia> address = BoseFS((1, 0, 2, 1, 2, 1, 1, 3))
BoseFS{11,8}(1, 0, 2, 1, 2, 1, 1, 3)
julia> v = DVec(address => 10);
julia> rayleigh_quotient(Momentum(), DVec(address => 1))
-2.0
julia> rayleigh_quotient(Momentum(fold=false), DVec(address => 1))
14.0Rimu.Hamiltonians.AxialAngularMomentumHO — TypeAxialAngularMomentumHO(S; z_dim = 3, addr = BoseFS(prod(S))) <: AbstractHamiltonianAngular momentum operator for application to Cartesian harmonic oscillator basis, see HOCartesianContactInteractions or HOCartesianEnergyConservedPerDim. Represents the projection of angular momentum onto z-axis:
\[\hat{L}_z = i \hbar \sum_{j=1}^N \left( b_x b_y^\dag - b_y b_x^\dag \right),\]
where $b_x^\dag$ and $b_x$ are raising and lowering (ladder) operators for a harmonic oscillator in the $x$ dimension, and simlarly for $y$.
This is implemented for an $N$ particle Fock space with creation and annihilation operators as
\[\frac{1}{\hbar} \hat{L}_z = i \sum_{n_x=1}^{M_x} \sum_{n_y=1}^{M_y} \left( a_{n_x-1,n_y+1}^\dag - a_{n_x+1,n_y-1}^\dag \right) a_{n_x, n_y}.\]
in units of $\hbar$.
Argument S is a tuple defining the range of Cartesian modes in each dimension and their mapping to Fock space modes in a SingleComponentFockAddress. If S indicates a 3D system the z dimension can be changed by setting z_dim; S should be be isotropic in the remaining x-y plane, i.e. must have S[x_dim] == S[y_dim]. The starting address addr only needs to satisfy num_modes(addr) == prod(S).
Example
Calculate the overlap of two Fock addresses interpreted as harmonic oscillator states in a 2D Cartesian basis
julia> S = (2,2)
(2, 2)
julia> Lz = AxialAngularMomentumHO(S)
AxialAngularMomentumHO((2, 2); z_dim = 3, addr = BoseFS{0,4}(0, 0, 0, 0))
julia> v = DVec(BoseFS(prod(S), 2 => 1) => 1.0)
DVec{BoseFS{1, 4, BitString{4, 1, UInt8}},Float64} with 1 entry, style = IsDeterministic{Float64}()
  fs"|0 1 0 0⟩" => 1.0
julia> w = DVec(BoseFS(prod(S), 3 => 1) => 1.0)
DVec{BoseFS{1, 4, BitString{4, 1, UInt8}},Float64} with 1 entry, style = IsDeterministic{Float64}()
  fs"|0 0 1 0⟩" => 1.0
julia> dot(w, Lz, v)
0.0 + 1.0imGeometry
Lattices in higher dimensions are defined here and can be passed with the keyword argument geometry to HubbardRealSpace and G2RealSpace.
Rimu.Hamiltonians.CubicGrid — TypeCubicGrid(dims::NTuple{D,Int}, fold::NTuple{D,Bool})Represents a D-dimensional grid. Used to define a cubic lattice and boundary conditions for some AbstractHamiltonians, e.g. with the keyword argument geometry when constructing a HubbardRealSpace. The type instance can be used to convert between cartesian vector indices (tuples or SVectors) and linear indices (integers). When indexed with vectors, it folds them back into the grid if the out-of-bounds dimension is periodic and 0 otherwise (see example below).
- dimscontrols the size of the grid in each dimension.
- foldcontrols whether the boundaries in each dimension are periodic (or folded in the case of momentum space).
julia> geo = CubicGrid((2,3), (true,false))
CubicGrid{2}((2, 3), (true, false))
julia> geo[1]
(1, 1)
julia> geo[2]
(2, 1)
julia> geo[3]
(1, 2)
julia> geo[(1,2)]
3
julia> geo[(3,2)] # 3 is folded back into 1
3
julia> geo[(3,3)]
5
julia> geo[(3,4)] # returns 0 if out of bounds
0See also PeriodicBoundaries, HardwallBoundaries and LadderBoundaries for special-case constructors. See also HubbardRealSpace and G2RealSpace.
Rimu.Hamiltonians.Directions — TypeDirections(D) <: AbstractVector{SVector{D,Int}}
Directions(geometry::CubicGrid) <: AbstractVector{SVector{D,Int}}Iterate over axis-aligned direction vectors in D dimensions.
julia> Directions(3)
6-element Directions{3}:
 [1, 0, 0]
 [0, 1, 0]
 [0, 0, 1]
 [-1, 0, 0]
 [0, -1, 0]
 [0, 0, -1]
See also CubicGrid.
Rimu.Hamiltonians.Displacements — TypeDisplacements(geometry::CubicGrid) <: AbstractVector{SVector{D,Int}}Return all valid offset vectors in a CubicGrid. If center=true the (0,0) displacement is placed at the centre of the array.
julia> geometry = CubicGrid((3,4));
julia> reshape(Displacements(geometry), (3,4))
3×4 reshape(::Displacements{2, CubicGrid{2, (3, 4), (true, true)}}, 3, 4) with eltype StaticArraysCore.SVector{2, Int64}:
 [0, 0]  [0, 1]  [0, 2]  [0, 3]
 [1, 0]  [1, 1]  [1, 2]  [1, 3]
 [2, 0]  [2, 1]  [2, 2]  [2, 3]
julia> reshape(Displacements(geometry; center=true), (3,4))
3×4 reshape(::Displacements{2, CubicGrid{2, (3, 4), (true, true)}}, 3, 4) with eltype StaticArraysCore.SVector{2, Int64}:
 [-1, -1]  [-1, 0]  [-1, 1]  [-1, 2]
 [0, -1]   [0, 0]   [0, 1]   [0, 2]
 [1, -1]   [1, 0]   [1, 1]   [1, 2]
Rimu.Hamiltonians.neighbor_site — Functionneighbor_site(geom::CubicGrid, site, i)Find the i-th neighbor of site in the geometry. If the move is illegal, return 0.
See also CubicGrid.
Rimu.Hamiltonians.PeriodicBoundaries — FunctionPeriodicBoundaries(dims...) -> CubicGrid
PeriodicBoundaries(dims) -> CubicGridReturn a CubicGrid with all dimensions periodic. Equivalent to CubicGrid(dims).
Rimu.Hamiltonians.HardwallBoundaries — FunctionHardwallBoundaries(dims...) -> CubicGrid
HardwallBoundaries(dims) -> CubicGridReturn a CubicGrid with all dimensions non-periodic. Equivalent to CubicGrid(dims, (false, false, ...)).
Rimu.Hamiltonians.LadderBoundaries — FunctionLadderBoundaries(dims...) -> CubicGrid
LadderBoundaries(dims) -> CubicGridReturn a CubicGrid where the first dimension is dimensions non-periodic and the rest are periodic. Equivalent to CubicGrid(dims, (true, false, ...)).
Additional documentation of internal functions
The following internal functions and types are documented here for completeness, but are not part of the public API and may change any time. Use at your own risk.
Rimu.Hamiltonians.one_electron_diagonal — Functionone_electron_diagonal(
    int1::Matrix{<:Number},
    occ_modes::NTuple{2,AbstractVector{FermiFSIndex}},
)::T where {T<:Number}Calculate the one body operator diagonal term $⟨U|Ĥ₁|U⟩$ for a two-component Fermi Fock address.
\[⟨U|Ĥ₁|U⟩ = ∑_{i,σ}^N ⟨U| h_{ii} a^†_{iσ} a_{iσ} |U⟩,\]
where the mode map of the two-component Fock address $|U⟩$ is passed as occ_modes.
Rimu.Hamiltonians.two_electron_diagonal — Functiontwo_electron_diagonal(
    int2::Array{T,4},
    occ_modes::NTuple{2,AbstractVector{FermiFSIndex}},
)::T where {T<:Number}Calculate the two body operator diagonal term $⟨U|Ĥ₂|U⟩$ for a two-component Fermi Fock address.
\[⟨U|Ĥ₂|U⟩ = ∑_{i < j,σ,τ}^{M} (V_{ij,ij} ⟨U| a^†_{i,σ} a^†_{j,τ} a_{j,τ} a_{i,σ} |U⟩ - V_{ij,ji} ⟨U| a^†_{i,σ} a^†_{j,τ} a_{i,τ} a_{j,σ}|U⟩ δ_{σ,τ} )\]
where the mode map of the two-component Fock address $|U⟩$ is passed as occ_modes.
Rimu.Hamiltonians.MolecularHamiltonianOffDiagonals — TypeMolecularHamiltonianOffDiagonalsThis struct is used internally to represent the iterator for the generation of off-diagonal terms from the operator_column of a MolecularHamiltonian.
The iteration proceeds by going through the five possible excitation types:
- single (particle - hole) excitations of the beta electrons
- single (p-h) excitations of the alpha electrons
- double (2p-2h) excitations of the beta electrons
- double (2p-2h) excitations of the alpha electrons
- mixed double excitations (p-h of alpha and p-h of beta electrons)
The field excitation_prefix_sums stores the sums of excitation counts for each of the five excitation types in order.
See also offdiagonals.
Rimu.Hamiltonians.MolecularHamiltonianOffDiagonalsIteratorState — TypeMolecularHamiltonianOffDiagonalsIteratorStateThis struct is used internally to represent the state during off-diagonal terms generation.
- excitations_per_channel: Tuple contains 2 values represents the how many electrons are excited in alpha(1) and beta(2) channel.
- from_occupieds: Records the indices of- FermiFS2CModesarrays which modes electrons being excited from.
- to_unoccupieds: Records the indices of- FermiFS2CModesarrays which modes electrons being excited to.
Both from_occupieds == (0,0) and to_unoccupieds == (0,0) represent a special "void" state when there is no more state in current n_excited situation, this is used to notify upper caller that it should move to next valid excitations_per_channel. This is checked by the function is_void_state.
When used to represents one-electron-excitation cases, only from_occupieds[1] and to_unoccupieds[1] are used. When used to represents two-electrons-excitation cases, from_occupieds[1], to_unoccupieds[1], from_occupieds[2] and to_unoccupieds[2] are all used. When used to represent the one-one-electron-excitation case, index 1 represents alpha electrons and index 2 represents beta electrons, respectively.
See also FermiFS2CModes.
Rimu.Hamiltonians.flip_spin_components — Functionflip_spin_components(component::Int)::IntThis is an inline function used to flip the spin component index.
Rimu.Hamiltonians.is_void_state — Functionis_void_state(s::MolecularHamiltonianOffDiagonalsIteratorState)When from_occupieds == (0,0) and to_unoccupieds == (0,0) are both satisfied, the state is considered a void state.
Rimu.Hamiltonians.is_invalid_state — Functionis_invalid_state(
    iter::MolecularHamiltonianOffDiagonalsIterator,
    s::MolecularHamiltonianOffDiagonalsIteratorState
)This function is used to check if s is a valid state. It checks if its field from_occupieds and to_unoccupieds tuples hold the indices within the range of corresponding FermiFS2CModes array.
Rimu.Hamiltonians.linear_to_state — Functionlinear_to_state(
    iter::MolecularHamiltonianOffDiagonals, iter_index::Int
)::MolecularHamiltonianOffDiagonalsIteratorStateThis function takes iter and iter_index as arguments. The iterator iter produces a sequence of state values in a fixed order, establishing a bijection between indices and states. Given an iter_index, the function generates the corresponding state by performing the following steps:
- Identify excitation type- As iter is traversed, it outputs states belonging to different excitation types in a specific order.
- Since the number of states for each excitation type is known in advance,   we can determine which excitation type corresponds to the given iter_indexby checking the index range it falls into.
 
- Locate the state within the excitation type- Once the excitation type is identified, compute the offset associated with that type.
- Using this offset, determine the exact state corresponding to the provided iter_index.
 
Rimu.Hamiltonians.unrank_combination — Functionunrank_combination(n::Int, i::Int)Return the 2-element combination (in lexicographical order) of the set $\{1, ..., n\}$ corresponding to the index $i$.
When generating excited states with two electrons excited within a single spin channel,  two indices are chosen from the array of (un)occupied mode maps. For example, selecting  two non-repeating indices from the array of unoccupied modes determines the target modes for the electrons, stored as the to_unoccupieds tuple in  MolecularHamiltonianOffDiagonalsIteratorState.
For instance, if there are 4 unoccupied modes, the possible 2-element combinations (in lexicographic order) are:
index:       1      2      3      4      5      6
combination: (1, 2) (1, 3) (1, 4) (2, 3) (2, 4) (3, 4)There are $\binom{4}{2} = 6$ such combinations in total.
Algorithm
- To determine the first element $x$ of the combination from $i$:- For each candidate $x$, compute the number of combinations possible with $y > x$. This count is $\binom{n-x}{1} = n - x$.
- Subtract these counts from $i$ until $i$ falls within the current range.
 
- Once $x$ is determined, the remaining offset $i$ directly specifies the second element $y$ of the combination.
Example for $i = 2, 4$:
x = 1 → count = 3
x = 2 → count = 2
x = 3 → count = 1
x = 4 → count = 0- For $i = 2$: since $i ∈ [1, 3]$, we set $x = 1$. Then $y = x + i = 3$, so the combination is $(1, 3)$. 
- For $i = 4$: since $i > 3$, subtract 3 → $i = 1$. Now test with $x = 2$. Since $i ∈ [1, 2]$, we set $x = 2$. Then $y = x + i = 3$, so the combination is $(2, 3)$. 
Index
- Rimu.Hamiltonians
- Rimu.Hamiltonians.AxialAngularMomentumHO
- Rimu.Hamiltonians.CubicGrid
- Rimu.Hamiltonians.DensityMatrixDiagonal
- Rimu.Hamiltonians.Directions
- Rimu.Hamiltonians.Displacements
- Rimu.Hamiltonians.ExtendedHubbardMom1D
- Rimu.Hamiltonians.ExtendedHubbardReal1D
- Rimu.Hamiltonians.FroehlichPolaron
- Rimu.Hamiltonians.G2MomCorrelator
- Rimu.Hamiltonians.G2RealCorrelator
- Rimu.Hamiltonians.G2RealSpace
- Rimu.Hamiltonians.GuidingVectorSampling
- Rimu.Hamiltonians.GutzwillerSampling
- Rimu.Hamiltonians.HOCartesianCentralImpurity
- Rimu.Hamiltonians.HOCartesianContactInteractions
- Rimu.Hamiltonians.HOCartesianEnergyConservedPerDim
- Rimu.Hamiltonians.HamiltonianProduct
- Rimu.Hamiltonians.HamiltonianSum
- Rimu.Hamiltonians.HubbardMom1D
- Rimu.Hamiltonians.HubbardMom1DEP
- Rimu.Hamiltonians.HubbardReal1D
- Rimu.Hamiltonians.HubbardReal1DEP
- Rimu.Hamiltonians.HubbardRealSpace
- Rimu.Hamiltonians.IdentityOperator
- Rimu.Hamiltonians.MatrixHamiltonian
- Rimu.Hamiltonians.MolecularHamiltonian
- Rimu.Hamiltonians.MolecularHamiltonianOffDiagonals
- Rimu.Hamiltonians.MolecularHamiltonianOffDiagonalsIteratorState
- Rimu.Hamiltonians.Momentum
- Rimu.Hamiltonians.ParitySymmetry
- Rimu.Hamiltonians.ParticleNumberOperator
- Rimu.Hamiltonians.ReducedDensityMatrix
- Rimu.Hamiltonians.ScaledHamiltonian
- Rimu.Hamiltonians.SingleParticleExcitation
- Rimu.Hamiltonians.Stoquastic
- Rimu.Hamiltonians.StringCorrelator
- Rimu.Hamiltonians.SuperfluidCorrelator
- Rimu.Hamiltonians.TimeReversalSymmetry
- Rimu.Hamiltonians.Transcorrelated1D
- Rimu.Hamiltonians.TransformUndoer
- Rimu.Hamiltonians.TwoParticleExcitation
- Rimu.Hamiltonians.HardwallBoundaries
- Rimu.Hamiltonians.LadderBoundaries
- Rimu.Hamiltonians.PeriodicBoundaries
- Rimu.Hamiltonians.continuum_dispersion
- Rimu.Hamiltonians.flip_spin_components
- Rimu.Hamiltonians.hubbard_dispersion
- Rimu.Hamiltonians.is_invalid_state
- Rimu.Hamiltonians.is_void_state
- Rimu.Hamiltonians.linear_to_state
- Rimu.Hamiltonians.momentum
- Rimu.Hamiltonians.neighbor_site
- Rimu.Hamiltonians.one_electron_diagonal
- Rimu.Hamiltonians.rayleigh_quotient
- Rimu.Hamiltonians.shift_lattice
- Rimu.Hamiltonians.shift_lattice_inv
- Rimu.Hamiltonians.two_electron_diagonal
- Rimu.Hamiltonians.unrank_combination