API

Rimu

Rimu.RimuModule
Rimu

Random Integrator for Many-Body Quantum Systems

source
Rimu.DelayedLogUpdateType
DelayedLogUpdate(ζ = 0.3, a = 10) <: ShiftStrategy

Strategy for updating the shift according to the log formula with damping parameter ζ and delay of a steps.

\[S^{n+a} = S^n -\frac{ζ}{a dτ}\ln\left(\frac{\|Ψ\|_1^{n+a}}{\|Ψ\|_1^n}\right)\]
source
Rimu.DelayedLogUpdateAfterTargetWalkersType
DelayedLogUpdateAfterTargetWalkers(targetwalkers, ζ = 0.3, a = 10) <: ShiftStrategy

Strategy for updating the shift: After targetwalkers is reached, update the shift according to the log formula with damping parameter ζ and delay of a steps. See DelayedLogUpdate.

source
Rimu.DeltaMemoryType
DeltaMemory(Δ::Int) <: MemoryStrategy

Before updating the shift, memory noise with a memory length of Δ is applied, where Δ = 1 means no memory noise.

r̃ = (pnorm - tnorm)/(dτ*pnorm) + shift
r = r̃ - <r̃>
source
Rimu.DoubleLogUpdateType
DoubleLogUpdate(targetwalkers, ζ = 0.3, ξ = 0.0225) <: ShiftStrategy

Strategy for updating the shift according to the log formula with damping parameter ζ and ξ.

\[S^{n+1} = S^n -\frac{ζ}{dτ}\ln\left(\frac{\|Ψ\|_1^{n+1}}{\|Ψ\|_1^n}\right)\frac{ζ}{dτ}\ln\left(\frac{\|Ψ\|_1^{n+1}}{\|Ψ\|_1^\text{target}}\right)\]
source
Rimu.DoubleLogUpdateAfterTargetWalkersType
LogUpdateAfterTargetWalkers(targetwalkers, ζ = 0.3, ξ = 0.0225) <: ShiftStrategy

Strategy for updating the shift: After targetwalkers is reached, update the shift according to the log formula with damping parameter ζ and ξ. See DoubleLogUpdate.

source
Rimu.HistoryLogUpdateType
HistoryLogUpdate(df::DataFrame; d = 100, k=1, ζ= 0.3)

Strategy for updating the shift according to log formula but with walker numbers accumulated from k samples of the history with delay d. A recent history has to be passed with the data frame df for initialisation.

\[N_w^{n} = \sum_{i=0}^{k-1} \|Ψ\|_1^{n-i} \\ S^{n+a} = S^n -\frac{ζ}{a dτ}\ln\left(\frac{N_w^{n+1}}{N_w^n}\right)\]
source
Rimu.IsStochasticWithThresholdType
IsStochasticWithThreshold(threshold::Float16)

Trait for generalised vector of configurations indicating stochastic propagation with real walker numbers and cutoff threshold.

> StochasticStyle(V) = IsStochasticWithThreshold(threshold)

During stochastic propoagation, walker numbers small than threshold will be stochastically projected to either zero or threshold.

source
Rimu.LogUpdateType
LogUpdate(ζ = 0.3) <: ShiftStrategy

Strategy for updating the shift according to the log formula with damping parameter ζ.

\[S^{n+1} = S^n -\frac{ζ}{dτ}\ln\left(\frac{\|Ψ\|_1^{n+1}}{\|Ψ\|_1^n}\right)\]
source
Rimu.LogUpdateAfterTargetWalkersType
LogUpdateAfterTargetWalkers(targetwalkers, ζ = 0.3) <: ShiftStrategy

Strategy for updating the shift: After targetwalkers is reached, update the shift according to the log formula with damping parameter ζ. See LogUpdate.

source
Rimu.MPIDataType

Simple wrapper used for signaling that this data is part of a distributed data structure and communication should happen with MPI.

