From 29d2bf8d500b24dbba70de72b9ae364ac27f7254 Mon Sep 17 00:00:00 2001 From: Manuel Zingl Date: Thu, 17 Sep 2015 10:03:07 +0200 Subject: [PATCH] sigma_from_file changed to read function of gf build_sigma_from_txt.py deleted as reading a gf from a file is now implemented in gf.local.tools --- python/build_sigma_from_txt.py | 77 --------------------------------- test/sigma_from_file.output.h5 | Bin 51312 -> 54112 bytes test/sigma_from_file.py | 9 ++-- 3 files changed, 6 insertions(+), 80 deletions(-) delete mode 100644 python/build_sigma_from_txt.py diff --git a/python/build_sigma_from_txt.py b/python/build_sigma_from_txt.py deleted file mode 100644 index 6e64fc52..00000000 --- a/python/build_sigma_from_txt.py +++ /dev/null @@ -1,77 +0,0 @@ -import numpy -import string -from pytriqs.gf.local import * - -def read_fortran_file (filename): - """Returns a generator that yields all numbers in the Fortran file as float, one by one""" - import os.path - if not(os.path.exists(filename)) : raise IOError, "File %s does not exist."%filename - for line in open(filename,'r') : - for x in line.replace('D','E').split() : - yield string.atof(x) - -def line_count(fname): - """Counts the lines of a file""" - with open(fname) as f: - for i, l in enumerate(f): - pass - return i + 1 - -def constr_Sigma_real_axis(filename, gf_struct_orb, tol_mesh=1e-6): - """Uses Data from files to construct Sigma (or GF) on the real axis.""" - - # first get the mesh out of any one of the files: - bl = gf_struct_orb.items()[0][0] # block name - ol = gf_struct_orb.items()[0][1] # list of orbital indices - if (len(ol)==1): # if blocks are of size one - Fname = filename+'_'+bl+'.dat' - else: - Fname = filename+'_'+bl+'/'+str(ol[0])+'_'+str(ol[0])+'.dat' - - try: - n_om = line_count(Fname) - R = read_fortran_file(Fname) - mesh = numpy.zeros([n_om],numpy.float_) - - for i in xrange(n_om): - mesh[i] = R.next() - sk = R.next() - sk = R.next() - - except StopIteration : # a more explicit error if the file is corrupted. - raise "constr_Sigma_real_axis : reading mesh failed!" - R.close() - - # check whether the mesh is uniform - bin = (mesh[n_om-1]-mesh[0])/(n_om-1) - for i in xrange(n_om): - assert abs(i*bin+mesh[0]-mesh[i]) < tol_mesh, 'constr_Sigma_real_axis: real-axis mesh is non-uniform!' - - # construct Sigma - a_list = [a for a,al in gf_struct_orb.iteritems()] - glist = lambda : [ GfReFreq(indices = al, window=(mesh[0],mesh[n_om-1]),n_points=n_om) for a,al in gf_struct_orb.iteritems()] - SigmaME = BlockGf(name_list = a_list, block_list = glist(),make_copies=False) - - #read Sigma - for i,g in SigmaME: - mesh=[w for w in g.mesh] - for iL in g.indices: - for iR in g.indices: - if (len(g.indices) == 1): - Fname = filename+'_%s'%(i)+'.dat' - else: - Fname = 'SigmaME_'+'%s'%(i)+'_%s'%(iL)+'_%s'%(iR)+'.dat' - R = read_fortran_file(Fname) - try: - for iom in xrange(n_om): - sk = R.next() - rsig = R.next() - isig = R.next() - g.data[iom,iL,iR]=rsig+1j*isig - except StopIteration : # a more explicit error if the file is corrupted. - raise "constr_Sigma_real_axis : reading Sigma from file failed!" - R.close() - - SigmaME.note='ReFreq' - - return SigmaME diff --git a/test/sigma_from_file.output.h5 b/test/sigma_from_file.output.h5 index 47dee8e441915cc84633f83f40da6b72ae78e241..3381c3216f50c369e1ea413de37929bec06abab2 100644 GIT binary patch delta 1950 zcmZWqUrbw77{B+h*?U`ocI`&1qa1vyePT0HT+~#uIG*qpO4l$_D-C}J8?+1)9{b>v zQPcV*1{n|Rg&@gXk7Wrn&OrpJ8;<(tfvCx9mMqI+3`fnM3PX@h^8aYY+4#P~G*33*jhMVyW#QLdT zv?-;>&X|Qj+M$t2D@;40upOe19h)f$zvp_N6s#HMg`!Ivp3kC+ih~mS2`8yd9I4zd zUc`whXZ(QcL>@=Glv}Ej^VQ-(dwqt@i6BYA&KBwj(4acJn(s{g_t!RAtIyTLC> zU`@o9Uek#CkeF?EYGj#f--lw?xVi&fp=JyJ>25_yWY`BVKWJ#D2Ri%T8ShU*%1I$& zqq;ALUbWn#=wlW9mIiGccOn_qkV{MyS{+>-@19bX8pSOmrw}~cRPt*#OuzGe(l0r6 z4MHKh*D+<6)En?|H$rf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OS2*;(g_7F2%?r}S{H9q%RDHiK~j--wybE&wOi9+<_S2}qs= zbL7J4P9wf?CM3=%L_KxwB??(2_2l@lya#*(Q545kh(gcs5tWeU5~Lo`i&>(+*oRr+ zB`F8;z+46}A`hOju*kR9u5+TX&G* z`Jqc09`Q}KU-*rL%<@B(fuH*r(9pT<=8&+Wp1{=V9(I2J$8Vg|UpxG)G=RffR#Hrn Me(BFDYz?&h1+dP-yZ`_I diff --git a/test/sigma_from_file.py b/test/sigma_from_file.py index b033d9e9..fb5ffd82 100644 --- a/test/sigma_from_file.py +++ b/test/sigma_from_file.py @@ -1,7 +1,7 @@ from pytriqs.archive import * from pytriqs.gf.local import * +from pytriqs.gf.local.tools import * from pytriqs.applications.dft.sumk_dft_tools import * -from pytriqs.applications.dft.build_sigma_from_txt import * import numpy as np # Read self energy from hdf file @@ -19,12 +19,15 @@ for name, s in Sigma_hdf: # Read self energy from txt files SK = SumkDFTTools(hdf_file = 'SrVO3.h5', use_dft_blocks = True) -Sigma_txt = constr_Sigma_real_axis(filename='Sigma', gf_struct_orb=SK.gf_struct_solver[0]) + +a_list = [a for a,al in SK.gf_struct_solver[0].iteritems()] +g_list = [read_gf_from_txt([['Sigma_' + a + '.dat']], a) for a in a_list] +Sigma_txt = BlockGf(name_list = a_list, block_list = g_list, make_copies=False) + SK.put_Sigma(Sigma_imp = [Sigma_txt]) SK.hdf_file = 'sigma_from_file.output.h5' SK.save(['Sigma_imp_w']) - if ((Sigma_txt - Sigma_hdf).real < 1e-6) & ((Sigma_txt - Sigma_hdf).imag < 1e-6): print 'Conversion: HDF -> TRIQS -> TXT -> TRIQS successful!'