Other Extensions
Apart from ITensor extension, FuzzifiED also provides other extensions, viz. HDF5 extension, KrylovKit extension, CUDA extension and SparseArrays extension.
HDF5 Extension
The HDF5 extension supports writing the types Confs, Basis, Terms, Operator, OpMat{ComplexF64} and OpMat{Float64} into HDF5 files and reading them from groups and subgroups in HDF5 format. This extension requires the packages HDF5. To use this extension, include at the heading
using HDF5A typical file operation process looks like
f = h5open(file_name, "cw")
# include the file name as a string
# Modes : "cw" for write and "r" for read
...
close(f)To write, include in the middle
write(f, group_name :: String, cfs :: Confs)
write(f, group_name :: String, bs :: Basis)
write(f, group_name :: String, tms :: Terms)
write(f, group_name :: String, op :: Operator)
write(f, group_name :: String, mat :: OpMat{ComplexF64})
write(f, group_name :: String, mat :: OpMat{Float64})To read, include in the middle
cfs = read(f, group_name :: String, Confs)
bs = read(f, group_name :: String, Basis)
tms = read(f, group_name :: String, Terms)
op = read(f, group_name :: String, Operator)
mat = read(f, group_name :: String, OpMat{ComplexF64})
mat = read(f, group_name :: String, OpMat{Float64})SparseArrays Extension
The SparseArrays extension supports the conversion between OpMat in FuzzifiED and the SparseMatrixCSC format. This extension requires the packages SparseArrays. To use this extension, include at the heading
using SparseArraysSparseArrays.SparseMatrixCSC — MethodSparseMatrixCSC(mat :: OpMat{ComplexF64}) :: SparseMatrixCSC{Int64,ComplexF64}
SparseMatrixCSC(mat :: OpMat{Float64}) :: SparseMatrixCSC{Int64,Float64}converts the OpMat objects to a SparseMatrixCSC object in the SparseArrays package.
FuzzifiED.OpMat — MethodOpMat(matcsc :: SparseMatrixCSC{Int64,ComplexF64}) :: OpMat{ComplexF64}
OpMat(matcsc :: SparseMatrixCSC{Int64,Float64}) :: OpMat{Float64}converts the SparseMatrixCSC object in the SparseArrays package to an OpMat objects.
KrylovKit Extension
The KrylovKit extension supports an interface diagonalising the sparse matrix using the KrylovKit pakage in Julia. This extension requires the packages KrylovKit. To use this extension, include at the heading
using KrylovKitBesides Arpack in Fortran, we also provide an interface calling KrylovKit in Julia.
FuzzifiED.GetEigensystemKrylov — MethodGetEigensystemKrylov(mat :: OpMat{ComplexF64}, nst :: Int64 ; initvec :: Vector{ComplexF64}, num_th :: Int64, disp_std :: Bool, kwargs...) :: Tuple{Vector{ComplexF64}, Matrix{ComplexF64}}
GetEigensystemKrylov(mat :: OpMat{Float64}, nst :: Int64 ; initvec :: Vector{Float64}, num_th :: Int64, disp_std :: Bool, kwargs...) :: Tuple{Vector{Float64}, Matrix{Float64}}This method calls the eigsolve from Julia KrylovKit.jl package instead of Arpack from Fortran to calculate the lowest eigenstates of sparse matrix. The performance should be similar. For an example, refer to ising_spectrum_krylov.jl.
Arguments
mat :: OpMat{ComplexF64}ormat :: OpMat{Float64}is the matrix.nst :: Int64is the number of eigenstates to be calculated.tol :: Float64is the tolerence for the KrylovKit process. The default value is1E-8.ncv :: Int64is the maximum dimension of the Krylov subspace. The default value ismax(2 * nst, nst + 10). Ifkrylovdimis also given,ncvwill not be used.initvec :: Vector{ComplexF64}orinitvec :: Vector{Float64}is the initial vector. Facultative, a random initialisation by default.num_th :: Int64, the number of threads. Facultative,NumThreadsby default.disp_std :: Bool, whether or not the log shall be displayed. Facultative,!SilentStdby default.kwargs...is the options that will directly sent intoeigsolve, see its documentation for detail.
Output
- A length-
nstarray that has the same type asmatrecording the eigenvalues, and - A
dimd×nstmatrix that has the same type asmatwhere every column records an eigenstate.
Modified Version of KrylovKit
We have forked KrylovKit and made some modifications to better suit our need. To install the modified packages, please use
using Pkg
Pkg.add(url="https://github.com/FuzzifiED/KrylovKit.jl.git")We add an algorithm LockedLanczos. It is a hard-locking (deflated) variant of the Lanczos algorithm that is useful when large number of eigenvectors (e. g. in the order of 1000) are required, for use in eigsolve with a real symmetric or complex Hermitian linear operator. Whenever a Ritz pair has converged to within a tolerence, it is locked, i. e. removed from the active Krylov subspace, but retained in the set against which every subsequent Krylov vector is orthogonalized.
CUDA Extension
The CUDA extension supports the conversion between OpMat in FuzzifiED and the CuSparseMatrixCSC in CUDA.CUSPARSE as well as the acceleration of diagonalisation on GPU. This extension requires the packages CUDA, KrylovKit and SparseArrays. To use this extension, include at the heading
using CUDA, KrylovKit, SparseArraysCUDA.CUSPARSE.CuSparseMatrixCSC — MethodCUSPARSE.CuSparseMatrixCSC(mat :: OpMat{ComplexF64})
CUSPARSE.CuSparseMatrixCSC(mat :: OpMat{Float64})converts the OpMat objects to a CuSparseMatrixCSC object in the CUDA.CUSPARSE package.
FuzzifiED.GetEigensystemCuda — MethodGetEigensystemCuda(mat :: OpMat{ComplexF64}, nst :: Int64 ; initvec :: Vector{ComplexF64}, num_th :: Int64, disp_std :: Bool, kwargs...) :: Tuple{Vector{ComplexF64}, CuArray{ComplexF64, 2, CUDA.DeviceMemory}}
GetEigensystemCuda(mat :: OpMat{Float64}, nst :: Int64 ; initvec :: Vector{Float64}, num_th :: Int64, disp_std :: Bool, kwargs...) :: Tuple{Vector{Float64}, CuArray{Float64, 2, CUDA.DeviceMemory}}This method uses Julia KrylovKit package to calculate the lowest eigenstates of sparse matrix. The sparse matrix multiplication is realised by CUDA.CUSPARSE. For an example, refer to ising_spectrum_cuda.jl.
Arguments
mat :: OpMat{ComplexF64}ormat :: OpMat{Float64}is the matrix.nst :: Int64is the number of eigenstates to be calculated.tol :: Float64is the tolerence for the KrylovKit process. The default value is1E-8.ncv :: Int64is the maximum dimension of the Krylov subspace. The default value ismax(2 * nst, nst + 10). Ifkrylovdimis also given,ncvwill not be used.initvecis the initial vector. Facultative, a random initialisationCUDA.rand(T, mat.dimd)by default.disp_std :: Bool, whether or not the log shall be displayed. Facultative,!SilentStdby default.kwargs...is the options that will directly sent intoeigsolve, see its documentation for detail.
Output
- A length-
nstarray that has the same type asmatrecording the eigenvalues, and - A
dimd×nstmatrix that has the same type asmatwhere every column records an eigenstate.