Skip to content

Commit e00c345

Browse files
committed
Remove functionalities that were merged into NamedGraphs.jl
Extend `models.jl` and remove `test/utils.jl` Change lazy `inner` to explicit `inner_network`
1 parent b389589 commit e00c345

12 files changed

+149
-332
lines changed

src/ITensorNetworks.jl

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,6 @@ const UniformDataGraph{D} = NamedDimDataGraph{
113113
}
114114

115115
include("utils.jl")
116-
include("namedgraphs.jl")
117116
include("itensors.jl")
118117
include("partition.jl")
119118
include("lattices.jl")
@@ -135,7 +134,6 @@ include(joinpath("treetensornetwork", "opsum_to_ttno.jl"))
135134
include(joinpath("treetensornetwork", "abstractprojttno.jl"))
136135
include(joinpath("treetensornetwork", "projttno.jl"))
137136
include(joinpath("treetensornetwork", "projttnosum.jl"))
138-
include(joinpath("graphs", "namedgraphs.jl"))
139137
include("utility.jl")
140138

141139
include("exports.jl")

src/abstractitensornetwork.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -546,7 +546,7 @@ function norm_network(tn::AbstractITensorNetwork; kwargs...)
546546
end
547547

548548
function flattened_inner_network::AbstractITensorNetwork, ψ::AbstractITensorNetwork)
549-
tn = inner(prime(ϕ; sites=[]), ψ)
549+
tn = inner_network(prime(ϕ; sites=[]), ψ)
550550
for v in vertices(ψ)
551551
tn = contract(tn, (2, v...) => (1, v...))
552552
end
@@ -559,7 +559,7 @@ function contract_inner(
559559
sequence=nothing,
560560
contraction_sequence_kwargs=(;),
561561
)
562-
tn = inner(prime(ϕ; sites=[]), ψ)
562+
tn = inner_network(prime(ϕ; sites=[]), ψ)
563563
# TODO: convert to an IndsNetwork and compute the contraction sequence
564564
for v in vertices(ψ)
565565
tn = contract(tn, (2, v...) => (1, v...))

src/exports.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@ export AbstractITensorNetwork,
8888
# namedgraphs.jl
8989
rename_vertices,
9090
# models.jl
91+
heisenberg,
9192
ising,
9293
# opsum.jl
9394
group_terms,

src/graphs/namedgraphs.jl

Lines changed: 0 additions & 49 deletions
This file was deleted.

src/models.jl

Lines changed: 73 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,78 @@
1-
function ising(g::AbstractGraph; h)
1+
_maybe_fill(x, n) = x
2+
_maybe_fill(x::Number, n) = fill(x, n)
3+
4+
"""
5+
Random field J1-J2 Heisenberg model on a general graph
6+
"""
7+
function heisenberg(
8+
g::AbstractGraph; J1=1.0, J2=0.0, h::Union{<:Real,Vector{<:Real}}=0
9+
)
10+
h = _maybe_fill(h, nv(g))
211
= OpSum()
3-
for e in edges(g)
4-
-= "Z", maybe_only(src(e)), "Z", maybe_only(dst(e))
12+
if !iszero(J1)
13+
for e in edges(g)
14+
+= J1 / 2, "S+", maybe_only(src(e)), "S-", maybe_only(dst(e))
15+
+= J1 / 2, "S-", maybe_only(src(e)), "S+", maybe_only(dst(e))
16+
+= J1, "Sz", maybe_only(src(e)), "Sz", maybe_only(dst(e))
17+
end
518
end
6-
for v in vertices(g)
7-
+= h, "X", maybe_only(v)
19+
if !iszero(J2)
20+
# TODO, more clever way of looping over next to nearest neighbors?
21+
for (i, v) in enumerate(vertices(g))
22+
nnn = [neighbors(g, n) for n in neighbors(g, v)]
23+
nnn = setdiff(Base.Iterators.flatten(nnn), neighbors(g, v))
24+
nnn = setdiff(nnn, vertices(g)[1:i])
25+
for nn in nnn
26+
+= J2 / 2, "S+", maybe_only(v), "S-", maybe_only(nn)
27+
+= J2 / 2, "S-", maybe_only(v), "S+", maybe_only(nn)
28+
+= J2, "Sz", maybe_only(v), "Sz", maybe_only(nn)
29+
end
30+
end
31+
end
32+
for (i, v) in enumerate(vertices(g))
33+
if !iszero(h[i])
34+
-= h[i], "Sz", maybe_only(v)
35+
end
36+
end
37+
return
38+
end
39+
40+
"""
41+
Next-to-nearest-neighbor Ising model (ZZX) on a general graph
42+
"""
43+
function ising(g::AbstractGraph; J1=-1.0, J2=0.0, h::Union{<:Real,Vector{<:Real}}=0)
44+
h = _maybe_fill(h, nv(g))
45+
= OpSum()
46+
if !iszero(J1)
47+
for e in edges(g)
48+
+= J1, "Z", maybe_only(src(e)), "Z", maybe_only(dst(e))
49+
end
50+
end
51+
if !iszero(J2)
52+
# TODO, more clever way of looping over next to nearest neighbors?
53+
for (i, v) in enumerate(vertices(g))
54+
nnn = [neighbors(g, n) for n in neighbors(g, v)]
55+
nnn = setdiff(Base.Iterators.flatten(nnn), neighbors(g, v))
56+
nnn = setdiff(nnn, vertices(g)[1:i])
57+
for nn in nnn
58+
+= J2, "Z", maybe_only(v), "Z", maybe_only(nn)
59+
end
60+
end
61+
end
62+
for (i, v) in enumerate(vertices(g))
63+
if !iszero(h[i])
64+
+= h[i], "X", maybe_only(v)
65+
end
866
end
967
return
1068
end
69+
70+
"""
71+
Random field J1-J2 Heisenberg model on a chain of length N
72+
"""
73+
heisenberg(N::Integer; kwargs...) = heisenberg(grid((N,)); kwargs...)
74+
75+
"""
76+
Next-to-nearest-neighbor Ising model (ZZX) on a chain of length N
77+
"""
78+
ising(N::Integer; kwargs...) = ising(grid((N,)); kwargs...)

src/namedgraphs.jl

Lines changed: 0 additions & 23 deletions
This file was deleted.

0 commit comments

Comments
 (0)