3
0
mirror of https://github.com/triqs/dft_tools synced 2024-07-04 18:36:05 +02:00

Allow for hdf filename that differs from dft data basename

This commit is contained in:
Priyanka Seth 2014-11-19 16:38:52 +01:00
parent 88f4105e5b
commit 84bd1ed655
3 changed files with 15 additions and 17 deletions

View File

@ -32,14 +32,14 @@ class HkConverter(ConverterTools):
Conversion from general H(k) file to an hdf5 file that can be used as input for the SumKDFT class.
"""
def __init__(self, hk_file, hdf_file, dft_subgrp = 'dft_input', symmcorr_subgrp = 'dft_symmcorr_input', repacking = False):
def __init__(self, hk_filename, hdf_filename, dft_subgrp = 'dft_input', symmcorr_subgrp = 'dft_symmcorr_input', repacking = False):
"""
Init of the class.
"""
assert type(hk_file)==StringType,"hk_file must be a filename"
self.hdf_file = hdf_file
self.dft_file = hk_file
assert type(hk_filename)==StringType,"HkConverter: hk_filename must be a filename."
self.hdf_file = hdf_filename
self.dft_file = hk_filename
self.dft_subgrp = dft_subgrp
self.symmcorr_subgrp = symmcorr_subgrp
self.fortran_to_replace = {'D':'E', '(':' ', ')':' ', ',':' '}
@ -152,8 +152,8 @@ class HkConverter(ConverterTools):
for isp in range(n_spin_blocs):
for ik in xrange(n_k) :
no = n_orbitals[ik,isp]
# IF TRUE, FIRST READ ALL REAL COMPONENTS OF ONE kPOINT, OTHERWISE TUPLE OF real,im
if (first_real_part_matrix):
if (first_real_part_matrix): # first read all real components for given k, then read imaginary parts
for i in xrange(no):
if (only_upper_triangle):
@ -172,7 +172,7 @@ class HkConverter(ConverterTools):
hopping[ik,isp,i,j] += R.next() * 1j
if ((only_upper_triangle)and(i!=j)): hopping[ik,isp,j,i] = hopping[ik,isp,i,j].conjugate()
else:
else: # read (real,im) tuple
for i in xrange(no):
if (only_upper_triangle):
@ -200,4 +200,4 @@ class HkConverter(ConverterTools):
'rot_mat_time_inv','n_reps','dim_reps','T','n_orbitals','proj_mat','bz_weights','hopping',
'n_inequiv_shells', 'corr_to_inequiv', 'inequiv_to_corr']
for it in things_to_save: ar[self.dft_subgrp][it] = locals()[it]
del ar
del ar

View File

@ -31,15 +31,17 @@ class Wien2kConverter(ConverterTools):
Conversion from Wien2k output to an hdf5 file that can be used as input for the SumkDFT class.
"""
def __init__(self, filename, dft_subgrp = 'dft_input', symmcorr_subgrp = 'dft_symmcorr_input',
parproj_subgrp='dft_parproj_input', symmpar_subgrp='dft_symmpar_input',
bands_subgrp = 'dft_bands_input', repacking = False):
def __init__(self, filename, hdf_filename = None,
dft_subgrp = 'dft_input', symmcorr_subgrp = 'dft_symmcorr_input',
parproj_subgrp='dft_parproj_input', symmpar_subgrp='dft_symmpar_input',
bands_subgrp = 'dft_bands_input', repacking = False):
"""
Init of the class. Variable filename gives the root of all filenames, e.g. case.ctqmcout, case.h5, and so on.
"""
assert type(filename)==StringType, "Please provide the DFT files' base name as a string."
self.hdf_file = filename+'.h5'
if hdf_filename is None: hdf_filename = filename
self.hdf_file = hdf_filename+'.h5'
self.dft_file = filename+'.ctqmcout'
self.symmcorr_file = filename+'.symqmc'
self.parproj_file = filename+'.parproj'
@ -57,7 +59,6 @@ class Wien2kConverter(ConverterTools):
if (os.path.exists(self.hdf_file) and repacking):
ConverterTools.__repack(self)
def convert_dmft_input(self):
"""
@ -332,9 +333,7 @@ class Wien2kConverter(ConverterTools):
# Initialise P, here a double list of matrices:
proj_mat_pc = numpy.zeros([n_k,self.n_spin_blocs,self.n_shells,max(n_parproj),max(numpy.array(self.shells)[:,3]),max(n_orbitals)],numpy.complex_)
for ish in range(self.n_shells):
for ik in xrange(n_k):
for ir in range(n_parproj[ish]):
for isp in range(self.n_spin_blocs):
@ -360,7 +359,6 @@ class Wien2kConverter(ConverterTools):
things_to_save = ['n_k','n_orbitals','proj_mat','hopping','n_parproj','proj_mat_pc']
for it in things_to_save: ar[self.bands_subgrp][it] = locals()[it]
del ar
def convert_symmetry_input(self, orbits, symm_file, symm_subgrp, SO, SP):

View File

@ -24,6 +24,6 @@
from pytriqs.applications.dft.converters import *
from pytriqs.archive import *
Converter = HkConverter(hk_file='hk_convert_hamiltonian.hk',hdf_file='hk_convert.output.h5')
Converter = HkConverter(hk_filename='hk_convert_hamiltonian.hk',hdf_filename='hk_convert.output.h5')
Converter.convert_dmft_input()