TRIQS / triqs_0.x

DEPRECATED -- This is the repository of the older versions of TRIQS
Other
11 stars 9 forks source link

Triqs: How to get the occupancy, self-energy and How to use Matrix formulation #126

Closed dasari123 closed 11 years ago

dasari123 commented 11 years ago

Hi,

I need to run the triqs for away from Half-filling in the single orbital case(Bethe lattice). In the Half-filled case it is writing Greens function(matsubara frequency) as a output for every iteration. How can I get the output data for occupancy, selfenergy(both tau and matsubara frequency) and Greens function(tau) also?

I know that matrix formulation is meant for any general local interactions. Is it possible to run the triqs for single orbital Bethe lattice in the Matrix formulation or It is only possible when we are dealing multi-orbitals? If possible in that case am I need to use "USE_SEGMENT_PICTURE=false" or by default will it take?

With regards, Dasari.

dasari123 commented 11 years ago

Hi, I read the triqs documentation. Then I learned how to get G(tau) from G(iw_n) and self energy in Matsubara frequency also. I did it. But I didn't understand how to use density(). I have G(tau), so I know the occupancy(n=-G(beta)). By using measured_operators also I got the occupancy. But I am not able to use density. I tried different ways: n=density(Gt), n=density(Gt=0) and n=density().

Could you please help me how to use density if I have G(tau).

With regards, Dasari.

mferrero commented 11 years ago

The density is most easily obtained from the imaginary-frequency Green's function G(iomega_n). Then you get it with:

G.density()

This is described in the documentation here: http://ipht.cea.fr/triqs/doc/user_manual/green/block/GFBloc_ImFreq.html

Cheers,

Michel

dasari123 commented 11 years ago

Hi,

I am running dmft script for single orbital square lattice. I initialize the greens function. In the self consistency loop I used Dyson equation to get "non-interacting" greens function G0. The following is the script I used,

from pytriqs.Base.GF_Local import from pytriqs.Base.Archive import from pytriqs.Base.Lattice.TightBinding import from pytriqs.Base.DOS.Hilbert_Transform import import pytriqs.Base.Utility.MPI as MPI

Set up a few parameters

U = 8 Beta = 100 N_loops = 5

BL = bravais_lattice(Units = [(1,0,0) , (0,1,0) ], Orbital_Positions= {"" : (0,0,0)} ) t = -1.00 # First neighbour Hopping tp = 0.0*t # Second neighbour Hopping hop= { (1,0) : [[ t]], (-1,0) : [[ t]], (0,1) : [[ t]], (0,-1) : [[ t]], (1,1) : [[ tp]], (-1,-1): [[ tp]], (1,-1) : [[ tp]], (-1,1) : [[ tp]]} TB = tight_binding ( BL, hop) d = dos (TB, nkpts= 500, neps = 101, Name = 'dos')[0]

H = Hilbert_Transform(d)

Construct a CTQMC solver

from pytriqs.Solvers.Operators import * # imports the class manipulating C, C_dagger and N = C_dagger C from pytriqs.Solvers.HybridizationExpansion 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,
       Measured_Operators={
       'Nimp':N('up',1)+N('down',1)}
        )                                        # Here we can use the segment picture

Initalize the Green's function to a square lattice

Sigma0 = GFBloc_ImFreq(Indices = [1], Beta = 100); Sigma0.zero() S.G <<= H(Sigma = Sigma0, mu=4.0) 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(S.Sigma+inverse(g)) # This is the Dyson equation

# Run the solver
S.Solve()

gc = GFBloc_ImTime(Indices=[1], Beta = 100)

gc <<= InverseFourier(0.5*(S.G['up']+S.G['down'])) # take 

#gd = GFBloc_ImFreq(Indices=[1], Beta = 100)

gd=S.G

n=gd.density()

Some intermediate saves

if MPI.IS_MASTER_NODE():
  R = HDF_Archive("SingleSiteBethe.h5")
  R["G-%s"%IterationNumber] = S.G
  A = HDF_Archive("Selfenergy.h5")
  A["Sigma-%s"%IterationNumber] = S.Sigma
  B= HDF_Archive("Density.h5")
  B["Density1-%s"%IterationNumber] = gc
  c= HDF_Archive("Density2.h5")
  c["Density-%s"%IterationNumber] = n
  del R,A,B,c

I am getting an error like this

File "myscript8.py", line 54 for name, g0block in S.G0: ^ IndentationError: unexpected indent

Is this script correct? Where I am doing a mistake?

With regards, Dasari.

----- Original Message ----- From: "Michel Ferrero" notifications@github.com To: "TRIQS/TRIQS" TRIQS@noreply.github.com Cc: "dasari123" dasari@jncasr.ac.in Sent: Monday, March 25, 2013 2:10:37 AM Subject: Re: [TRIQS] Triqs: How to get the occupancy, self-energy and How to use Matrix formulation (#126)

The density is most easily obtained from the imaginary-frequency Green's function G(iomega_n). Then you get it with: G.density()

This is described in the documentation here: http://ipht.cea.fr/triqs/doc/user_manual/green/block/GFBloc_ImFreq.html

Cheers,

Michel

— Reply to this email directly or view it on GitHub .

aichhorn commented 11 years ago

There is obviously an extract blank in front of 'for'. python does not allow this, indentation is marking blocks (e.g. of for loops, if statements and so on). LMGTFY: http://stackoverflow.com/questions/1016814/what-to-do-with-unexpected-indent-in-python

mferrero commented 11 years ago

It is essential to know python well to use TRIQS. I recommend you go through the python tutorial to get familiar with the language:

http://docs.python.org/2/tutorial/index.html