TRIQS/TRIQS — Issue #13: How to input G0 from file?
Author: A32167
Created: 2011-11-17 17:08:18+00:00
State: open

Hi all!
Here's a piece of code (from the same example aim.py)

from pytriqs.Base.GF_Local import *
from pytriqs.Solvers.Operators import *
from pytriqs.Solvers.HybridizationExpansion import Solver
from pytriqs.Base.Plot.MatplotlibInterface import oplot
from matplotlib.pyplot import show, draw
from pytriqs.Base.Archive import *
import numpy

Input = HDF_Archive("input.h5")

# The impurity solver
S = Solver(Beta = Input["Beta"], # inverse temperature
GFstruct = [ ('up',[1]), ('down',[1]) ], # Structure of the Green's function
H_Local = Input["U"]* N('up',1) * N('down',1), # Local Hamiltonian
Quantum_Numbers = { # Quantum Numbers
'Nup' : N('up',1), # (operators commuting with H_Local)
'Ndown' : N('down',1) },
N_Frequencies_Accumulated = int(Input["N_Matsubaras"]),
N_Cycles = 500000, # Number of QMC cycles
Length_Cycle = 20000, # Length of one cycle
N_Warmup_Cycles = 10000, # Warmup cycles
Legendre_Accumulation = True,
N_Legendre_Coeffs = 80, # Number of Legendre coefficients
Random_Generator_Name = 'mt19937', # Name of the random number generator
#Use_Segment_Picture = False, # Use the segment picture
Measured_Operators = { # Operators to be averaged
'Nimp' : N('up',1)+N('down',1) },
Global_Moves = [ # Global move in the QMC
(0.05, lambda (a,alpha,dag) : ( {'up':'down','down':'up'}[a],alpha,dag ) ) ],
)

G0 = GFBloc_ImFreq(Indices = [1], NFreqMatsubara=Input['N_Matsubaras'], Beta = Input['Beta'])
G0 <<= Input['G0'] #This works!
print len(G0.x_data_view(flatten_y = True )[1]) # The len is 200
for name, block in S.G0:
print len(block.x_data_view(flatten_y = True )[1]) # The len is 1025
print name
block <<= G0 #This doesn't

The input is obtained in a following way:

from pytriqs.Base.GF_Local import *
from pytriqs.Solvers.Operators import *
from pytriqs.Base.Archive import *
import numpy

D, V, U = 1.0, 0.5, 4.0
e_f, Beta = -U/2.0, 10
N_Matsubaras = 200

Delta = GFBloc_ImFreq(Indices = [1], NFreqMatsubara=N_Matsubaras, Beta = Beta)
Delta <<= V**2*Wilson(D)

G0 = GFBloc_ImFreq(Indices = [1], NFreqMatsubara=N_Matsubaras, Beta = Beta)
G0 <<= inverse( iOmega_n - e_f - Delta )

Input = HDF_Archive("input.h5",'w')
Input["G0"] = G0
Input["U"]=U
Input["Beta"]=Beta
Input["N_Matsubaras"]=N_Matsubaras

I get the error "Mesh are not the same", which is indeed true, since solver implies a particular number of Matsubaras (1025). Is there a way to provide less?

Feature request: put somewhere the roadmap )