Skip to content

Commit

Permalink
Format.
Browse files Browse the repository at this point in the history
  • Loading branch information
Benedikt Kloss committed Jan 26, 2024
1 parent 3549068 commit ebea998
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 35 deletions.
6 changes: 3 additions & 3 deletions src/treetensornetworks/projttns/abstractprojttn.jl
Original file line number Diff line number Diff line change
Expand Up @@ -134,9 +134,9 @@ function position(
# shift position
P = shift_position(P, pos)
# remove internal edges (out of place)
ie=internal_edges(P)
newenvskeys=filter(!in(ie),keys(P.environments))
P=ProjTTN(pos,P.H,getindices(P.environments,newenvskeys))
ie = internal_edges(P)
newenvskeys = filter(!in(ie), keys(P.environments))
P = ProjTTN(pos, P.H, getindices(P.environments, newenvskeys))
# make all environments surrounding new position
for e in incident_edges(P)
make_environment!(P, psi, e)
Expand Down
64 changes: 32 additions & 32 deletions test/test_treetensornetworks/test_position.jl
Original file line number Diff line number Diff line change
Expand Up @@ -4,40 +4,40 @@ using ITensorNetworks: position
using Test

@testset "ProjTTN position copy-safe" begin
# make a nontrivial TTN state and TTN operator

auto_fermion_enabled = ITensors.using_auto_fermion()
use_qns = true
cutoff = 1e-12
# make a nontrivial TTN state and TTN operator

tooth_lengths = fill(2, 3)
c = named_comb_tree(tooth_lengths)
if use_qns # test whether autofermion breaks things when using non-fermionic QNs
ITensors.enable_auto_fermion()
else # when using no QNs, autofermion breaks # ToDo reference Issue in ITensors
ITensors.disable_auto_fermion()
end
s = siteinds("S=1/2", c; conserve_qns=use_qns)
auto_fermion_enabled = ITensors.using_auto_fermion()
use_qns = true
cutoff = 1e-12

os = ITensorNetworks.heisenberg(c)
tooth_lengths = fill(2, 3)
c = named_comb_tree(tooth_lengths)
if use_qns # test whether autofermion breaks things when using non-fermionic QNs
ITensors.enable_auto_fermion()
else # when using no QNs, autofermion breaks # ToDo reference Issue in ITensors
ITensors.disable_auto_fermion()
end
s = siteinds("S=1/2", c; conserve_qns=use_qns)

H = TTN(os, s)
os = ITensorNetworks.heisenberg(c)

d = Dict()
for (i, v) in enumerate(vertices(s))
d[v] = isodd(i) ? "Up" : "Dn"
end
states = v -> d[v]
psi = TTN(s, states)
H = TTN(os, s)

# actual test, verifies that position is copy safe
vs= vertices(s)
PH0 = ProjTTN(H)
PH0 = position(PH0, psi, [vs[2],])
PH=copy(PH0)
PH=position(PH,psi,[vs[2],vs[5]])
@test keys(PH.environments)!=keys(PH0.environments)
if !auto_fermion_enabled
ITensors.disable_auto_fermion()
end
end
d = Dict()
for (i, v) in enumerate(vertices(s))
d[v] = isodd(i) ? "Up" : "Dn"
end
states = v -> d[v]
psi = TTN(s, states)

# actual test, verifies that position is copy safe
vs = vertices(s)
PH0 = ProjTTN(H)
PH0 = position(PH0, psi, [vs[2]])
PH = copy(PH0)
PH = position(PH, psi, [vs[2], vs[5]])
@test keys(PH.environments) != keys(PH0.environments)
if !auto_fermion_enabled
ITensors.disable_auto_fermion()
end
end

0 comments on commit ebea998

Please sign in to comment.