Skip to content

Commit 557740f

Browse files
committed
Add test
1 parent 7bcde00 commit 557740f

File tree

2 files changed

+44
-0
lines changed

2 files changed

+44
-0
lines changed

test/bose_hubbard.jl

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
using Test
2+
using TensorKit
3+
using MPSKit
4+
using MPSKitModels
5+
6+
## Setup
7+
8+
symmetry = U1Irrep
9+
cutoff = 3
10+
t = 1.0
11+
U = 10.0
12+
mu = 0.0
13+
n = 1
14+
lattice = InfiniteChain()
15+
16+
Vspace = U1Space(0 => 8, 1 => 6, -1 => 6, 2 => 4, -2 => 4, 3 => 2, -3 => 2)
17+
18+
alg = VUMPS(; maxiter=25, verbosity=0)
19+
20+
# compare against higher-order analytic expansion from https://arxiv.org/pdf/1507.06426
21+
function exact_bose_hubbard_energy(; t=1.0, U=1.0)
22+
J = t / U
23+
24+
E = 4 * U *
25+
(-J^2 + J^4 + 68 / 9 * J^6 - 1267 / 81 * J^8 + 44171 / 1458 * J^10 -
26+
4902596 / 6561 * J^12 -
27+
8020902135607 / 2645395200 * J^14 - 32507578587517774813 / 466647713280000 * J^16)
28+
29+
return E
30+
end
31+
32+
## Test
33+
34+
@testset "Bose-Hubbard ground state" begin
35+
H = bose_hubbard_model(symmetry, lattice; cutoff, t, U, mu, n)
36+
ψ = InfiniteMPS([physicalspace(H, 1)], [Vspace])
37+
@test imag(expectation_value(ψ, H)) 0 atol = 1e-10
38+
ψ, envs, δ = find_groundstate(ψ, H, alg)
39+
@test expectation_value(ψ, H, envs) exact_bose_hubbard_energy(; t, U) atol = 1e-2
40+
end

test/runtests.jl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,10 @@ end
3737
include("heisenberg.jl")
3838
end
3939

40+
@testset "bose-hubbard model" begin
41+
include("bose_hubbard.jl")
42+
end
43+
4044
@testset "quantum potts model" begin
4145
include("quantum_potts.jl")
4246
end

0 commit comments

Comments
 (0)