3
0
mirror of https://github.com/triqs/dft_tools synced 2024-09-01 08:43:41 +02:00

Simplified fleur converter

This commit is contained in:
Priyanka Seth 2015-04-08 12:09:53 +02:00 committed by Priyanka Seth
parent d99e43161c
commit 5450f0a050

View File

@ -31,9 +31,8 @@ class FleurConverter(ConverterTools):
""" """
def __init__(self, filename, hdf_filename = None, def __init__(self, filename, hdf_filename = None,
dft_subgrp = 'dft_input', symmcorr_subgrp = 'dft_symmcorr_input', dft_subgrp = 'dft_input', parproj_subgrp='dft_parproj_input',
parproj_subgrp='dft_parproj_input', symmpar_subgrp='dft_symmpar_input', repacking = False):
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. Init of the class. Variable filename gives the root of all filenames, e.g. case.ctqmcout, case.h5, and so on.
""" """
@ -42,15 +41,9 @@ class FleurConverter(ConverterTools):
if hdf_filename is None: hdf_filename = filename if hdf_filename is None: hdf_filename = filename
self.hdf_file = hdf_filename+'.h5' self.hdf_file = hdf_filename+'.h5'
self.dft_file = filename+'.ctqmcout' self.dft_file = filename+'.ctqmcout'
self.symmcorr_file = filename+'.symqmc'
self.parproj_file = filename+'.parproj' self.parproj_file = filename+'.parproj'
self.symmpar_file = filename+'.sympar'
self.band_file = filename+'.outband'
self.dft_subgrp = dft_subgrp self.dft_subgrp = dft_subgrp
self.symmcorr_subgrp = symmcorr_subgrp
self.parproj_subgrp = parproj_subgrp self.parproj_subgrp = parproj_subgrp
self.symmpar_subgrp = symmpar_subgrp
self.bands_subgrp = bands_subgrp
self.fortran_to_replace = {'D':'E'} self.fortran_to_replace = {'D':'E'}
# Checks if h5 file is there and repacks it if wanted: # Checks if h5 file is there and repacks it if wanted:
@ -59,7 +52,7 @@ class FleurConverter(ConverterTools):
ConverterTools.repack(self) ConverterTools.repack(self)
def convert_dmft_input(self): def convert_dft_input(self):
""" """
Reads the input files, and stores the data in the HDFfile Reads the input files, and stores the data in the HDFfile
""" """
@ -78,7 +71,7 @@ class FleurConverter(ConverterTools):
SO = int(R.next()) # flag for spin-orbit calculation SO = int(R.next()) # flag for spin-orbit calculation
charge_below = R.next() # total charge below energy window charge_below = R.next() # total charge below energy window
density_required = R.next() # total density required, for setting the chemical potential density_required = R.next() # total density required, for setting the chemical potential
symm_op = 1 # Use symmetry groups for the k-sum symm_op = 0 # Use symmetry groups for the k-sum
# the information on the non-correlated shells is not important here, maybe skip: # the information on the non-correlated shells is not important here, maybe skip:
n_shells = int(R.next()) # number of shells (e.g. Fe d, As p, O p) in the unit cell, n_shells = int(R.next()) # number of shells (e.g. Fe d, As p, O p) in the unit cell,
@ -201,9 +194,6 @@ class FleurConverter(ConverterTools):
for it in things_to_save: ar[self.dft_subgrp][it] = locals()[it] for it in things_to_save: ar[self.dft_subgrp][it] = locals()[it]
del ar del ar
# Symmetries are used, so now convert symmetry information for *correlated* orbitals:
self.convert_symmetry_input(orbits=corr_shells,symm_file=self.symmcorr_file,symm_subgrp=self.symmcorr_subgrp,SO=self.SO,SP=self.SP)
def convert_parproj_input(self): def convert_parproj_input(self):
""" """
@ -276,151 +266,3 @@ class FleurConverter(ConverterTools):
things_to_save = ['dens_mat_below','n_parproj','proj_mat_pc','rot_mat_all','rot_mat_all_time_inv'] things_to_save = ['dens_mat_below','n_parproj','proj_mat_pc','rot_mat_all','rot_mat_all_time_inv']
for it in things_to_save: ar[self.parproj_subgrp][it] = locals()[it] for it in things_to_save: ar[self.parproj_subgrp][it] = locals()[it]
del ar del ar
# Symmetries are used, so now convert symmetry information for *all* orbitals:
self.convert_symmetry_input(orbits=self.shells,symm_file=self.symmpar_file,symm_subgrp=self.symmpar_subgrp,SO=self.SO,SP=self.SP)
def convert_bands_input(self):
"""
Converts the input for momentum resolved spectral functions, and stores it in bands_subgrp in the
HDF5.
"""
if not (mpi.is_master_node()): return
mpi.report("Reading bands input from %s..."%self.band_file)
R = ConverterTools.read_fortran_file(self,self.band_file,self.fortran_to_replace)
try:
n_k = int(R.next())
# read the list of n_orbitals for all k points
n_orbitals = numpy.zeros([n_k,self.n_spin_blocs],numpy.int)
for isp in range(self.n_spin_blocs):
for ik in range(n_k):
n_orbitals[ik,isp] = int(R.next())
# Initialise the projectors:
proj_mat = numpy.zeros([n_k,self.n_spin_blocs,self.n_corr_shells,max([crsh['dim'] for crsh in corr_shells]),max(n_orbitals)],numpy.complex_)
# Read the projectors from the file:
for ik in range(n_k):
for icrsh in range(self.n_corr_shells):
n_orb = self.corr_shells[icrsh]['dim']
# first Real part for BOTH spins, due to conventions in dmftproj:
for isp in range(self.n_spin_blocs):
for i in range(n_orb):
for j in range(n_orbitals[ik,isp]):
proj_mat[ik,isp,icrsh,i,j] = R.next()
# now Imag part:
for isp in range(self.n_spin_blocs):
for i in range(n_orb):
for j in range(n_orbitals[ik,isp]):
proj_mat[ik,isp,icrsh,i,j] += 1j * R.next()
hopping = numpy.zeros([n_k,self.n_spin_blocs,max(n_orbitals),max(n_orbitals)],numpy.complex_)
# Grab the H
# we use now the convention of a DIAGONAL Hamiltonian!!!!
for isp in range(self.n_spin_blocs):
for ik in range(n_k) :
n_orb = n_orbitals[ik,isp]
for i in range(n_orb):
hopping[ik,isp,i,i] = R.next() * self.energy_unit
# now read the partial projectors:
n_parproj = [int(R.next()) for i in range(self.n_shells)]
n_parproj = numpy.array(n_parproj)
# 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([sh['dim'] for sh in self.shells]),max(n_orbitals)],numpy.complex_)
for ish in range(self.n_shells):
for ik in range(n_k):
for ir in range(n_parproj[ish]):
for isp in range(self.n_spin_blocs):
for i in range(self.shells[ish]['dim']): # read real part:
for j in range(n_orbitals[ik,isp]):
proj_mat_pc[ik,isp,ish,ir,i,j] = R.next()
for i in range(self.shells[ish]['dim']): # read imaginary part:
for j in range(n_orbitals[ik,isp]):
proj_mat_pc[ik,isp,ish,ir,i,j] += 1j * R.next()
except StopIteration : # a more explicit error if the file is corrupted.
raise "Fleur_converter : reading file band_file failed!"
R.close()
# Reading done!
# Save it to the HDF:
ar = HDFArchive(self.hdf_file,'a')
if not (self.bands_subgrp in ar): ar.create_group(self.bands_subgrp)
# The subgroup containing the data. If it does not exist, it is created. If it exists, the data is overwritten!
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):
"""
Reads input for the symmetrisations from symm_file, which is case.sympar or case.symqmc.
"""
if not (mpi.is_master_node()): return
mpi.report("Reading symmetry input from %s..."%symm_file)
n_orbits = len(orbits)
R = ConverterTools.read_fortran_file(self,symm_file,self.fortran_to_replace)
try:
n_symm = int(R.next()) # Number of symmetry operations
n_atoms = int(R.next()) # number of atoms involved
perm = [ [int(R.next()) for i in range(n_atoms)] for j in range(n_symm) ] # list of permutations of the atoms
if SP:
time_inv = [ int(R.next()) for j in range(n_symm) ] # time inversion for SO coupling
else:
time_inv = [ 0 for j in range(n_symm) ]
# Now read matrices:
mat = []
for i_symm in range(n_symm):
mat.append( [ numpy.zeros([orbits[orb]['dim'], orbits[orb]['dim']],numpy.complex_) for orb in range(n_orbits) ] )
for orb in range(n_orbits):
for i in range(orbits[orb]['dim']):
for j in range(orbits[orb]['dim']):
mat[i_symm][orb][i,j] = R.next() # real part
for i in range(orbits[orb]['dim']):
for j in range(orbits[orb]['dim']):
mat[i_symm][orb][i,j] += 1j * R.next() # imaginary part
mat_tinv = [numpy.identity(orbits[orb]['dim'],numpy.complex_)
for orb in range(n_orbits)]
if ((SO==0) and (SP==0)):
# here we need an additional time inversion operation, so read it:
for orb in range(n_orbits):
for i in range(orbits[orb]['dim']):
for j in range(orbits[orb]['dim']):
mat_tinv[orb][i,j] = R.next() # real part
for i in range(orbits[orb]['dim']):
for j in range(orbits[orb]['dim']):
mat_tinv[orb][i,j] += 1j * R.next() # imaginary part
except StopIteration : # a more explicit error if the file is corrupted.
raise "Fleur_converter : reading file symm_file failed!"
R.close()
# Reading done!
# Save it to the HDF:
ar=HDFArchive(self.hdf_file,'a')
if not (symm_subgrp in ar): ar.create_group(symm_subgrp)
things_to_save = ['n_symm','n_atoms','perm','orbits','SO','SP','time_inv','mat','mat_tinv']
for it in things_to_save: ar[symm_subgrp][it] = locals()[it]
del ar