source
Rimu.MPIDefaultType
MPIDefault(nprocs, my_rank, comm)

Strategy for point-to-point MPI communication.

source
Rimu.MPIOSWinType
MPIOSWin(nprocs, myrank, comm, ::Type{T}, capacity)

Communication buffer for use with MPI one-sided communication (remote memory access). Up to capacity elements of type T can be exchanged between MPI ranks via put. It is important that isbitstype(T) == true. Objects of type MPIOSWin have to be freed manually with a (blocking) call to free().

source
Rimu.ReportDFAndInfoType
ReportDFAndInfo(; k=10, i=100, io=stdout, writeinfo=true)

Report every kth step in DataFrame and write info message to io every ith step (unless writeinfo == false). The flag writeinfo is useful for controlling info messages in MPI codes.

source
Rimu.RunTillLastStepType
RunTillLastStep(step::Int = 0 # number of current/starting timestep
             laststep::Int = 50 # number of final timestep
             shiftMode::Bool = false # whether to adjust shift
             shift::Float64 = 0.0 # starting/current value of shift
             dτ::Float64 = 0.01 # current value of time step
) <: FciqmcRunStrategy

Parameters for running fciqmc!() for a fixed number of time steps. For alternative strategies, see FciqmcRunStrategy.

source
Rimu.ScaledThresholdProjectType
ScaledThresholdProject(threshold = 1.0) <: ProjectStrategy

Project stochastically for walker amplitudes below threshold and scale configuration array as to keep the norm constant. As a consequence, the final configuration amplitudes may be smaller than threshold. See norm_project.

source
Rimu.ShiftMemoryType
ShiftMemory(Δ::Int) <: MemoryStrategy

Effectively replaces the fluctuating shift update procedure for the coefficient vector by an averaged shift over Δ timesteps, where Δ = 1 means no averaging.

source
Rimu.StochasticStyleType
StochasticStyle(v)
StochasticStyle(typeof(v))

StochasticStyle specifies the native style of the generalised vector v that determines how simulations are to proceed. This can be fully stochastic (with IsStochastic), fully deterministic (with IsDeterministic), or semistochastic (with IsSemistochastic).

source
Rimu.fciqmc!Function
fciqmc!(v, pa::FciqmcRunStrategy, [df,]
         ham, s_strat::ShiftStrategy,
         [r_strat::ReportingStrategy, τ_strat::TimeStepStrategy, w])
-> df

Perform the FCIQMC algorithm for determining the lowest eigenvalue of ham. v can be a single starting vector of type :<AbstractDVec or a vector of such structures. In the latter case, independent replicas are constructed. Returns a DataFrame df with statistics about the run, or a tuple of DataFrames for a replica run. Strategies can be given for updating the shift (see ShiftStrategy) and (optionally), for reporting (see ReportingStrategy), and for updating the time step (see TimeStepStrategy).

A pre-allocated data structure w for working memory can be passed as argument, and controls multi-threading behaviour. By default multi-threading is turned on. To turn multi-threading off, pass similar(localpart(v)) for w.

This function mutates v, the parameter struct pa as well as df, and w.

source
Rimu.freeMethod
free(obj::MPIOSWin)

De-reference the object, call finalizer and the garbage collector immediately. This is a syncronizing MPI call. Make sure that the object is not used later.

source
Rimu.mpi_defaultFunction
mpi_default(data, comm = MPI.COMM_WORLD, root = 0)

Declare data as mpi-distributed and set communication strategy to default. Sets up the MPIData structure with MPIDefault strategy.

source
Rimu.mpi_one_sidedFunction
mpi_one_sided(data, comm = MPI.COMM_WORLD, root = 0)

Declare data as mpi-distributed and set communication strategy to one-sided with remote memory access (RMA). Sets up the MPIData structure with MPIOSWin strategy.

