mirror of
https://github.com/triqs/dft_tools
synced 2024-11-06 22:23:52 +01:00
New test added for build_sigma_from_txt.py
This commit is contained in:
parent
9935aa552d
commit
61747745f4
@ -1,3 +1,7 @@
|
|||||||
|
import numpy
|
||||||
|
import string
|
||||||
|
from pytriqs.gf.local import *
|
||||||
|
|
||||||
def read_fortran_file (filename):
|
def read_fortran_file (filename):
|
||||||
""" Returns a generator that yields all numbers in the Fortran file as float, one by one"""
|
""" Returns a generator that yields all numbers in the Fortran file as float, one by one"""
|
||||||
import os.path
|
import os.path
|
||||||
@ -17,6 +21,7 @@ def constr_Sigma_real_axis(self, filename, hdf=True, hdf_dataset='SigmaReFreq',n
|
|||||||
if (len(ol)==1): # if blocks are of size one
|
if (len(ol)==1): # if blocks are of size one
|
||||||
Fname = filename+'_'+bl+'.dat'
|
Fname = filename+'_'+bl+'.dat'
|
||||||
else:
|
else:
|
||||||
|
print 'TEST'
|
||||||
Fname = filename+'_'+bl+'/'+str(ol[0])+'_'+str(ol[0])+'.dat'
|
Fname = filename+'_'+bl+'/'+str(ol[0])+'_'+str(ol[0])+'.dat'
|
||||||
|
|
||||||
R = read_fortran_file(Fname)
|
R = read_fortran_file(Fname)
|
||||||
|
@ -7,3 +7,4 @@ triqs_add_test_hdf(hk_convert " -p 1.e-6" )
|
|||||||
triqs_add_test_hdf(sumkdft_basic " -d 1.e-6" )
|
triqs_add_test_hdf(sumkdft_basic " -d 1.e-6" )
|
||||||
triqs_add_test_hdf(srvo3_Gloc " -d 1.e-6" )
|
triqs_add_test_hdf(srvo3_Gloc " -d 1.e-6" )
|
||||||
triqs_add_test_hdf(srvo3_transp " -d 1.e-6" )
|
triqs_add_test_hdf(srvo3_transp " -d 1.e-6" )
|
||||||
|
triqs_add_test_hdf(sigma_from_file " -d 1.e-6" )
|
||||||
|
BIN
test/sigma_from_file.output.h5
Normal file
BIN
test/sigma_from_file.output.h5
Normal file
Binary file not shown.
30
test/sigma_from_file.py
Normal file
30
test/sigma_from_file.py
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
from pytriqs.archive import *
|
||||||
|
from pytriqs.gf.local 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
|
||||||
|
ar = HDFArchive('SrVO3_Sigma.h5','r')
|
||||||
|
Sigma_hdf = ar['dmft_transp_input']['Sigma_w']
|
||||||
|
|
||||||
|
# Save self energy to txt files
|
||||||
|
for name, s in Sigma_hdf:
|
||||||
|
mesh = np.array([p for p in s.mesh]).reshape(-1,1).real
|
||||||
|
re_data = s.data.real.reshape((s.data.shape[0],-1))
|
||||||
|
im_data = s.data.imag.reshape((s.data.shape[0],-1))
|
||||||
|
|
||||||
|
mesh_a_data = np.hstack((mesh,re_data,im_data))
|
||||||
|
np.savetxt('Sigma_' + name + '.dat', mesh_a_data)
|
||||||
|
|
||||||
|
# Read self energy from txt files
|
||||||
|
SK = SumkDFTTools(hdf_file = 'SrVO3.h5', use_dft_blocks = True)
|
||||||
|
Sigma_txt = constr_Sigma_real_axis(SK, 'Sigma', hdf=False, n_om=101, orb=0)
|
||||||
|
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!'
|
Loading…
Reference in New Issue
Block a user