ITensor extension
FuzzifiED also supports an ITensor extension, including convertion with the Site and OpSum objects from ITensor library and management of DMRG sweeping process. To use the extension, make sure the packages ITensors, ITensorMPS are properly installed, and include
using ITensors, ITensorMPSat the heading of the Julia script.
During intialisation, the optimal configuration for parallelisation is already automatically set.
BLAS.set_num_threads(1);
NDTensors.Strided.disable_threads();
ITensors.enable_threaded_blocksparse();Format conversion
FuzzyfiED defines a new SityType "FuzzyFermion" that can be initialised from QNDiags to avoid overwriting the original "Fermion" type.
ITensors.space — MethodITensors.space( :: SiteType"FuzzyFermion" ; o :: Int, qnd :: Vector{QNDiag})Define a new site type "FuzzyFermion" which inherits all the features of ITensor type "Fermion". It can be initialised by a set of QNDiag's and the site index $o$.
The Sites objects in ITensor can be converted to a QNDiags and Confs with the QNs extracted.
FuzzifiED.GetQNDiags — MethodGetQNDiags(sites :: Vector{<:Index})Converts a Sites object in the ITensors package to a set of QNDiags.
Arguments
sites :: Vector{<:Index}is aSitesobject. OnlyFermionsite type is supported, and the quantum numbers of the0state must be all zero. Note that this will subject to the limitation in ITensors that the number of conserved quantities must be less than 4.
FuzzifiED.Confs — MethodConfs(sites :: Vector{<:Index}, sec_qn :: QN)
Confs(sites :: Vector{<:Index}, cf_ref :: Vector{Int64})Converts a Sites object in the ITensors package to the Confs object
Arguments
sites :: Vector{<:Index}is aSitesobject. OnlyFermionsite type is supported, and the quantum numbers of the0state must be all zero. Note that this will subject to the limitation in ITensors that the number of conserved quantities must be less than 4.sec_qn :: QNis aQNobject that specifies the the quantum number of the selected configuration. Alternatively,cf_ref :: Vector{Int64}is a reference configuration composed of0and1.
Conversely, the Sites objects in ITensors can also be generated from a set of diagonal quantum numbers
FuzzifiED.GetSites — MethodGetSites(qnd :: Vector{QNDiag}) :: Vector{<:Index}returns the ITensors Sites of type "FuzzyFermion" from a set of QNDiags.
If the number of quantum numbers are too many, it can be truncated by
FuzzifiED.TruncateQNDiag — MethodTruncateQNDiag(qnd :: Vector{QNDiag} ; trunc_lth :: Int64, trunc_wt :: Vector{Int64}) :: Vector{QNDiag}truncates the list of $N_U$ QNDiags from to a number $N'_U$ acceptable by ITensors. The new quantum numbers are
\[\begin{aligned} &Q'_1=Q_1,\ Q'_2=Q_2,\ …,\ Q'_{N'_U-1}=Q_{N'_U-1}\\ &Q'_{N'_U}=λ_{N'_U}Q_{N'_U}+λ_{N'_U+1}Q_{N'_U+1}+…+λ_{N_U}Q_{N_U} \end{aligned}\]
Arguments
qnd :: Vector{QNDiag}stores the set of QNDiags.trunc_lth :: Int64stores the truncated numbers of QNDiags. Facultative, 3 by default.trunc_wt :: Vecotr{Int64}stores the $N_U-N'_U+1$ coefficients $λ$. Facultative, $1,10,100,1000,…$ by default.
The OpSum objects in ITensor can be converted with the collection of Term's
FuzzifiED.Terms — MethodTerms(opsum :: OpSum)Converts a OpSum object in ITensors to a series of terms. Note that the only operators supported are "C", "Cdag" "N" and "I".
ITensors.Ops.OpSum — MethodOpSum(tms :: Terms)Converts a series of terms to OpSum object in ITensors.
Easy sweep
This tool kit facilitates the management of DMRG process. It automatically records the intermediate results and recover these results if a job is stopped and run again on HPC. It also manages the gradual increase of maximal bond dimensions and the determination of convergence by the criteria of energy. This extension required the packages HDF5. We also recommand using the package ITensorMPOConstruction for the generation of Hamiltonian MPO, which can be installed by
using Pkg ; Pkg.add(url="https://github.com/ITensor/ITensorMPOConstruction.jl.git")FuzzifiED.EasySweep — MethodEasySweep(id :: String, hmt :: MPO, st00 :: MPS ; path :: String, dim_list :: Vector{Int64}, proj :: Vector{String}, e_tol1 :: Float64, e_tol :: Float64, cutoff :: Vector{Float64}, maxdim0 :: Vector{Float64}, noise0 :: Vector{Float64}, noise :: Vector{Int64}, nsweeps :: Int64, weight :: Float64, observer :: AbstractObserver) :: Tuple{Float64, MPS}Function
This function automatically performs several rounds of DMRG sweeps with increasing bond dimensions. It first checks the file st_$(id).h5 in a specified repository. If the key st_fin exists, it reads the energy and MPS from the file and return the energy and MPS, otherwise it will perform the DMRG process. For each round, it will try to access the results from the key st_d$(dim_i) in st_$(id).h5, where dim_i is either 0 representing the initial round, or an element of array dim_list. If the key exist, it will read the result ; otherwise it will perform the sweeps using SweepOne. For the initial round, it will take the initial state from st00, the maximal bond dimensions from maxdim0, noise from noise0 and record the results in the key E_d0 and st_d0 in st_$(id).h5. For each of the following round, it will take the result from the previous round as the initial state and perform nsweeps sweeps with the bond dimension dim_list[i]. Each round will be stopped if the energy difference is less than e_tol1. The entire process will be stopped if the energy difference between two rounds is less than e_tol or the bond dimension of the result is less than 0.9 times the maximal bond dimension. The projected states will be accessed from the files specified by proj. It will try to access first the states with the same bond dimension as the projected states. If such states do not exist, it will then access the final state. The resulting energy will be written into the key E_fin in the file st_$(id).h5, and the MPS written into st_fin. The function returns a tuple of energy and the final MPS.
Arguments
id :: Stringis a string identifying the file to which the results will be accessed and written.hmt :: MPOis an MPO specifying the Hamiltonian.st00 :: MPSis an MPS specifying the initial state.path :: Stringidentifies the path where the results will be accessed and stored. Facultative,./by default.dim_list :: Vector{Int64} :: Int64is a list that specifies the maximal bond dimensions of each round of sweeps starting from the second round. Facultative,[1000,2000,3000,4000,5000,6000]by defaultproj :: Vector{String}specifies the name of the states that will be projected. Facultative, empty by default.e_tol1 :: Float64specifies the energy tolerence as a criteria to end the round of sweeps for each round of sweeps. Facultative,1E-6by default.e_tol :: Float64specifies the energy tolerence as a criteria to end the entire process. Facultative,1E-7by default.cutoff :: Vector{Float64}is the cutoff that will be sent into DMRG. Facultative,[1.E-9]by default.maxdim0 :: Vector{Int64}specifies the maximal bond dimensions of the first round of sweeps. Facultative,[10,20,50,100,200,500]by default.noise0 :: Vector{Float64}specifies the noise of each sweep in the initial round and will be sent into DMRG. Facultative,[1E-4,3E-5,1E-5,3E-6,1E-6,3E-7]by default.noise :: Vector{Float64}specifies the noise of each sweep from the second round and will be sent into DMRG. Facultative,[1E-6,1E-7,0]by default.nsweeps :: Int64specifies the number of sweeps in each round from the second rounds. Facultative, 10 by default.weight :: Float64specifies the weight of projected states and will be sent into DMRG. Facultative, 100.0 by default.observer :: AbstractObserverspecifies the measurement and cutoff condition for each sweep starting from the second round. Facultative, by default the observer will print the energy and cutoff once the energy difference is less thane_tolat each sweep.dmrg_options :: Dictspecifies other options to be sent into DMRG. E.g., to specifywrite_when_maxdim_exceeds = 1000andwrite_path = "./tmp/", one can putdmrg_options = Dict(:write_when_maxdim_exceeds => 1000, :write_path => "./tmp/").clear_previous :: Bool. If set true, the filest_$(id).h5will be removed and the calculation will start from scratch. Facultative, false by default.
FuzzifiED.SweepOne — MethodSweepOne(id :: String, hmt :: MPO, st0 :: MPS, dim1 :: Int64 ; path :: String, cutoff :: Vector{Float64}, maxdim :: Vector{Int64}, nsweeps :: Int64, noise :: Vector{Float64}, proj :: Vector{String}, e_tol :: Float64, weight :: Float64, observer :: AbstractObserver, dmrg_options :: Dict, dmrg_options :: Dict) :: Tuple{Float64, MPS}Function
This function performs one round of nsweeps sweeps. It first checks the file st_$(id).h5 in a specified repository. If the key st_d$(dim1) exists, it reads the energy and MPS from the file and return the energy and MPS, otherwise it will perform the DMRG process with the maximal bond dimension specified by maxdim if it exists, or dim1. The projected states will be read from the key st_d$(dim1) if it exists or st_fin in the file st_$(fi).h5 in the same repository for each string fi in the array proj. The sweeps will be ended if the energy difference is less than etol or whatever criteria is given in observer. The resulting energy will be written into the key E_d$(dim1) in the file st_$(id).h5, and the MPS written into st_d$(dim1). The function returns a tuple of energy and the final MPS.
Arguments
id :: Stringis a string identifying the file to which the results will be accessed and written.hmt :: MPOis an MPO specifying the Hamiltonian.st0 :: MPSis an MPS specifying the initial state.dim1 :: Int64is a bond dimension that will be used to identify the result.path :: Stringidentifies the path where the results will be accessed and stored. Facultative,./by default.cutoff :: Vector{Float64}is the cutoff that will be sent into DMRG. Facultative,[1.E-9]by default.maxdim :: Vector{Int64}specifies the maximal bond dimension of each sweep. Facultative,[dim1]by default.nsweeps :: Int64specifies the number of sweeps in the round. Facultative, 10 by default.noise :: Vector{Float64}specifies the noise of each sweep and will be sent into DMRG. Facultative,[1E-6,1E-7,0]by default.proj :: Vector{String}specifies the name of the states that will be projected. Facultative, empty by default.e_tol :: Float64specifies the energy tolerence as a criteria to end the sweeps. Facultative,1E-6by default.weight :: Float64specifies the weight of projected states and will be sent into DMRG. Facultative, 100.0 by default.observer :: AbstractObserverspecifies the measurement and cutoff condition for each sweep. Facultative, by default the observer will print the energy and cutoff once the energy difference is less thane_tolat each sweep.dmrg_options :: Dictspecifies other options to be sent into DMRG. E.g., to specifywrite_when_maxdim_exceeds = 1000andwrite_path = "./tmp/", one can putdmrg_options = Dict(:write_when_maxdim_exceeds => 1000, :write_path => "./tmp/").
FuzzifiED.GetMPOSites — MethodGetMPOSites(id :: String, tms, qnd :: Vector{QNDiag} ; path :: String, qnu_o :: Vector{Vector{Int64}}, qnu_name :: Vector{String}, modul :: Vector{Int64}, mpo_method :: Function) :: Tuple{MPO, Vector{<:Index}}Function
This function returns the MPO and sites for a given operator and a Hilbert space with given quantum numbers. It first checks the file op_$(id).h5 in a specified repository. If the file exists, it will try to read the fields mpo and sites and return the MPO and Sites. Otherwise it will first generates the sites with the quantum numbers given in qnd. Then it will generate the MPO with the terms of the operator given in tms. The MPO and sites will be written into the file op_$(id).h5 in the fields mpo and sites.
Arguments
id :: Stringis a string identifying the file to which the results will be accessed and written.tms :: Termsortms :: OpSumis either an array of terms or aOpSumobjects that specifies the expression of the operator.qnd :: Vector{QNDiag}is a list of diagonal quantum numbers.path :: Stringidentifies the path where the results will be accessed and stored. Facultative,./by default.mpo_method :: Functionis a functionmpo_method(os :: OpSum, sites :: Sites) :: MPOthat generates the MPO from OpSum and Sites. Facultative,MPOby default. We suggest usingMPO_newinITensorMPOConstructionpackage. Seeexample_ising_dmrg_easysweep.jlfor example. N.b.,MPO_newonly applies to the cases that the operator do not carry charge under any of the quantum numbers.clear_previous :: Bool. If set true, the fileop_$(id).h5will be removed and the calculation will start from scratch. Facultative, false by default.
FuzzifiED.GetMPO — MethodGetMPO(id :: String, tms :: Union{Terms, OpSum}, sites :: Vector{<:Index} ; path :: String, mpo_method :: Function) :: MPOFunction
This function returns the MPO for a given operator and a given set of sites. It first checks the file op_$(id).h5 in a specified repository. If the file exists, it will try to read the fields mpo and return the MPO it has read. Otherwise it will generate the MPO with the terms of the operator given in tms. The MPO and Sites will be written into the file op_$(id).h5 in the fields mpo.
Arguments
id :: Stringis a string identifying the file to which the results will be accessed and written.tms :: Termsortms :: OpSumis either an array of terms or aOpSumobjects that specifies the expression of the operator.sites :: Vector{<:Index}specifies the sites that the operator is acting on.path :: Stringidentifies the path where the results will be accessed and stored. Facultative,./by default.mpo_method :: Functionis a functionmpo_method(os :: OpSum, sites :: Sites) :: MPOthat generates the MPO from OpSum and Sites. Facultative,MPOby default. We suggest usingMPO_newinITensorMPOConstructionpackage. Seeexample_ising_dmrg_easysweep.jlfor example. N.b.,MPO_newonly applies to the cases that the operator do not carry charge under any of the quantum numbers.clear_previous :: Bool. If set true, the fileop_$(id).h5will be removed and the calculation will start from scratch. Facultative, false by default.
Modified version of ITensor
We have forked ITensors 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/ITensors.jl.git")
Pkg.add(url="https://github.com/FuzzifiED/ITensorMPS.jl.git")
Pkg.add(url="https://github.com/FuzzifiED/ITensorMPOConstruction.jl.git")The modifications made include
- Modify
ITensorsto allow up to 10 quantum numbers ; - Modify
ITensorMPSto allowwrite_when_maxdim_exceedsin DMRG in the presence of projection matrices ; - Modify
ITensorMPOConstructionto allow building MPOs that has symmetry flux ; - Modify
ITensorMPOConstructionto allow compatibility with the newest version ofITensors.
Please be warned that the robustness and the backward compatibility of these modifications are not warranted.