-
Notifications
You must be signed in to change notification settings - Fork 124
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[ITensors] [ENHANCMENT] Non-Hermitian
dmrg
(#913)
* nonHermitician * nonHermitician * nonHermitician * nonHermitician * Change DMRGObserver to allow complex energies * Change DMRGObserver to allow complex energies * Formatting and cleanup of tests * Replace complex_energy with energy_type * Redesign of DMRGObserver constructors Co-authored-by: leachinellato <leachinellato@outlook.com.ar> Co-authored-by: Miles <miles.stoudenmire@gmail.com>
- Loading branch information
1 parent
6695289
commit bd31af8
Showing
4 changed files
with
176 additions
and
26 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
######### | ||
## XXZ model with imaginary part | ||
######### | ||
using ITensors | ||
|
||
function Hamiltonian(sites, Δ::Float64, J::Float64, γ::Float64, h::Float64) | ||
N = length(sites) | ||
ampo = AutoMPO() | ||
|
||
for j in 1:(N - 1) | ||
ampo += Δ, "Sz", j, "Sz", j + 1 | ||
ampo += -(J + im * γ * (-1.0)^j), "Sx", j, "Sx", j + 1 | ||
ampo += -(J + im * γ * (-1.0)^j), "Sy", j, "Sy", j + 1 | ||
end | ||
for j in 1:N | ||
ampo += h * (-1.0)^j, "Sz", j | ||
end | ||
# Convert these terms to an MPO tensor network | ||
return MPO(ampo, sites) | ||
end | ||
|
||
let | ||
#model parameters | ||
N = 4 | ||
Δ = -0.70 | ||
J = 1.0 | ||
γ = 0.1 | ||
h = 0.1 | ||
|
||
alg = "qr_iteration" | ||
|
||
#dmrg parameters | ||
sweeps = Sweeps(1000) | ||
minsweeps = 5 | ||
maxdim!(sweeps, 50, 100, 200) | ||
#cutoff!(sweeps, 1E-12) | ||
etol = 1E-12 | ||
|
||
sites = siteinds("S=1/2", N; conserve_qns=false) | ||
|
||
#initial state | ||
state = ["Emp" for n in 1:N] | ||
p = N | ||
for i in N:-1:1 | ||
if p > i | ||
#println("Doubly occupying site $i") | ||
state[i] = "UpDn" | ||
p -= 2 | ||
elseif p > 0 | ||
#println("Singly occupying site $i") | ||
state[i] = (isodd(i) ? "Up" : "Dn") | ||
p -= 1 | ||
end | ||
end | ||
psi0 = randomMPS(sites, state) | ||
@show flux(psi0) | ||
|
||
H = Hamiltonian(sites, Δ, J, γ, h) | ||
|
||
obs = DMRGObserver( | ||
["Sz"], sites; energy_tol=etol, minsweeps=minsweeps, complex_energies=true | ||
) | ||
|
||
energy, psi = dmrg( | ||
H, psi0, sweeps; svd_alg=alg, observer=obs, outputlevel=1, ishermitian=false | ||
) | ||
println("Final energy = $energy") | ||
end |
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,68 @@ | ||
using ITensors | ||
|
||
function Hamiltonian(sites, λ::Float64, k::Float64) | ||
N = length(sites) | ||
ampo = AutoMPO() | ||
|
||
for j in 1:(N - 1) | ||
ampo += -0.5 * 2 * λ, "Sz", j, "Sz", j + 1 | ||
end | ||
for j in 1:N | ||
ampo += -0.5 * 2 * im * k, "Sz", j | ||
ampo += -0.5, "S+", j | ||
ampo += -0.5, "S-", j | ||
end | ||
# Convert these terms to an MPO tensor network | ||
return MPO(ampo, sites) | ||
end | ||
|
||
let | ||
#----------------------------------------------------------------------- | ||
|
||
#models parameters | ||
N = 4 | ||
λ = 0.1 | ||
k = 0.5 | ||
|
||
alg = "qr_iteration" | ||
|
||
#dmrg parameters | ||
sweeps = Sweeps(1000) | ||
minsweeps = 5 | ||
maxdim!(sweeps, 50, 100, 200) | ||
#cutoff!(sweeps, 1E-12) | ||
etol = 1E-12 | ||
|
||
#----------------------------------------------------------------------- | ||
|
||
sites = siteinds("S=1/2", N; conserve_qns=false) | ||
#----------------------------------------------------------------------- | ||
|
||
#inicial state | ||
state = ["Emp" for n in 1:N] | ||
p = N | ||
for i in N:-1:1 | ||
if p > i | ||
state[i] = "UpDn" | ||
p -= 2 | ||
elseif p > 0 | ||
state[i] = (isodd(i) ? "Up" : "Dn") | ||
p -= 1 | ||
end | ||
end | ||
psi0 = randomMPS(sites, state) | ||
@show flux(psi0) | ||
#----------------------------------------------------------------------- | ||
|
||
#----------------------------------------------------------------------- | ||
|
||
H = Hamiltonian(sites, λ, k) | ||
#----------------------------------------------------------------------- | ||
|
||
obs = DMRGObserver(; energy_tol=etol, minsweeps=2, complex_energies=true) | ||
|
||
energy, psi = dmrg( | ||
H, psi0, sweeps; svd_alg=alg, observer=obs, outputlevel=1, ishermitian=false | ||
) | ||
println("Final energy = $energy") | ||
end |