Exemplo n.º 1
0
    #-----------------------------------------------------

    def InverseFourier(self, time_min =None) : 
        """
           Returns a GfReTime containing the Inverse Fourier transform of self
           time_min is the minimal time. By default the time window is centered around 0
        """
        import gf_retime
        (a,b),N = list(self.mesh)[0:2], len(self.mesh)
        om0 = b-a
        if time_min !=None :
            time_max = time_min + 2* pi/om0
        else :
            time_max = pi/om0
            time_min = -time_max
        gt = gf_retime.GfReTime( indices = self.indices, beta = self.beta,
                                           statistic = self.statistic,
                                           time_min = time_min, time_max = time_max, n_time_points = N )
        gt.set_from_inverse_fourier(self)
        return gt


#-----------------------------------------------------
#  Register the class for HDFArchive
#-----------------------------------------------------

from pytriqs.base.archive.hdf_archive_schemes import register_class
register_class (GfReFreq)
 
 
Exemplo n.º 2
0
    def __check_attr(self,ATTR) :
        if not hasattr(self._first(), ATTR ) :
           raise RuntimeError, "The blocks of this Green Function do not possess the %s method"%ATTR

    def invert(self) : 
       """Inverse all the blocks"""
       self.__check_attr("invert")
       for i,g in self : g.invert()

    def delta(self) :
       """Compute delta from G0"""
       self.__check_attr("delta")
       return self.__class__( name_block_generator = [ (n, g.delta()) for n,g in self], make_copies=False)

    def transpose(self):
       """Transpose of the BlockGf"""
       self.__check_attr("transpose")
       return self.__class__( name_block_generator = [ (n, g.transpose()) for n,g in self], make_copies=False)

    def conjugate(self):
       """Conjugate of the BlockGf"""
       self.__check_attr("conjugate")
       return self.__class__( name_block_generator = [ (n, g.conjugate()) for n,g in self], make_copies=False)

#---------------------------------------------------------

from pytriqs.base.archive.hdf_archive_schemes import register_class
register_class (BlockGf)

