Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use random_itensor and random_mps #8

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion TODO
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,7 @@ Done: -add Printf for
Done: -simplify MPOpbc code
Done: -Get rid of MPOpbs struct.
Done: -Prevent Documter.jl from showing ITensor docs.
Done: -Seeing flakey GS tests. probably need to seed the randomMPS for consistency.
Done: -Seeing flakey GS tests. probably need to seed the random_mps for consistency.
Done: -Add a big lattice test and look at SVs
Plan:
90% Document what I have so far
Expand Down
2 changes: 1 addition & 1 deletion examples/apply_gates.jl
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ N,NNN = 10,2
sites = siteinds("Electron", N;conserve_qns=true)
H = reg_form_MPO(Hubbard_AutoMPO(ElT,sites, NNN))
state = [isodd(n) ? "Up" : "Dn" for n in 1:N]
psi = randomMPS(sites, state)
psi = random_mps(sites, state)
# show_directions(H)
@show get_Dw(H)
orthogonalize!(H,right)
Expand Down
2 changes: 1 addition & 1 deletion examples/directions.jl
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ include("../test/hamiltonians/hamiltonians.jl")
N = 10
sites = siteinds("S=1/2", N; conserve_qns=true)
state = [isodd(n) ? "Up" : "Dn" for n in 1:length(sites)]
psi = randomMPS(sites, state)
psi = random_mps(sites, state)
println("Show QN directions. Arrows should point *away* from ortho centers")
println("MPS as constructed")
show_directions(psi)
Expand Down
6 changes: 3 additions & 3 deletions test/blocking.jl
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ end
@testset "Sub tensor assign for block sparse matrices with compatable QN spaces" begin
qns=[QN("Sz",0)=>1,QN("Sz",0)=>3,QN("Sz",0)=>2]
i,j=Index(qns,"i"),Index(qns,"j")
A=randomITensor(i,j)
A=random_itensor(i,j)
nr,nc=dims(A)
B=copy(A)
for dr in 0:nr-1
Expand All @@ -170,10 +170,10 @@ end
# qns=[QN("Sz",0)=>1,QN("Sz",0)=>3,QN("Sz",0)=>2]
# qnsC=[QN("Sz",0)=>2,QN("Sz",0)=>2,QN("Sz",0)=>2] #purposely miss allgined.
# i,j=Index(qns,"i"),Index(qns,"j")
# A=randomITensor(i,j)
# A=random_itensor(i,j)
# nr,nc=dims(A)
# ic,jc=Index(qnsC,"i"),Index(qnsC,"j")
# C=randomITensor(ic,jc)
# C=random_itensor(ic,jc)
# @show dense(A) dense(C)
# C[ic=>1:nr,jc=>1:nc]=A[i=>1:nr,j=>1:nc]
# @show matrix(A)-matrix(C)
Expand Down
2 changes: 1 addition & 1 deletion test/gauge_fix.jl
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ models = [
state = [isodd(n) ? "Up" : "Dn" for n in 1:N]

H = MPO(Hrf)
psi = randomMPS(elt,sites, state)
psi = random_mps(elt,sites, state)
E0 = inner(psi', H, psi)

@test is_regular_form(Hrf)
Expand Down
2 changes: 1 addition & 1 deletion test/hamiltonians.jl
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ end
sites = siteinds("SpinHalf", N; conserve_qns=false)
Hnot = three_body_AutoMPO(sites; cutoff=-1.0) #No truncation inside autoMPO
H = three_body_AutoMPO(sites; cutoff=1e-15) #Truncated by autoMPO
psi = randomMPS(sites)
psi = random_mps(sites)
Enot = inner(psi', Hnot, psi)
E = inner(psi', H, psi)
#@show E-Enot get_Dw(Hnot) get_Dw(H)
Expand Down
2 changes: 1 addition & 1 deletion test/hamiltonians/hamiltonians.jl
Original file line number Diff line number Diff line change
Expand Up @@ -456,7 +456,7 @@ end

function fast_GS(H::MPO, sites, nsweeps::Int64=5)::Tuple{Float64,MPS}
state = [isodd(n) ? "Up" : "Dn" for n in 1:length(sites)]
psi0 = randomMPS(sites, state)
psi0 = random_mps(sites, state)
sweeps = Sweeps(nsweeps)
setmaxdim!(sweeps, 2, 4, 8, 16, 32)
setcutoff!(sweeps, 1E-10)
Expand Down
2 changes: 1 addition & 1 deletion test/orthogonalize.jl
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ verbose1 = false #verbose inside orth algos
sites = siteinds(model[2], N; conserve_qns=qns)
Hrf = reg_form_MPO(model[1](elt,sites, NNN; ul=ul))
state = [isodd(n) ? "Up" : "Dn" for n in 1:N]
psi = randomMPS(elt,sites, state)
psi = random_mps(elt,sites, state)
E0 = inner(psi', MPO(Hrf), psi)

@test is_regular_form(Hrf)
Expand Down
12 changes: 6 additions & 6 deletions test/truncate.jl
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ using NDTensors: Diag, BlockSparse, tensor
Base.show(io::IO, f::Float64) = @printf(io, "%1.1e", f)

#
# We need consistent output from randomMPS in order to avoid flakey unit testset
# So we just pick any seed so that randomMPS (hopefull) gives us the same
# We need consistent output from random_mps in order to avoid flakey unit testset
# So we just pick any seed so that random_mps (hopefull) gives us the same
# pseudo-random output for each test run.
#
using Random
Expand Down Expand Up @@ -46,7 +46,7 @@ verbose1 = false #verbose inside orth algos
sites = siteinds(model[2], N; conserve_qns=qns)
Hrf = reg_form_MPO(model[1](elt,sites, NNN; ul=ul))
state = [isodd(n) ? "Up" : "Dn" for n in 1:N]
psi = randomMPS(elt,sites, state)
psi = random_mps(elt,sites, state)
E0 = inner(psi', MPO(Hrf), psi)

bs = truncate!(Hrf, lr)
Expand Down Expand Up @@ -135,7 +135,7 @@ verbose1 = false #verbose inside orth algos
# H=transIsing_MPO(sites,NNN)
# #@show get_Dw(H)
# state=[isodd(n) ? "Up" : "Dn" for n=1:N]
# psi=randomMPS(sites,state)
# psi=random_mps(sites,state)
# Ea=inner(psi',Ha,psi)
# E0=inner(psi',H,psi)
# @test E0 ≈ Ea atol = eps
Expand Down Expand Up @@ -234,7 +234,7 @@ verbose1 = false #verbose inside orth algos
# si = infsiteinds("S=1/2", N; initstate, conserve_szparity=qns)
# ψ = InfMPS(si, initstate)
# for n in 1:N
# ψ[n] = randomITensor(inds(ψ[n]))
# ψ[n] = random_itensor(inds(ψ[n]))
# end
# H0=transIsing_iMPO(si,NNN;ul=ul)
# H0.llim=-1
Expand Down Expand Up @@ -310,7 +310,7 @@ verbose1 = false #verbose inside orth algos
# H=three_body_AutoMPO(sites) #Truncated by autoMPO
# #@show get_Dw(Hnot)
# Dw_auto = get_Dw(H)
# psi=randomMPS(sites)
# psi=random_mps(sites)
# Enot=inner(psi',Hnot,psi)
# E=inner(psi',H,psi)
# @test E ≈ Enot atol = sqrt(eps)
Expand Down