Developer Documentation
Module Hamiltionians.jl
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 LinearOperator, in the spirit of the AbstractArray interface as discussed in the Julia Documentation.
Rimu.Hamiltonians — ModuleThis module defines Hamiltonian types and standard methods. Model Hamiltonians should be subtyped to LinearOperator. Models implemented so far are:
BoseHubbardReal1DBose-Hubbard chain, real spaceExtendedBHReal1Dextended Bose-Hubbard model with on-site and nearest neighbour interactions, real space, one dimension
Relation to other parts of the Rimu code
In order to define a specific model Hamiltonian with relevant parameters for the model, instantiate the model like this in the input file:
ham = BoseHubbardReal1D(n=6, m=6, u=1.0, t=1.0, AT = BSAdd64)
In the rest of the Rimu code, access to properties and matrix elements of the model are then provided by the following methods:
ham[address1, address2]: indexing of matrix elements (slow - use with caution)ham(dv::AbstractDVec)ormul!(dv1, ham, dv2): use as linear operatordiagME(ham, add): diagonal matrix elementnumOfHops(ham, add): number of off-diagonalshop(ham, add, chosen): access off-diagonal matrix elementHops(ham, add): iterator over off-diagonal matrix elementsgenerateRandHop(hops::Hops): choose random off-diagonalbit_String_Length(ham): number of bits in the configurationham(:dim)andham(:fdim): dimension of linear space. SeehasIntDimension(ham),dimensionLO(ham),fDimensionLO(ham)nearUniform(ham): configuration with particles spread across modes
Model Hamiltonians
Here is a list of fully implemented model Hamiltonians. So far there are two variants implemented of the Bose-Hubbard model in one dimensional in real space.
Rimu.Hamiltonians.BoseHubbardReal1D — Typeham = BoseHubbardReal1D(;[n=6, m=6, u=1.0, t=1.0, AT = BSAdd64])Implements a one-dimensional Bose Hubbard chain in real space.
Arguments
n::Int: the number of bosonsm::Int: the number of lattice sitesu::Float64: the interaction parametert::Float64: the hopping strengthAT::Type: the address type
Functor use:
w = ham(v)
ham(w, v)Compute the matrix - vector product w = ham * v. The two-argument version is mutating for w.
ham(:dim)Return the dimension of the linear space if representable as Int, otherwise return nothing.
ham(:fdim)Return the approximate dimension of linear space as Float64.
Rimu.Hamiltonians.ExtendedBHReal1D — Typeham = ExtendedBHReal1D(n=6, m=6, u=1.0, v=1.0, t=1.0, AT=BSAdd64)Implements the extended Bose Hubbard model on a one-dimensional chain in real space.
Arguments
n::Int: number of bosonsm::Int: number of lattice sitesu::Float64: on-site interaction parameterv::Float64: the next-neighbor interactiont::Float64: the hopping strengthAT::Type: address type for identifying configuration
Hamiltonians interface
Behind the implementation of a particular model is a more abstract interface for defining hamiltonians. If you want to define a new model you should make use of this interface. The most general form of a model Hamiltonian should subtype to LinearOperator and implement the relevant methods.
Rimu.Hamiltonians.LinearOperator — TypeLinearOperator{T}Supertype that provides and interface for linear operators over T that are suitable for FCIQMC. Indexing is done with addresses from a linear space that may be large (and will not need to be completely generated).
Provides:
Hops: iterator over reachable off-diagonal matrix elementsgenerateRandHop: function to generate random off-diagonal matrix elementhamiltonian[address1, address2]: indexing withgetindex()- mostly for testing purposes*(LO, v)deterministic matrix-vector multiply (== LO(v))mul!(w, LO, v)mutating matrix-vector multiplydot(x, LO, v)computex⋅(LO*v)minimizing allocations
Methods that need to be implemented:
numOfHops(lo::LinearOperator, address)hop(lo::LinearOperator, address, chosen::Integer)diagME(lo::LinearOperator, address)hasIntDimension(lo::LinearOperator)dimensionLO(lo::LinearOperator), if applicablefDimensionLO(lo::LinearOperator)
Optional:
Rimu.Hamiltonians.Hops — TypeHops(ham, add)Iterator over new address and matrix element for reachable off-diagonal matrix elements of linear operator ham from address add. Represents an abstract vector containing the possibly non-zero off-diagonal matrix elements of the column of ham indexed by add.
Examples
new_address, matrix_element = Hops(ham, current_address)[i]
number_of_hops = length(Hops(ham, current_address))
for (add,elem) in Hops(ham, current_address)
# do something with address and elem
endRimu.Hamiltonians.generateRandHop — FunctiongenerateRandHop(ham, add)
generateRandHop(hops::Hops)Generate a single random excitation, i.e. choose from one of the accessible off-diagonal elements in the column corresponding to address add of the Hamiltonian matrix represented by ham. Alternatively, pass as argument an iterator over the accessible matrix elements.
Core functions
The following functions are part of the core functionality of a Hamiltonian and need to be implemented efficiently and specifically for each model.
Rimu.Hamiltonians.numOfHops — FunctionnumOfHops(ham, add)Compute the number of number of reachable configurations from address add.
Rimu.Hamiltonians.hop — Functionnewadd, me = hop(ham, add, chosen)Compute matrix element of hamiltonian and new address of a single hop from address add with integer index chosen.
Rimu.Hamiltonians.diagME — FunctiondiagME(ham, add)Compute the diagonal matrix element of the linear operator ham at address add.
BosonicHamiltonian
For a many-body system consisting of spinless bosons, we already know more about the structure of the problem. BosonicHamiltonian is a pre-defined subtype of LinearOperator.
Rimu.Hamiltonians.BosonicHamiltonian — TypeBosonicHamiltonian{T} <: LinearOperator{T}Abstract type for representing Hamiltonians in a Fock space of fixed number of scalar bosons. At least the following fields should be present:
n # number of particlesm # number of modesAT # address type
Methods that need to be implemented:
numOfHops(lo::LinearOperator, address)- number of off-diagonal matrix elementshop(lo::LinearOperator, address, chosen::Integer)- access an off-diagonal m.e. by indexchosendiagME(lo::LinearOperator, address)- diagonal matrix element
Optional:
Hamiltonians.LOStructure(::Type{typeof(lo)})- can speed up deterministic calculations ifHermitianLO
Provides:
hasIntDimension(lo::LinearOperator)dimensionLO(lo::LinearOperator), might fail if linear space too largefDimensionLO(lo::LinearOperator)bit_String_LengthnearUniform, default version
Rimu.Hamiltonians.hasIntDimension — FunctionhasIntDimension(ham)Return true if dimension of the linear operator ham can be computed as an integer and false if not.
If true, dimensionLO(h) will be successful and return an Int. The method fDimensionLO(h) should be useful in other cases.
Rimu.Hamiltonians.dimensionLO — FunctiondimensionLO(hamiltonian)Compute dimension of linear operator as integer.
Rimu.Hamiltonians.fDimensionLO — FunctionfDimensionLO(hamiltonian)Returns the dimension of Hilbert space as Float64. The exact result is returned if the value is smaller than 2^53. Otherwise, an improved Stirling formula is used.
Rimu.Hamiltonians.bit_String_Length — Functionbit_String_Length(ham)Number of bits needed to represent an address for the linear operator ham.
Rimu.BitStringAddresses.nearUniform — FunctionnearUniform(N, M) -> onr::SVector{M,Int}Create occupation number representation onr distributing N particles in M modes in a close-to-uniform fashion with each orbital filled with at least N ÷ M particles and at most with N ÷ M + 1 particles.
nearUniform(BoseFS{N,M})
nearUniform(BoseFS{N,M,A}) -> bfs::BoseFS{N,M,A}Create bosonic Fock state with near uniform occupation number of M modes with a total of N particles. Specifying the bit address type A is optional.
Examples
julia> nearUniform(BoseFS{7,5,BitAdd})
BoseFS{BitAdd}((2,2,1,1,1))
julia> nearUniform(BoseFS{7,5})
BoseFS{BSAdd64}((2,2,1,1,1))nearUniform(ham)Create bitstring address with near uniform distribution of particles across modes for the Hamiltonian ham.