source
Rimu.putMethod
put(buf::Vector{T}, [len,] targetrank, s::MPIOSWin{T})
put(obj::T, targetrank, s::MPIOSWin{T})

Deposit a single obj or vector buf into the MPI window s on rank targetrank. If len is given, only the first len elements are transmitted.

source
Rimu.targetrankFunction
targetrank(key, np, hash = hash(key))

Compute the rank where the key belongs.

source
Rimu.DeltaMemory2Type
DeltaMemory2(Δ::Int) <: MemoryStrategy

Before updating the shift, memory noise with a memory length of Δ is applied, where Δ = 1 means no memory noise.

r̃ = pnorm - tnorm + shift*dτ*pnorm
r = (r̃ - <r̃>)/(dτ*pnorm)

The long-term average of r is not guaranteed to be zero.

source
Rimu.IsSemistochasticType
IsSemistochastic(threshold::Float16, d_space)

Trait for generalised vector of configurations indicating semistochastic propagation. Set with setSemistochastic!.

> StochasticStyle(V) = IsSemistochastic(threshold, d_space)

where d_space is a vector of addresses defining the the stochastic subspace.

source
Rimu.MPINoWalkerExchangeType
MPINoWalkerExchange(nprocs, my_rank, comm)

Strategy for for not exchanging walkers between ranks. Consequently there will be no cross-rank annihilations.

source
Base.lengthMethod
length(md::MPIData)

Compute the length of the distributed data on every MPI rank with MPI.Allreduce.

source
LinearAlgebra.normFunction
norm(md::MPIData, p=2)

Compute the norm of the distributed data on every MPI rank with MPI.Allreduce.

source
Rimu.applyMemoryNoise!Method
applyMemoryNoise!(w, v, shift, dτ, pnorm, m_strat::MemoryStrategy)

Apply memory noise to w according to the strategy m_strat. Note that the strategy needs to be compatible with StochasticStyle(w). The default is to not add memory noise. See MemoryStrategy.

w is the walker array after fciqmc step, v the previous one, pnorm the norm of v.

source
Rimu.fciqmc_col!Method
fciqmc_col!(w, ham, add, num, shift, dτ)
fciqmc_col!(::Type{T}, args...)
-> spawns, deaths, clones, antiparticles, annihilations

Spawning and diagonal step of FCIQMC for single column of ham. In essence it computes

w .+= (1 .+ dτ.*(shift .- ham[:,add])).*num.

Depending on T ==StochasticStyle(w), a stochastic or deterministic algorithm will be chosen. The possible values for T are:

source
Rimu.fciqmc_step!Method
fciqmc_step!(Ĥ, v, shift, dτ, pnorm, w;
                      m_strat::MemoryStrategy = NoMemory()) -> ṽ, w̃, stats

Perform a single matrix(/operator)-vector multiplication:

\[\tilde{v} = [1 - dτ(\hat{H} - S)]⋅v ,\]

where Ĥ == ham and S == shift. Whether the operation is performed in stochastic, semistochastic, or determistic way is controlled by the trait StochasticStyle(w). See StochasticStyle. w is a local data structure with the same size and type as v and used for working. Both v and w are modified.

Returns the result , a (possibly changed) reference to working memory , and the array stats = [spawns, deaths, clones, antiparticles, annihilations]. Stats will contain zeros when running in deterministic mode.

source
Rimu.next_mpiIDFunction
next_mpiID()

Produce a new ID number for MPI distributed objects. Uses an internal counter.

source
Rimu.norm_project!Method
norm_project!(w, p_strat::ProjectStrategy) -> norm

Computes the 1-norm of w. Project all elements of w to s.threshold preserving the sign if StochasticStyle(w) requires projection according to p_strat. See ProjectStrategy.

source
Rimu.report!Method
report!(df::DataFrame, t::Tuple, s<:ReportingStrategy)

Record results in df and write informational messages according to strategy s. See ReportingStrategy.

