3
0
mirror of https://github.com/triqs/dft_tools synced 2024-11-01 03:33:50 +01:00
dft_tools/doc/tutorials/python/single_site_bethe.py
Olivier Parcollet 3305185bee Work on doc
- remove empty parts, start to clean the tour.
- added export of _template and _static to reuse in appli doc.
- clean tutorial part. rm cookbook.
2013-08-31 15:22:36 +02:00

49 lines
2.2 KiB
Python

from pytriqs.gf.local import *
from pytriqs.archive import *
import pytriqs.utility.mpi as mpi
# Set up a few parameters
Half_Bandwidth = 1.0
U = 2.5
Chemical_Potential = U/2.0
Beta = 100
N_loops = 5
# Construct a CTQMC solver
from pytriqs.applications.impurity_solvers.operators import * # imports the class manipulating C, C_dagger and N = C_dagger C
from pytriqs.applications.impurity_solvers.cthyb_matrix import Solver # imports the solver class
S = Solver(Beta = Beta, # inverse temperature
GFstruct = [ ('up',[1]), ('down',[1]) ], # Structure of the Green function
H_Local = U * N('up',1) * N('down',1), # Local Hamiltonian
Quantum_Numbers = { 'Nup' : N('up',1), 'Ndown' : N('down',1) }, # Quantum Numbers (operators commuting with H_Local)
N_Cycles = 5000, # Number of QMC cycles
Length_Cycle = 200, # Length of a cycle
N_Warmup_Cycles = 1000, # How many warmup cycles
N_Legendre_Coeffs = 30, # Use 30 Legendre coefficients to represent G(tau)
Random_Generator_Name = "mt19937", # Use the Mersenne Twister 19937 random generator
Use_Segment_Picture = True) # Here we can use the segment picture
# Initalize the Green's function to a semi circular
S.G <<= SemiCircular(Half_Bandwidth)
# Now do the DMFT loop
for IterationNumber in range(N_loops):
# Compute S.G0 with the self-consistency condition while imposing paramagnetism
g = 0.5 * ( S.G['up'] + S.G['down'] )
for name, g0block in S.G0:
g0block <<= inverse( iOmega_n + Chemical_Potential - (Half_Bandwidth/2.0)**2 * g )
# Run the solver
S.Solve()
# Some intermediate saves
if mpi.is_master_node():
R = HDFArchive("single_site_bethe.h5")
R["G-%s"%IterationNumber] = S.G
del R
# Here we would usually write some convergence test
# if Converged : break