Exemplo n.º 3
0
        """
        assert callable(function), "function is not callable"
        self.function,self.x_min,self.x_max = function,x_min,x_max
        try :
            e = function(0.001)
            len(numpy.array(e).shape) ==1
        except :
            raise RuntimeError , "Value of the function must be a 1d-array"
        self.__f(n_pts) # compute arrays
        DOS.__init__(self,self.eps,self.rho,name) 
        
    #-------------------------------------------------------------
    
    def __reduce__(self) : 
        return  self.__class__, (self.function,self.x_min, self.x_max, len(self.eps), self.name)
    
    #-------------------------------------------------------------
  
    def __f(self,N) :
        r = (self.x_max - self.x_min)/float(N-1)
        self.eps  = numpy.array( [self.x_min + r* i for i in range(N) ] )
        self.rho  = numpy.array( [self.function(e) for e in self.eps])

#-----------------------------------------------------
#  Register the class for HDFArchive
#-----------------------------------------------------

from pytriqs.base.archive.hdf_archive_schemes import register_class
register_class (DOS)

Exemplo n.º 4
0
           return [{'type' : "XY", 
                    'xlabel' : xlabel,
                    'ylabel' : ylabel (self.name),
                    'xdata' : X[sl],
                    'label' : Name if Name else prefix + B.name ,
                    'ydata' : f( B._data.array[0,0,sl] ) } for (i,j,B) in self ] 
    
        if use_ris : 
            ris = opt_dict.pop('RI','RI') 
            if   ris == "R" : 
                res = mdic( 'Re ', lambda x : x.real)
            elif ris == "I" : 
                res = mdic( 'Im ', lambda x : x.imag)
            elif ris == "S" :
                res = mdic( '', lambda x : -1/numpy.pi *x.imag)
            elif ris == 'RI' :
                 res = mdic( 'Re ', lambda x : x.real) + mdic( 'Im ', lambda x : x.imag)
            else : 
                 raise ValueError, "RIS flags meaningless %s"%ris
        else: 
            res = mdic( '', lambda x : x)
            
        if NamePrefix: self.name = name_save
        return res 
 
#-----------------------------------------------------

from pytriqs.base.archive.hdf_archive_schemes import register_class
register_class (TailGf)
register_class (MeshGf)
Exemplo n.º 5
0
        import gf_refreq
        om0 = 2*pi/(self.time_max - self.time_min)
        N = self.Npts
        gw = gf_refreq.GfReFreq(indices = self.indices,beta = self.beta,
                                         statistic = self.statistic,
                                         MeshArray = numpy.array([ om0*i for i in range (- (N/2),N/2)]))
        gw.set_from_fourier(self)
        return gw
                
    #-----------------------------------------------------

    def _plot_(self, OptionsDict):
        """ Plot protocol. OptionsDict can contain : 
             * :param RI: 'R', 'I', 'RI' [ default] 
             * :param x_window: (xmin,xmax) or None [default]
             * :param name: a string [default ='']. If not '', it remplaces the name of the function just for this plot.
        """
        M = [x for x in self.mesh]
        return self._plot_base( OptionsDict,  r'$t$', lambda name : r'%s$(t)$'%name, True, M)
 
#-----------------------------------------------------
#  Register the class for HDFArchive
#-----------------------------------------------------

from pytriqs.base.archive.hdf_archive_schemes import register_class
register_class (GfReTime)



 
Exemplo n.º 6
0
        return tuple([x for (n, x) in sorted(D.items())])


class PythonDictWrap:
    def __init__(self, ob):
        self.ob = ob

    def __reduce_to_dict__(self):
        return dict([(str(n), v) for (n, v) in self.ob.items()])

    @classmethod
    def __factory_from_dict__(cls, D):
        return dict([(n, x) for (n, x) in D.items()])


register_class(PythonListWrap)
register_class(PythonTupleWrap)
register_class(PythonDictWrap)

# -------------------------------------------
#
#  A view of a subgroup of the archive
#
# --------------------------------------------


class HDFArchiveGroup(HDFArchiveGroupBasicLayer):
    """
    """

    _wrappedType = {type([]): PythonListWrap, type(()): PythonTupleWrap, type({}): PythonDictWrap}
Exemplo n.º 7
0
           # This is the function to be minimized, the diff between the original
           # data in values and the fitting function
           def fct(p):
             y_fct = 1.0*f_known
             for order in range(len_param):
               y_fct += p[order]*omegas**(1-len(known_coef[n1][n2])-order)
             y_fct -= values[n1,n2,:]
             return abs(y_fct)

           # Now call the minimizing function
           sol = leastsq(fct, p0, maxfev=1000*len_param)

           # Put the known and the new found moments in the tail
           for order in range(len(known_coef[n1][n2])):
             self._tail[order-1][indR,indL] = [[ known_coef[n1][n2][order] ]]
           for order, moment in enumerate(sol[0]):
             self._tail[len(known_coef[n1][n2])+order-1][indR,indL] = [[ moment ]]

       # Replace then end of the Green's function by the tail
       if replace_tail: self.replace_by_tail(ninit);


#-----------------------------------------------------
#  Register the class for HDFArchive
#-----------------------------------------------------

from pytriqs.base.archive.hdf_archive_schemes import register_class
register_class (GfImFreq)


Exemplo n.º 8
0
    #-----------------------------------------------------

    def copy_and_truncate(self, Nleg):
        """ Copies the Legendre Green's function and truncates it down

        Parameters
        ----------
        Nleg : int
          remaining number of Legendre coefficients after truncation
        """
        new_g = self.__class__(indicesL = self._indicesL,
                               indicesR = self._indicesR,
                               beta = self.beta,
                               statistic = self.statistic,
                               n_legendre_coeffs = Nleg,
                               name = self.name, note = self.note)
        new_g._data.array[:,:,:] = self._data.array[:,:,0:Nleg]
        new_g.determine_tail()
        return new_g


#-----------------------------------------------------
#  Register the class for HDFArchive
#-----------------------------------------------------

from pytriqs.base.archive.hdf_archive_schemes import register_class
register_class (GfLegendre)