from __future__ import print_function # # ALPS Project: Algorithms and Libraries for Physics Simulations # # ALPS Libraries # # Copyright (C) 2012-2013 by Jakub Imriska # # This software is part of the ALPS libraries, published under the ALPS # Library License; you can use, redistribute it and/or modify it under # the terms of the license, either version 1 or (at your option) any later # version. # # You should have received a copy of the ALPS Library License along with # the ALPS Libraries; see the file LICENSE.txt. If not, the license is also # available from http://alps.comp-phys.org/. # # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, # FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT # SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE # FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, # ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER # DEALINGS IN THE SOFTWARE. # # **************************************************************************** import pyalps import numpy as np import matplotlib.pyplot as plt import pyalps.plot from math import pi listobs=['0'] # we look at a single flavor (=0) res_files = pyalps.getResultFiles(pattern='parm_*.h5') # we look for result files ################################################################################## ## Display all iterations of the Green's function in imaginary time representation ################################################################################## ## load all iterations of G_{flavor=0}(tau) data = pyalps.loadDMFTIterations(res_files, observable="G_tau", measurements=listobs, verbose=False) ## create a figure for each BETA grouped = pyalps.groupSets(pyalps.flatten(data), ['BETA']) for sim in grouped: common_props = pyalps.dict_intersect([ d.props for d in sim ]) ## rescale x-axis and set label for d in sim: d.x = d.x * d.props['BETA']/float(d.props['N']) d.props['label'] = 'it'+d.props['iteration'] ## plot all iterations for this BETA plt.figure() plt.xlabel(r'$\tau$') plt.ylabel(r'$G_{flavor=0}(\tau)$') plt.title('Simulation at ' + r'$\beta = {beta}$'.format(beta= common_props['BETA'])) pyalps.plot.plot(sim) plt.legend() plt.show() ################################################# ## Display final occupation ################################################# ## load the final iteration of G_{flavor=0}(tau) data_G_tau = pyalps.loadMeasurements(res_files, respath='/simulation/results/G_tau', what=listobs, verbose=False) print("Occupation in the last iteration at flavor=0") for d in pyalps.flatten(data_G_tau): # obtain occupation using relation: = - d.y = np.array([-d.y[-1]]) print("n_0(beta =",d.props['BETA'],") =",d.y[0]) d.x = np.array([0]) d.props['observable'] = 'occupation' occupation = pyalps.collectXY(data_G_tau, 'BETA', 'occupation') for d in occupation: d.props['line']="scatter" plt.figure() pyalps.plot.plot(occupation) plt.xlabel(r'$\beta$') plt.ylabel(r'$n_{flavor=0}$') plt.title('Occupation versus BETA') plt.show() ############################################################################# ## Display all iterations of the Green's function in Matsubara representation ############################################################################# ## load all iterations of G_{flavor=0}(i omega_n) data = pyalps.loadDMFTIterations(pyalps.getResultFiles(pattern='parm_*.h5'), observable="G_omega", measurements=listobs, verbose=False) ## create a figure for each BETA grouped = pyalps.groupSets(pyalps.flatten(data), ['BETA']) for sim in grouped: common_props = pyalps.dict_intersect([ d.props for d in sim ]) ## rescale x-axis and set label for d in sim: d.x = np.array([(2.*n+1)*pi/common_props['BETA'] for n in d.x]) d.y = np.array(d.y.imag) d.props['label'] = "it"+d.props['iteration'] d.props['line']="scatter" d.props['fillmarkers'] = False ## plot all iterations for this BETA plt.figure() plt.xlabel(r'$i\omega_n$') plt.ylabel(r'$Im\ G_{flavor=0}(i\omega_n)$') plt.title('Simulation at ' + r'$\beta = {beta}$'.format(beta=common_props['BETA'])) pyalps.plot.plot(sim) plt.legend() plt.show() ############################################################################# ## Display all iterations of the selfenergy in Matsubara representation ############################################################################# ## load all iterations of G_{flavor=0}(i omega_n) and G0_{flavor=0}(i omega_n) data_G = pyalps.loadDMFTIterations(pyalps.getResultFiles(pattern='parm_*.h5'), observable="G_omega", measurements=listobs, verbose=False) data_G0 = pyalps.loadDMFTIterations(pyalps.getResultFiles(pattern='parm_*.h5'), observable="G0_omega", measurements=listobs, verbose=False) ## create a figure for each BETA grouped_G = pyalps.groupSets(pyalps.flatten(data_G), ['BETA','observable']) for sim in grouped_G: common_props = pyalps.dict_intersect([ d.props for d in sim ]) ## compute selfenergy using the Dyson equation, rescale x-axis and set label for d_G in sim: # find corresponding dataset from data_G0 d_G0 = [s for s in pyalps.flatten(data_G0) if s.props['iteration']==d_G.props['iteration'] and s.props['BETA']==common_props['BETA']][0] d_G.x = np.array([(2.*n+1)*pi/common_props['BETA'] for n in d_G.x]) # Dyson equation Sigma = np.array([1./d_G0.y[w] - 1./d_G.y[w] for w in range(len(d_G.y))]) d_G.y = np.array(Sigma.imag) d_G.props['label'] = "it"+d_G.props['iteration'] d_G.props['line']="scatter" d_G.props['fillmarkers'] = False ## plot all iterations for this BETA plt.figure() plt.xlabel(r'$i\omega_n$') plt.ylabel(r'$Im\ \Sigma_{flavor=0}(i\omega_n)$') plt.title('Simulation at ' + r'$\beta = {beta}$'.format(beta=common_props['BETA'])) pyalps.plot.plot(sim) plt.legend() plt.show()