@@ -5,6 +5,8 @@ import QuanticsGrids as QG
5
5
using TensorCrossInterpolation
6
6
import TensorCrossInterpolation as TCI
7
7
import TCIAlgorithms as TCIA
8
+ using HubbardAtoms
9
+ using SparseIR
8
10
9
11
import TCIAlgorithms:
10
12
create_node,
@@ -338,4 +340,100 @@ import TCIAlgorithms:
338
340
@test maximum (abs .(product_matrix .- C)) < 1e-5
339
341
@test maximum (abs .(product_matrix_without_patches .- C)) < 1e-5
340
342
end
343
+
344
+ @testset " Bethe-Salpeter equation" begin
345
+ U = 1.6
346
+ beta = 2.3
347
+ model = HubbardAtom (U, beta)
348
+ ch_d = DensityChannel ()
349
+ ch_m = MagneticChannel ()
350
+ ch_t = TripletChannel ()
351
+ ch_s = SingletChannel ()
352
+ m = BosonicFreq (10 )
353
+
354
+ R = 7
355
+ maxbonddim = 50
356
+ N = 2 ^ R
357
+ halfN = 2 ^ (R - 1 )
358
+ grid = QG. InherentDiscreteGrid {2} (
359
+ R, (- halfN, - halfN); step= (1 , 1 ), unfoldingscheme= :fused
360
+ )
361
+ localdims = fill (4 , R)
362
+ sitedims = [[2 , 2 ] for _ in 1 : R]
363
+ pordering = TCIA. PatchOrdering (collect (1 : R))
364
+
365
+ for ch in CHANNELS
366
+
367
+ # ######################## quantics functions ############################
368
+ # absorb 1/β^2 into chi0 function!!!!!
369
+ function fq_chi0 (x, y)
370
+ return 1 / beta^ 2 *
371
+ chi0 (ch, model, (FermionicFreq (2 x + 1 ), FermionicFreq (2 y + 1 ), m))
372
+ end
373
+ fI_chi0 = QG. quanticsfunction (ComplexF64, grid, fq_chi0)
374
+
375
+ function fq_full (x, y)
376
+ return full_vertex (
377
+ ch, model, (FermionicFreq (2 x + 1 ), FermionicFreq (2 y + 1 ), m)
378
+ )
379
+ end
380
+ fI_full = QG. quanticsfunction (ComplexF64, grid, fq_full)
381
+
382
+ function fq_gamma (x, y)
383
+ return gamma (ch, model, (FermionicFreq (2 x + 1 ), FermionicFreq (2 y + 1 ), m))
384
+ end
385
+ fI_gamma = QG. quanticsfunction (ComplexF64, grid, fq_gamma)
386
+ # ########################################################################
387
+
388
+ initialpivots = [QG. origcoord_to_quantics (grid, (0 , 0 ))] # approx center of grid
389
+
390
+ chi0_patches = reshape (
391
+ TCIA. adaptiveinterpolate (
392
+ TCIA. makeprojectable (Float64, fI_chi0, localdims),
393
+ pordering;
394
+ verbosity= 0 ,
395
+ maxbonddim,
396
+ initialpivots,
397
+ ),
398
+ sitedims,
399
+ )
400
+ full_patches = reshape (
401
+ TCIA. adaptiveinterpolate (
402
+ TCIA. makeprojectable (Float64, fI_full, localdims),
403
+ pordering;
404
+ verbosity= 0 ,
405
+ maxbonddim,
406
+ initialpivots,
407
+ ),
408
+ sitedims,
409
+ )
410
+ gamma_patches = reshape (
411
+ TCIA. adaptiveinterpolate (
412
+ TCIA. makeprojectable (Float64, fI_gamma, localdims),
413
+ pordering;
414
+ verbosity= 0 ,
415
+ maxbonddim,
416
+ initialpivots,
417
+ ),
418
+ sitedims,
419
+ )
420
+
421
+ # multiplication Φ = Γ X₀ F
422
+ chi0_full = TCIA. adaptivematmul (
423
+ chi0_patches, full_patches, pordering; maxbonddim
424
+ )
425
+ phi_bse = TCIA. adaptivematmul (gamma_patches, chi0_full, pordering; maxbonddim)
426
+
427
+ # normal multiplication for comparison
428
+ box = [(x, y) for x in (- halfN): (halfN - 1 ), y in (- halfN): (halfN - 1 )]
429
+ chi0_exact = map (splat (fq_chi0), box)
430
+ full_exact = map (splat (fq_full), box)
431
+ gamma_exact = map (splat (fq_gamma), box)
432
+ phi_normalmul = gamma_exact * chi0_exact * full_exact
433
+
434
+ phi_adaptivemul = [phi_bse (QG. origcoord_to_quantics (grid, p)) for p in box]
435
+
436
+ @test isapprox (phi_normalmul, phi_adaptivemul; rtol= 1e-5 )
437
+ end
438
+ end
341
439
end
0 commit comments