source
Rimu.setSemistochastic!Method
setSemistochastic!(dv, threshold::Float16, d_space)

Set the deterministic space for dv with threshold threshold, where d_space is a vector of addresses defining the the stochastic subspace.

source
Rimu.sort_into_targets!Method
sort_into_targets!(target, source, stats) -> agg, wm, agg_stats

Aggregate coefficients from source to agg and from stats to agg_stats according to thread- or MPI-level parallelism. wm passes back a reference to working memory.

source
Rimu.sort_into_targets!Method
sort_into_targets!(target::MPIData, source)

Distribute the entries of source to the target data structure such that all entries in the target dictionaries are on the process with the correct rank as controlled by targetrank().

source
Rimu.update_dτMethod
update_dτ(s<:TimeStepStrategy, dτ, args...) -> new dτ

Update the time step according to the strategy s.

source

Reexported Submodules

Hamiltonians

Link to Module Hamiltionians.jl

BitStringAddresses

Rimu.BitStringAddresses.BitAddType
BitAdd{I,B} <: BitStringAddressType
BitAdd(address::Integer, B)
BitAdd(chunks::T, B) where T<:Union{Tuple,SVector}
BitAdd{B}(address)

Address type that encodes a bistring address with B bits. The bits are stored efficiently as SVector of I chunks of type UInt64. The two-argument constructor is preferred due to safety (consistency checks). In hot loops there maybe gain from the (unsafe) parametric constructor. If an integer address is passed, its bit representation is used to initialize BitAdd. For large bit numbers, BigInt is convenient. BitAdd[i] will return bit i (as Bool), counting from right to left.

  • BitAdd{B}() creates a BitAdd with all ones.
  • zero(BitAdd{B}) creates a BitAdd with all zeros.

Note that no checking for ghost bits occurs when constructing BitAdd from SVector or Tuple. See bitadd(), check_consistency(), and remove_ghost_bits() methods!

source
Rimu.BitStringAddresses.BitStringAddressTypeType
BitStringAddressType

Abstract type for configuration addresses with the nature of a bitstring. A number of methods need to be implemented, in particular Base.isless(a,b), numBits(), numChunks().

source
Rimu.BitStringAddresses.BoseFSType
BoseFS{N,M,A} <: BosonicFockStateAddress <: BitStringAddressType
BoseFS(bs::A) where A <: BitAdd
BoseFS(bs::A, b)

Address type that represents a Fock state of N spinless bosons in M orbitals by wrapping a bitstring of type A. Orbitals are stored in reverse order, i.e. the first orbital in a BoseFS is stored rightmost in the bitstring bs. If the number of significant bits b is not encoded in A it must be passed as an argument (e.g. for BSAdd64 and BSAdd128).

source
Rimu.BitStringAddresses.BoseFSMethod
BoseFS(onr::T) where T<:Union{AbstractVector,Tuple}
BoseFS{BST}(onr::T)

Create BoseFS address from an occupation number representation, specifying the occupation number of each orbital. If a type BST is given it will define the underlying bit string type. Otherwise, the bit string type is chosen to fit the onr.

source
Rimu.BitStringAddresses.bitaddrMethod
bitaddr(onr, Type)

Calculate a bitstring address from an occupation number representation the type of the bitstring address is passed as the second argument.

source
Rimu.BitStringAddresses.nearUniformMethod
nearUniform(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.

source
Rimu.BitStringAddresses.nearUniformMethod
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))
source
Rimu.BitStringAddresses.onrMethod
onr(address, m)

Compute and return the occupation number representation as an array of Int corresponding to the given address.

source
Rimu.BitStringAddresses.onrMethod
onr(bs)

Compute and return the occupation number representation of the bit string address bs as an SVector{M,Int}, where M is the number of orbitals.

source
Base.:<<Method
<<(b::BitAdd,n::Integer)

