|
| 1 | +using ITensors, ITensorMPS |
| 2 | +using ITensorInfiniteMPS |
| 3 | +using Test |
| 4 | + |
| 5 | +@testset verbose = true "Heisenberg Model Test" begin |
| 6 | + cell_widths = [2, 3, 4, 5] |
| 7 | + @testset "cell_width=$width" for width in cell_widths |
| 8 | + model = Model("heisenberg") |
| 9 | + os = ITensorInfiniteMPS.opsum_finite(model, width;) |
| 10 | + |
| 11 | + connections = [] |
| 12 | + for term in os |
| 13 | + push!(connections, sort(ITensors.sites(term))) |
| 14 | + end |
| 15 | + for i in 1:(width - 1) |
| 16 | + @test [i, i + 1] ∈ connections |
| 17 | + end |
| 18 | + end |
| 19 | +end |
| 20 | + |
| 21 | +@testset verbose = true "Heisenberg2D Model Test" begin |
| 22 | + widths = [2, 3, 4, 5, 6] |
| 23 | + cell_widths = [2, 3, 4, 5] |
| 24 | + @testset "cell_width=$cell_width width=$width" for cell_width in cell_widths, |
| 25 | + width in widths |
| 26 | + |
| 27 | + model = Model("heisenberg2D") |
| 28 | + |
| 29 | + os = ITensorInfiniteMPS.opsum_finite(model, cell_width * width; width, yperiodic) |
| 30 | + |
| 31 | + connections = [] |
| 32 | + for term in os |
| 33 | + push!(connections, ITensors.sites(term)) |
| 34 | + end |
| 35 | + for col in 1:(cell_width - 1) |
| 36 | + for row in 1:(width - 1) |
| 37 | + i = (col - 1) * width + row |
| 38 | + @test [i, i + 1] ∈ connections |
| 39 | + @test [i, i + width] ∈ connections |
| 40 | + end |
| 41 | + (yperiodic && width > 2) && @test [i, i + width - 1] ∈ connections |
| 42 | + end |
| 43 | + # the above forgets the last horizontal bond |
| 44 | + for col in 1:(cell_width - 1) |
| 45 | + i = (col - 1) * width + width |
| 46 | + @test [i, i + width] ∈ connections |
| 47 | + end |
| 48 | + end |
| 49 | +end |
| 50 | + |
| 51 | +@testset verbose = true "Ising Model Test" begin |
| 52 | + cell_widths = [2, 3, 4, 5] |
| 53 | + @testset "cell_width=$width" for width in cell_widths |
| 54 | + model = Model("ising") |
| 55 | + os = ITensorInfiniteMPS.opsum_finite(model, width;) |
| 56 | + |
| 57 | + connections = [] |
| 58 | + for term in os |
| 59 | + push!(connections, sort(ITensors.sites(term))) |
| 60 | + end |
| 61 | + for i in 1:(width - 1) |
| 62 | + @test [i, i + 1] ∈ connections |
| 63 | + @test [i] ∈ connections |
| 64 | + end |
| 65 | + end |
| 66 | +end |
| 67 | + |
| 68 | +@testset verbose = true "Hubbard Model Test" begin |
| 69 | + t, U = 1.0, 4.0 |
| 70 | + cell_widths = [2, 3, 4, 5] |
| 71 | + @testset "cell_width=$width" for width in cell_widths |
| 72 | + model = Model("hubbard") |
| 73 | + os = ITensorInfiniteMPS.opsum_finite(model, width; t, U) |
| 74 | + |
| 75 | + connections = [] |
| 76 | + for term in os |
| 77 | + push!(connections, ITensors.sites(term)) |
| 78 | + end |
| 79 | + for i in 1:(width - 1) |
| 80 | + @test [i, i + 1] ∈ connections |
| 81 | + @test [i + 1, i] ∈ connections |
| 82 | + @test [i] ∈ connections |
| 83 | + end |
| 84 | + @test [width] ∈ connections |
| 85 | + end |
| 86 | +end |
| 87 | + |
| 88 | +nothing |
0 commit comments