Impurity Solver Tutorial

This tutorial goes through using the Hartree-Fock ImpuritySolver for a simple one band case. We start by importing the required modules:

[1]:
import numpy as np
from triqs.gfs import *
from triqs.mesh import MeshImFreq
from triqs.operators import *
from h5 import HDFArchive
from triqs_hartree_fock import ImpuritySolver
from triqs.plot.mpl_interface import oplot
Warning: could not identify MPI environment!
Starting serial run at: 2026-06-12 18:12:27.493677

Next we define G0, h_int, and the parameters that we will pass to the solver

[2]:
beta = 40
n_iw = 1025

iw_mesh = MeshImFreq(beta=beta, statistic='Fermion', n_iw=n_iw)
g0 = Gf(mesh=iw_mesh, target_shape=[1,1])
g0 << inverse(iOmega_n + 2)
G0 = BlockGf(name_list=['up', 'down'], block_list=[g0, g0], make_copies=True)

h_int = 3*n('up', 0)*n('down', 0)

gf_struct = [('up', 1), ('down', 1)]

Now we are ready to initialize the solver:

[3]:
S = ImpuritySolver(gf_struct=gf_struct, mesh=iw_mesh)

Next we pass G0 to the solver:

[4]:
S.G0_iw << G0
[4]:
Green Function G composed of 2 blocks:
 Green's Function G_up with mesh Imaginary frequency mesh with beta = 40, statistics = Fermion, N_iw = 1025, positive_only = false and target_shape (1, 1):

 Green's Function G_down with mesh Imaginary frequency mesh with beta = 40, statistics = Fermion, N_iw = 1025, positive_only = false and target_shape (1, 1):

Finally, we are ready to call the solve method. By default with_fock is True but can be turned to False to only include Hartree terms.

[5]:
S.solve(h_int=h_int, with_fock=True)

╔╦╗╦═╗╦╔═╗ ╔═╗  ┬ ┬┌─┐
 ║ ╠╦╝║║═╬╗╚═╗  ├─┤├┤
 ╩ ╩╚═╩╚═╝╚╚═╝  ┴ ┴└
TRIQS: Hartree-Fock solver

Running Impurity Solver
beta = 40.0000
h_int =
3*c_dag('down',0)*c_dag('up',0)*c('up',0)*c('down',0)
HARTREE SOLVER: starting solver in one-shot mode
Including Fock terms:
True
HARTREE SOLVER: Sigma_HF before iterating['up']:
[[0.+0.j]]
HARTREE SOLVER: Sigma_HF before iterating['down']:
[[0.+0.j]]

HARTREE SOLVER: fixing dc to 0.0000

HARTREE SOLVER: fixing dc to 0.0000
HARTREE SOLVER: Sigma_HF['up']:
[[3.-0.j]]
HARTREE SOLVER: Sigma_HF['down']:
[[3.-0.j]]
Final G_dens['up']:
[[-0.-0.j]]
Final G_dens['down']:
[[-0.-0.j]]