Bitshift b to the left by n bits and fill from the right with zeros.

source
Base.:>>>Method
>>>(b::BitAdd,n::Integer)

Bitshift b to the right by n bits and fill from the left with zeros.

source

DictVectors

Rimu.DictVectorsModule

Module that provides data structures that behave similar to sparse vectors, but are indexed by arbitrary types (could be non-integers) similarly to dictionaries. The idea is to do linear algebra with data structures that are neither subtyped to AbstractVector nor to AbstractDict and are suitable for use with KrylovKit.jl. For this, the abstract type and interface AbstractDVec is provided, with the following concrete subtypes:

source
Rimu.DictVectors.AbstractDVecType
DictVectors.AbstractDVec{K,V}

Abstract type for sparse vectors with valtype() V based on dictionary-like structures. They behave like vectors except that indexing is performed with an arbitrary keytype() K (no order required). getindex() returns zero(V) for any unknown key and zeroed elements should be deleted with delete!(). Thus, iteration typically returns only non-zero entries. In variance to AbstractVector, length() will return the number of non-zero elements, while capacity() returns the holding capacity (assumed fixed) of the object. Even though AbstractDVec is similar to both AbstractDict and AbstractVector, it is explicitly not subtyped to either. The aim is to create data structures suitable for FCIQMC and compatible with KrylovKit.jl.

Interface

The interface is similar to the AbstractDict interface. Implement what would be needed for the AbstractDict interface (setindex!, getindex, delete!, length, haskey, empty!, isempty) and, in addition:

  • capacity(dv): holding capacity
  • similar(dv [,Type])
  • iterate(): should return values of type V
  • pairs(): should return an iterator over key::K => content pairs. If content ≠ value::V the provide values() iterator as well!
source
Rimu.DictVectors.DFVecType
DFVec{K,V,F}(capacity) <: AbstractDVec{K,V <: Number}
DFVec(d::Dict [, capacity])
DFVec(v::Vector{V} [, capacity])

Construct a wrapped dictionary with minimum capacity capacity to represent a vector-like object with valtype(dv) == V. The value of the Dict are of type Tuple{V,F}, which allows for storing a flag of type F for each entry. Indexing is done with an arbitrary (in general non-integer) keytype(dv) == K. When constructed from a Vector{V}, the keys will be integers ∈ [1, length(v)] and the flag zero(UInt16). See AbstractDVec. The method capacity() is defined but not a strict upper limit as Dict objects can expand.

source
Rimu.DictVectors.DVecType
DVec{K,T}(capacity) <: AbstractDVec{K,T}
DVec(d::Dict [, capacity])
DVec(v::Vector{T} [, capacity])

Construct a wrapped dictionary with minimum capacity capacity to represent a vector-like object with eltype(dv) == T, which corresponds to the values of the Dict. Indexing is done with an arbitrary (in general non-integer) keytype(dv) == K. When constructed from a Vector, the keys will be integers ∈ [0, length(v)]. See AbstractDVec. The method capacity() is defined but not a strict upper limit as Dict objects can expand.

source
Rimu.DictVectors.FastDVecType
DictVectors.FastDVec{K,V}(capacity)

Create a dictionary-like array indexed by keys of type K and values of type V with a maximum capacity of capacity.

FastDVec(a::AbstractArray, [capacity = length(a)])
FastDVec(d::AbstractDict{K,V}, [capacity = length(d)])
FastDVec(d::AbstractDVec{K,V}, [capacity = length(d)])

Construct a FastDVec object from an existing array or dictionary.

source
Rimu.DictVectors.NormProjectorType
NormProjector()

Results in computing the one-norm when used in dot(). E.g.

dot(NormProjector(),x)
-> norm(x,1) # with type valtype(x)

NormProjector() thus represents the vector sign.(x).

source
Rimu.DictVectors.UniformProjectorType
UniformProjector()

Represents a vector with all elements 1. To be used with dot(). Minimizes memory allocations.

