-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c0e6b15
commit c63c2fe
Showing
25 changed files
with
482 additions
and
123 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
# Example: Optimizing TTN | ||
|
||
## Ground state search | ||
|
||
A straight-forward TTN optimization can be performed as follows. | ||
|
||
``` | ||
using ITensors | ||
using TeNLib | ||
let | ||
N = 32 | ||
sites = siteinds("S=1/2",N) | ||
os = OpStrings() | ||
for j=1:N-1 | ||
os += 1, "Sz" => j, "Sz" => j+1 | ||
os += 0.5, "S+" => j, "S-" => j+1 | ||
os += 0.5, "S-" => j, "S+" => j+1 | ||
end | ||
H = CouplingModel(os,sites) | ||
psi0 = default_randomTTN(sites, 12, QN("Sz", 0)) | ||
sweeppath = default_sweeppath(psi0) | ||
params = OptimizeParamsTTN(; nsweeps = [10, 10], maxdim = [20, 50], | ||
cutoff = 1e-14, noise = 1e-3, noisedecay = 2, | ||
disable_noise_after = 5) | ||
en, psi = optimize(psi0, H, params, sweeppath) | ||
end | ||
``` | ||
|
||
!!! warning | ||
For TTN optimzaion, direct `MPO` input is not supported. One can, however, prepare a | ||
`CouplingModel` from `MPO` using | ||
[`CouplingModel(mpos::MPO...)`](@ref CouplingModel(mpos::MPO...)). | ||
|
||
|
||
Instead of using such higher-level code, one can also use lower-level functions for a better | ||
control. | ||
``` | ||
sysenv = StateEnvsTTN(psi0, H) | ||
swdata = optimize!(sysenv, params, sweeppath) | ||
# Get energy from `Sweepdata` | ||
energy = swdata.energy[end] | ||
# take a shallow copy of the TTN | ||
# if the `StateEnvsTTN` will be updated later again | ||
psi = getpsi(sysenv) | ||
# Alternatively, take the psi from `StateEnvsTTN` itself. | ||
# NOTE: This can crash the simulation, if the TTN is modified (e.g., in measurements) | ||
# and `StateEnvsTTN` is going to be updated later on. | ||
# psi = sysenv.psi | ||
``` | ||
|
||
## Excited state search | ||
|
||
Excited state search is also straightforword. | ||
|
||
``` | ||
# Given a ground state `psi_gr`, initial TTN `psi0`, | ||
# and a Hamiltonian `H` | ||
en, psi = optimize(psi0, H, [psi_gr], params, sweeppath; weight = 10.0) | ||
``` | ||
|
||
Similarly, using `StateEnvsTTN`: | ||
``` | ||
sysenv_ex = StateEnvsTTN(psi0, H, [psi_gr]; weight = 10.0) | ||
swdata_ex = optimize!(sysenv_ex, params, sweeppath) | ||
# Get energy from `Sweepdata` | ||
energy1 = swdata_ex.energy[end] | ||
# take a shallow copy of the TTN | ||
# if the `StateEnvsTTN` will be updated later again | ||
psi1 = getpsi(sysenv_ex) | ||
# Alternatively, take the psi from `StateEnvsTTN` itself. | ||
# NOTE: This can crash the simulation, if the TTN is modified (e.g., in measurements) | ||
# and `StateEnvsTTN` is going to be updated later. | ||
# psi1 = sysenv_ex.psi | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
# Measuring the TTN | ||
|
||
```@docs | ||
measure(::Type{T}, psi::TTN, opten::ITensor) where T <: Union{ComplexF64, Float64} | ||
measure(::Type{T}, psi::TTN, opstr::String, pos::Int) where T <: Union{ComplexF64, Float64} | ||
measure(::Type{T}, psi::TTN, opstr::String; kwargs...) where T <: Union{ComplexF64, Float64} | ||
measure(::Type{T}, psi::TTN, optens::Vector{ITensor}) where T <: Union{ComplexF64, Float64} | ||
measure(::Type{T}, psi::TTN, oppairs::Vector{Pair{String, Int}}; isfermions::Bool = true) where T <: Union{ComplexF64, Float64} | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
# Optimizing TTN | ||
|
||
Functions to optimize TTN. | ||
|
||
## `OptimizeParamsTTN` | ||
|
||
TeNLib.jl defines a struct, called `OptimizeParamsTTN`, to control TTN optimizations. | ||
|
||
```@docs | ||
OptimizeParamsTTN | ||
OptimizeParamsTTN(;maxdim::Vector{Int}, nsweeps::Vector{Int}, cutoff::Union{Vector{Float64}, Float64} = _Float64_Threshold, noise::Union{Vector{Float64}, Float64, Int} = 0.0, noisedecay::Union{Vector{Float64}, Float64, Int} = 1.0, disable_noise_after::Union{Vector{Int}, Int} = typemax(Int)) | ||
Base.copy(params::OptimizeParamsTTN) | ||
``` | ||
|
||
## A lower level optimization function | ||
|
||
Following function modifies `StateEnvsTTN` in-place. Skip this function if you want to | ||
avoid lower-level abstraction. | ||
|
||
```@docs | ||
optimize!(sysenv::StateEnvsTTN, params::OptimizeParamsTTN,sweeppath::Vector{Int2}; kwargs...) | ||
``` | ||
|
||
## Higher level optimzation functions | ||
|
||
```@docs | ||
optimize(psi0::TTN, H::CouplingModel, params::OptimizeParamsTTN, sweeppath::Vector{Int2}; kwargs...) | ||
``` | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
# Sweeping through the TTN | ||
|
||
At a lower level of abstraction, TeNLib.jl allows to control each fullsweep | ||
manually to update `StateEnvsTTN`. | ||
|
||
Skip this part if you want to avoid lower-level abstraction. | ||
|
||
## `SweepDataTTN` | ||
|
||
TeNLib.jl defines a struct, called `SweepDataTTN`, to store essential data after each fullsweep. | ||
|
||
```@docs | ||
SweepDataTTN | ||
Base.copy(swdata::SweepDataTTN) | ||
``` | ||
## `sweeppath` | ||
|
||
```@docs | ||
default_sweeppath | ||
``` | ||
|
||
## Perform a fullsweep | ||
|
||
```@docs | ||
fullsweep!(sysenv::StateEnvsTTN, sweeppath::Vector{Int2}, solver, swdata::SweepDataTTN; kwargs...) | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
# Perform local updates | ||
|
||
At the lowest-level of abstraction, TeNLib.jl allows for updating the `StateEnvsTTN` for each sites manually. | ||
|
||
Skip this part if you want to avoid lower-level abstraction. | ||
|
||
```@docs | ||
update_position!(sysenv::StateEnvsTTN, solver, node::Int2; time_step::Union{Float64, ComplexF64, Nothing}, normalize::Bool, maxdim::Int, mindim::Int, cutoff::Float64, svd_alg::String, kwargs...) | ||
``` | ||
|
||
TeNLib.jl implements the subspace expansion method described in | ||
[SciPost Phys. Lect. Notes 8 (2019)] (https://scipost.org/10.21468/SciPostPhysLectNotes.8) to increase the bond dimension between two neighboring nodes. | ||
|
||
```@docs | ||
subspace_expand!(psi::TTN, node::Int2, nextnode::Int2, max_expand_dim::Int, noise::Float64) | ||
``` |
Oops, something went wrong.