Skip to content

Commit

Permalink
transverse field ising
Browse files Browse the repository at this point in the history
  • Loading branch information
GiggleLiu committed May 19, 2024
1 parent cdf67bc commit 5db3044
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/SimpleTDVP.jl
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export MPS, nsite, nflavor, vec2mps, IndexStore, newindex!, code_mps2vec, rand_m
export product_mps, ghz_mps
export left_move!, right_move!, canonical_move!, is_canonicalized, canonical_center, to_left_canonical!, to_right_canonical!
export mat, MPO, code_mpo2mat, mat2mpo, rand_mpo
export heisenberg_mpo
export heisenberg_mpo, transverse_ising_mpo
export dot, sandwich, compress!, num_of_elements
export dmrg!, dmrg
export TensorLayout
Expand Down
11 changes: 11 additions & 0 deletions src/mpo.jl
Original file line number Diff line number Diff line change
Expand Up @@ -121,4 +121,15 @@ function heisenberg_mpo(::Type{T}, n::Int) where T
tensor1[1, :, :, 3] = tensor2[3, :, :, 5] = tensor2[1, :, :, 3] = tensor3[3, :, :, 1] = Matrix{T}(Y)
tensor1[1, :, :, 4] = tensor2[4, :, :, 5] = tensor2[1, :, :, 4] = tensor3[4, :, :, 1] = Matrix{T}(Z)
MPO([tensor1, fill(tensor2, n-2)..., tensor3])
end

function transverse_ising_mpo(::Type{T}, n::Int, h::Real) where T
@assert n > 1
tensor1 = zeros(T, 1, 2, 2, 3)
tensor2 = zeros(T, 3, 2, 2, 3)
tensor3 = zeros(T, 3, 2, 2, 1)
tensor1[1, :, :, 1] = tensor2[1, :, :, 1] = tensor2[3, :, :, 3] = tensor3[3, :, :, 1] = Matrix{T}(I2)
tensor1[1, :, :, 2] = tensor2[2, :, :, 3] = tensor2[1, :, :, 2] = tensor3[2, :, :, 1] = Matrix{T}(Z)
tensor1[1, :, :, 3] = tensor2[1, :, :, 3] = tensor3[1, :, :, 1] = Matrix{T}(X) .* h
MPO([tensor1, fill(tensor2, n-2)..., tensor3])
end
16 changes: 16 additions & 0 deletions test/mpo.jl
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,20 @@ end
@test nsite(mpo) == n
h = EasyBuild.heisenberg(n; periodic=false)
@test mat(mpo) mat(h)
end

@testset "transverse ising" begin
n = 7
h = 0.0
mpo = transverse_ising_mpo(ComplexF64, n, h)
@test nsite(mpo) == n
h = EasyBuild.transverse_ising(n, h; periodic=false)
@test mat(mpo) mat(h)

n = 7
h = 0.2
mpo = transverse_ising_mpo(ComplexF64, n, h)
@test nsite(mpo) == n
h = EasyBuild.transverse_ising(n, h; periodic=false)
@test mat(mpo) mat(h)
end

0 comments on commit 5db3044

Please sign in to comment.