UniformProjector()⋅v == sum(v)
dot(UniformProjector(), LO, v) == sum(LO*v)
source
Rimu.DictVectors.capacityFunction
DictVectors.capacity(dv::AbstractDVec, [s = :effective])
capacity(dvs::Tuple, [s = :effective])

gives the effective holding capacity of dv. If a tuple of dvs is given it aggregates the capacities.

Optional argument s:

  • :effective the number of elements that

can be stored savely (default)

  • :allocated actual internal memory allocation
source
Rimu.DictVectors.gettupleMethod
gettuple(dv::DFVec, key)

Retrieve the tuple (v,f) stored at the given key. If the key is not found, return a tuple of zeros.

source
Rimu.DictVectors.kvpairsMethod
kvpairs(collection)

Return an iterator over key => value pairs ignoring any flags. If no flags are present, eg. for generic AbstractDVec, this falls back to Base.pairs.

source
Rimu.DictVectors.kvpairsMethod
kvpairs(dv::DFVec)

An iterator that yields key => value pairs stored in the DFVec dv ignoring any flags. In contrast, Base.pairs() will return pairs key => (value, flag).

source
Rimu.DictVectors.zero!Method
zero!(v::AbstractDVec)

Replace v by a zero vector as an inplace operation. For AbstractDVec types it means removing all non-zero elements.

source
Base.fill!Method
fill!(da::AbstractDVec, x)

Empties da if x==zero(valtype(da)) and throws an error otherwise.

source
Base.getMethod
get(dv::DFVec, key, deftup::Tuple)

Return tuple containing value and flag if key exists and otherwise deftup.

source
Base.getMethod
get(dv::DFVec, key, defnum::Number)

Return value only if key exists and otherwise defnum

source
Base.isequalMethod
isequal(l::AbstractDVec, r::AbstractDVec)

Returns true if all non-zero entries have the same value. Equality of flags is not tested unless both l and r support flags.

source
Base.isequalMethod
isequal(l::DFVec, r::DFVec)

Returns true if all non-zero entries have the same value and the same flag.

source
LinearAlgebra.axpy!Method
axpy!(α::Number, X::AbstractDVec, Y::AbstractDVec)
axpy!(α::Number, X::AbstractDVec, Ys::Tuple, batchsize)

Overwrite Y with α*X + Y where α is scalar for AbstractDVecs. If a tuple Ys is passed with Threads.nthreads() AbstractDVecs, then perform the operation in parallel over threads with batchsize elements at a time.

source
LinearAlgebra.normMethod
norm(x::AbstractDVec, p)

Computes the p-norm of the DVec x. Implemented for p ∈ {1, 2, Inf}. Returns zero if x is empty.

source

Blocking

Rimu.BlockingModule

Blocking

Module that contains functions performing the Flyvbjerg-Petersen blocking analysis for evaluating the standard error on a correlated data set.

source
Rimu.Blocking.blockingErrorEstimationMethod

estimating stnadard error from blocking analysis based on the overlapping of error bars, if all the error bars (or more than 3 on a roll) behind current one are overlapping with it, return the current standard error with error bar.

source
Rimu.Blocking.mtestMethod

The "M test" based on Jonsson, M. Physical Review E, 98(4), 043304, (2018). If the blocking analysis (BA) has passed the M test, an error estimation will be given based on the smallest k (i.e. meaningful results at the k-th data point on a BA plot).

source

Unexported Submodules

FastBufs

Rimu.FastBufs.FastBufType
FastBuf{T}(n)

Create a first-in-last-out buffer of maximum capacity n. The element type is T. Fill a FastBuf with push!(), retrieve with pop!(). Accessing elements with getindex() and setindex!() as well as iteration are also supported. Check the capacity of a FastBuf with capacity().

source

ConsistentRNG

Link to Module ConsistentRNG.jl

Index