|
1 | 1 | @testitem "imaginarytime_tests.jl/imaginarytime" begin |
2 | 2 | using Test |
3 | 3 | using Quantics |
| 4 | + import Quantics |
4 | 5 | using ITensors: siteinds, Index |
5 | 6 | using ITensors.SiteTypes: op |
6 | 7 | import ITensors |
7 | 8 | import SparseIR: Fermionic, Bosonic, FermionicFreq, valueim |
8 | 9 |
|
| 10 | + import ITensorMPS: MPS, onehot |
| 11 | + import QuanticsGrids as QG |
| 12 | + import TensorCrossInterpolation as TCI |
| 13 | + import QuanticsTCI: quanticscrossinterpolate |
| 14 | + import TCIITensorConversion |
| 15 | + |
9 | 16 | function _test_data_imaginarytime(nbit, β) |
10 | 17 | ω = 0.5 |
11 | 18 | N = 2^nbit |
|
80 | 87 | @test maximum(abs, (gtau - gtau_smpl)[trunc(Int, 0.2 * nτ):trunc(Int, 0.8 * nτ)]) < |
81 | 88 | 1e-2 |
82 | 89 | end |
| 90 | + |
| 91 | + |
| 92 | + @testset "ImaginaryTimeFT.to_tau with large R" begin |
| 93 | + function fermionic_wn(n, β) |
| 94 | + return (2 * n + 1) * π / β |
| 95 | + end |
| 96 | + |
| 97 | + function inv_iwn(n, β; ϵ=0.0) |
| 98 | + return 1.0 / (im * fermionic_wn(n, β) - ϵ) |
| 99 | + end |
| 100 | + |
| 101 | + _evaluate(Ψ::MPS, sites, index::Vector{Int}) = only(reduce( |
| 102 | + *, Ψ[n] * onehot(sites[n] => index[n]) for n in 1:length(Ψ))) |
| 103 | + |
| 104 | + β = 100.0 |
| 105 | + R = 50 |
| 106 | + N = 2^R |
| 107 | + N_half = 2^(R - 1) |
| 108 | + tol = 1e-16 |
| 109 | + maxdim_TCI = 100 |
| 110 | + maxdim_contract = 1000 |
| 111 | + cutoff_mpo = 1e-30 |
| 112 | + cutoff_contract = 1e-30 |
| 113 | + τ_check = 0.99 * β |
| 114 | + |
| 115 | + ngrid = QG.InherentDiscreteGrid{1}(R, -N_half) |
| 116 | + τgrid = QG.DiscretizedGrid{1}(R, 0, β) |
| 117 | + |
| 118 | + sitesiω = [Index(2, "Qubit, iω=$n") for n in 1:R] |
| 119 | + sitesτ = [Index(2, "Qubit, τ=$n") for n in 1:R] |
| 120 | + |
| 121 | + inv_iwn_tci(n) = inv_iwn(n, β; ϵ= 0.0) |
| 122 | + qtci2, ranks2, errors2 = quanticscrossinterpolate( |
| 123 | + ComplexF64, inv_iwn_tci, ngrid; tolerance=tol, maxbonddim=maxdim_TCI) |
| 124 | + |
| 125 | + inv_iwn_tt = TCI.TensorTrain(qtci2.tci) |
| 126 | + iwmps = MPS(inv_iwn_tt; sites=sitesiω) |
| 127 | + |
| 128 | + fourier_inv_iw = Quantics.to_tau( |
| 129 | + Fermionic(), iwmps, β; tag="iω", sitesdst=sitesτ, cutoff_MPO=cutoff_mpo, |
| 130 | + cutoff=cutoff_contract, maxdim=maxdim_contract, alg="naive") |
| 131 | + |
| 132 | + gtau_reconst = _evaluate(fourier_inv_iw, reverse(sitesτ), reverse(QG.origcoord_to_quantics(τgrid, τ_check))) |
| 133 | + |
| 134 | + @test abs(gtau_reconst - (-1/2)) < 1e-11 |
| 135 | + end |
83 | 136 | end |
84 | 137 |
|
85 | 138 | @testitem "imaginarytime_tests.jl/poletomps" begin |
|
112 | 165 | gtauref = gtauf.(LinRange(0, β, 2^nqubit + 1)[1:(end - 1)]) |
113 | 166 | @test maximum(abs, gtauref .- gtauvec) < 1e-14 |
114 | 167 | end |
| 168 | + |
115 | 169 | end |
0 commit comments