2013-07-23 19:49:42 +02:00
|
|
|
|
|
|
|
################################################################################
|
|
|
|
#
|
|
|
|
# TRIQS: a Toolbox for Research in Interacting Quantum Systems
|
|
|
|
#
|
|
|
|
# Copyright (C) 2011 by M. Aichhorn, L. Pourovskii, V. Vildosola
|
|
|
|
#
|
|
|
|
# TRIQS is free software: you can redistribute it and/or modify it under the
|
|
|
|
# terms of the GNU General Public License as published by the Free Software
|
|
|
|
# Foundation, either version 3 of the License, or (at your option) any later
|
|
|
|
# version.
|
|
|
|
#
|
|
|
|
# TRIQS is distributed in the hope that it will be useful, but WITHOUT ANY
|
|
|
|
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
|
|
|
# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
|
|
|
# details.
|
|
|
|
#
|
|
|
|
# You should have received a copy of the GNU General Public License along with
|
|
|
|
# TRIQS. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
#
|
|
|
|
################################################################################
|
|
|
|
|
|
|
|
from types import *
|
2014-12-09 16:47:40 +01:00
|
|
|
import numpy
|
2013-07-23 19:49:42 +02:00
|
|
|
from pytriqs.archive import *
|
2014-11-08 23:51:24 +01:00
|
|
|
from converter_tools import *
|
2014-11-20 13:17:46 +01:00
|
|
|
import os.path
|
2013-07-23 19:49:42 +02:00
|
|
|
|
2014-11-08 23:51:24 +01:00
|
|
|
class Wien2kConverter(ConverterTools):
|
2013-07-23 19:49:42 +02:00
|
|
|
"""
|
2014-11-18 11:30:26 +01:00
|
|
|
Conversion from Wien2k output to an hdf5 file that can be used as input for the SumkDFT class.
|
2013-07-23 19:49:42 +02:00
|
|
|
"""
|
|
|
|
|
2014-11-19 16:38:52 +01:00
|
|
|
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',
|
2015-02-10 11:55:44 +01:00
|
|
|
bands_subgrp = 'dft_bands_input', misc_subgrp = 'dft_misc_input',
|
|
|
|
transp_subgrp = 'dft_transp_input', repacking = False):
|
2013-07-23 19:49:42 +02:00
|
|
|
"""
|
2014-09-22 19:24:33 +02:00
|
|
|
Init of the class. Variable filename gives the root of all filenames, e.g. case.ctqmcout, case.h5, and so on.
|
2013-07-23 19:49:42 +02:00
|
|
|
"""
|
|
|
|
|
2014-11-18 11:30:26 +01:00
|
|
|
assert type(filename)==StringType, "Please provide the DFT files' base name as a string."
|
2014-11-19 16:38:52 +01:00
|
|
|
if hdf_filename is None: hdf_filename = filename
|
|
|
|
self.hdf_file = hdf_filename+'.h5'
|
2014-11-18 11:30:26 +01:00
|
|
|
self.dft_file = filename+'.ctqmcout'
|
2014-11-03 14:47:55 +01:00
|
|
|
self.symmcorr_file = filename+'.symqmc'
|
2013-07-23 19:49:42 +02:00
|
|
|
self.parproj_file = filename+'.parproj'
|
|
|
|
self.symmpar_file = filename+'.sympar'
|
|
|
|
self.band_file = filename+'.outband'
|
2015-02-10 11:55:44 +01:00
|
|
|
self.bandwin_file = filename+'.oubwin'
|
|
|
|
self.struct_file = filename+'.struct'
|
|
|
|
self.outputs_file = filename+'.outputs'
|
|
|
|
self.pmat_file = filename+'.pmat'
|
2014-11-18 11:30:26 +01:00
|
|
|
self.dft_subgrp = dft_subgrp
|
2014-11-03 14:47:55 +01:00
|
|
|
self.symmcorr_subgrp = symmcorr_subgrp
|
|
|
|
self.parproj_subgrp = parproj_subgrp
|
|
|
|
self.symmpar_subgrp = symmpar_subgrp
|
|
|
|
self.bands_subgrp = bands_subgrp
|
2015-02-10 11:55:44 +01:00
|
|
|
self.misc_subgrp = misc_subgrp
|
2014-11-03 11:16:32 +01:00
|
|
|
self.transp_subgrp = transp_subgrp
|
2014-11-08 23:51:24 +01:00
|
|
|
self.fortran_to_replace = {'D':'E'}
|
2013-07-23 19:49:42 +02:00
|
|
|
|
|
|
|
# Checks if h5 file is there and repacks it if wanted:
|
|
|
|
if (os.path.exists(self.hdf_file) and repacking):
|
2014-11-19 18:50:53 +01:00
|
|
|
ConverterTools.repack(self)
|
2014-11-20 13:17:46 +01:00
|
|
|
|
2013-07-23 19:49:42 +02:00
|
|
|
|
2014-12-09 12:26:00 +01:00
|
|
|
def convert_dft_input(self):
|
2013-07-23 19:49:42 +02:00
|
|
|
"""
|
|
|
|
Reads the input files, and stores the data in the HDFfile
|
|
|
|
"""
|
|
|
|
|
2014-09-22 19:24:33 +02:00
|
|
|
# Read and write only on the master node
|
|
|
|
if not (mpi.is_master_node()): return
|
2014-11-18 11:30:26 +01:00
|
|
|
mpi.report("Reading input from %s..."%self.dft_file)
|
2013-07-23 19:49:42 +02:00
|
|
|
|
|
|
|
# R is a generator : each R.Next() will return the next number in the file
|
2014-11-18 11:30:26 +01:00
|
|
|
R = ConverterTools.read_fortran_file(self,self.dft_file,self.fortran_to_replace)
|
2013-07-23 19:49:42 +02:00
|
|
|
try:
|
2014-11-26 16:24:02 +01:00
|
|
|
energy_unit = R.next() # read the energy convertion factor
|
|
|
|
n_k = int(R.next()) # read the number of k points
|
2013-07-23 19:49:42 +02:00
|
|
|
k_dep_projection = 1
|
|
|
|
SP = int(R.next()) # flag for spin-polarised calculation
|
|
|
|
SO = int(R.next()) # flag for spin-orbit calculation
|
|
|
|
charge_below = R.next() # total charge below energy window
|
|
|
|
density_required = R.next() # total density required, for setting the chemical potential
|
|
|
|
symm_op = 1 # Use symmetry groups for the k-sum
|
|
|
|
|
|
|
|
# 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,
|
2014-11-26 16:24:02 +01:00
|
|
|
# corresponds to index R in formulas
|
|
|
|
# now read the information about the shells (atom, sort, l, dim):
|
|
|
|
shell_entries = ['atom', 'sort', 'l', 'dim']
|
|
|
|
shells = [ {name: int(val) for name, val in zip(shell_entries, R)} for ish in range(n_shells) ]
|
2014-09-22 19:24:33 +02:00
|
|
|
|
2013-07-23 19:49:42 +02:00
|
|
|
n_corr_shells = int(R.next()) # number of corr. shells (e.g. Fe d, Ce f) in the unit cell,
|
|
|
|
# corresponds to index R in formulas
|
2014-11-26 16:24:02 +01:00
|
|
|
# now read the information about the shells (atom, sort, l, dim, SO flag, irep):
|
|
|
|
corr_shell_entries = ['atom', 'sort', 'l', 'dim', 'SO', 'irep']
|
|
|
|
corr_shells = [ {name: int(val) for name, val in zip(corr_shell_entries, R)} for icrsh in range(n_corr_shells) ]
|
2013-07-23 19:49:42 +02:00
|
|
|
|
2014-11-15 18:15:45 +01:00
|
|
|
# determine the number of inequivalent correlated shells and maps, needed for further reading
|
2014-11-26 16:24:02 +01:00
|
|
|
n_inequiv_shells, corr_to_inequiv, inequiv_to_corr = ConverterTools.det_shell_equivalence(self,corr_shells)
|
2013-07-23 19:49:42 +02:00
|
|
|
|
|
|
|
use_rotations = 1
|
2014-11-26 16:24:02 +01:00
|
|
|
rot_mat = [numpy.identity(corr_shells[icrsh]['dim'],numpy.complex_) for icrsh in range(n_corr_shells)]
|
2013-07-23 19:49:42 +02:00
|
|
|
|
|
|
|
# read the matrices
|
|
|
|
rot_mat_time_inv = [0 for i in range(n_corr_shells)]
|
|
|
|
|
2014-11-26 16:24:02 +01:00
|
|
|
for icrsh in range(n_corr_shells):
|
|
|
|
for i in range(corr_shells[icrsh]['dim']): # read real part:
|
|
|
|
for j in range(corr_shells[icrsh]['dim']):
|
2013-07-23 19:49:42 +02:00
|
|
|
rot_mat[icrsh][i,j] = R.next()
|
2014-11-26 16:24:02 +01:00
|
|
|
for i in range(corr_shells[icrsh]['dim']): # read imaginary part:
|
|
|
|
for j in range(corr_shells[icrsh]['dim']):
|
2013-07-23 19:49:42 +02:00
|
|
|
rot_mat[icrsh][i,j] += 1j * R.next()
|
|
|
|
|
|
|
|
if (SP==1): # read time inversion flag:
|
|
|
|
rot_mat_time_inv[icrsh] = int(R.next())
|
|
|
|
|
2014-09-22 19:24:33 +02:00
|
|
|
# Read here the info for the transformation of the basis:
|
2014-11-15 18:15:45 +01:00
|
|
|
n_reps = [1 for i in range(n_inequiv_shells)]
|
|
|
|
dim_reps = [0 for i in range(n_inequiv_shells)]
|
2013-07-23 19:49:42 +02:00
|
|
|
T = []
|
2014-11-26 16:24:02 +01:00
|
|
|
for ish in range(n_inequiv_shells):
|
|
|
|
n_reps[ish] = int(R.next()) # number of representatives ("subsets"), e.g. t2g and eg
|
|
|
|
dim_reps[ish] = [int(R.next()) for i in range(n_reps[ish])] # dimensions of the subsets
|
2013-07-23 19:49:42 +02:00
|
|
|
|
2014-09-22 19:24:33 +02:00
|
|
|
# The transformation matrix:
|
|
|
|
# is of dimension 2l+1 without SO, and 2*(2l+1) with SO!
|
2014-11-26 16:24:02 +01:00
|
|
|
ll = 2*corr_shells[inequiv_to_corr[ish]]['l']+1
|
|
|
|
lmax = ll * (corr_shells[inequiv_to_corr[ish]]['SO'] + 1)
|
2013-07-23 19:49:42 +02:00
|
|
|
T.append(numpy.zeros([lmax,lmax],numpy.complex_))
|
|
|
|
|
|
|
|
# now read it from file:
|
2014-11-26 16:24:02 +01:00
|
|
|
for i in range(lmax):
|
|
|
|
for j in range(lmax):
|
|
|
|
T[ish][i,j] = R.next()
|
|
|
|
for i in range(lmax):
|
|
|
|
for j in range(lmax):
|
|
|
|
T[ish][i,j] += 1j * R.next()
|
2013-07-23 19:49:42 +02:00
|
|
|
|
|
|
|
# Spin blocks to be read:
|
|
|
|
n_spin_blocs = SP + 1 - SO
|
|
|
|
|
|
|
|
# read the list of n_orbitals for all k points
|
|
|
|
n_orbitals = numpy.zeros([n_k,n_spin_blocs],numpy.int)
|
|
|
|
for isp in range(n_spin_blocs):
|
2014-11-26 16:24:02 +01:00
|
|
|
for ik in range(n_k):
|
2013-07-23 19:49:42 +02:00
|
|
|
n_orbitals[ik,isp] = int(R.next())
|
|
|
|
|
|
|
|
# Initialise the projectors:
|
2014-11-26 16:24:02 +01:00
|
|
|
proj_mat = numpy.zeros([n_k,n_spin_blocs,n_corr_shells,max([crsh['dim'] for crsh in corr_shells]),max(n_orbitals)],numpy.complex_)
|
2014-09-22 19:24:33 +02:00
|
|
|
|
2013-07-23 19:49:42 +02:00
|
|
|
# Read the projectors from the file:
|
2014-11-26 16:24:02 +01:00
|
|
|
for ik in range(n_k):
|
2013-07-23 19:49:42 +02:00
|
|
|
for icrsh in range(n_corr_shells):
|
2014-11-26 16:24:02 +01:00
|
|
|
n_orb = corr_shells[icrsh]['dim']
|
2013-07-23 19:49:42 +02:00
|
|
|
# first Real part for BOTH spins, due to conventions in dmftproj:
|
|
|
|
for isp in range(n_spin_blocs):
|
2014-11-26 16:24:02 +01:00
|
|
|
for i in range(n_orb):
|
|
|
|
for j in range(n_orbitals[ik][isp]):
|
2013-07-23 19:49:42 +02:00
|
|
|
proj_mat[ik,isp,icrsh,i,j] = R.next()
|
|
|
|
# now Imag part:
|
|
|
|
for isp in range(n_spin_blocs):
|
2014-11-26 16:24:02 +01:00
|
|
|
for i in range(n_orb):
|
|
|
|
for j in range(n_orbitals[ik][isp]):
|
2013-07-23 19:49:42 +02:00
|
|
|
proj_mat[ik,isp,icrsh,i,j] += 1j * R.next()
|
|
|
|
|
|
|
|
# now define the arrays for weights and hopping ...
|
|
|
|
bz_weights = numpy.ones([n_k],numpy.float_)/ float(n_k) # w(k_index), default normalisation
|
|
|
|
hopping = numpy.zeros([n_k,n_spin_blocs,max(n_orbitals),max(n_orbitals)],numpy.complex_)
|
2014-09-22 19:24:33 +02:00
|
|
|
|
2013-07-23 19:49:42 +02:00
|
|
|
# weights in the file
|
2014-11-26 16:24:02 +01:00
|
|
|
for ik in range(n_k) : bz_weights[ik] = R.next()
|
2013-07-23 19:49:42 +02:00
|
|
|
|
|
|
|
# if the sum over spins is in the weights, take it out again!!
|
|
|
|
sm = sum(bz_weights)
|
|
|
|
bz_weights[:] /= sm
|
2014-09-22 19:24:33 +02:00
|
|
|
|
2013-07-23 19:49:42 +02:00
|
|
|
# Grab the H
|
2014-11-03 14:47:55 +01:00
|
|
|
# we use now the convention of a DIAGONAL Hamiltonian -- convention for Wien2K.
|
2013-07-23 19:49:42 +02:00
|
|
|
for isp in range(n_spin_blocs):
|
2014-11-26 16:24:02 +01:00
|
|
|
for ik in range(n_k) :
|
|
|
|
n_orb = n_orbitals[ik,isp]
|
|
|
|
for i in range(n_orb):
|
2013-07-23 19:49:42 +02:00
|
|
|
hopping[ik,isp,i,i] = R.next() * energy_unit
|
|
|
|
|
2014-09-22 19:24:33 +02:00
|
|
|
# keep some things that we need for reading parproj:
|
2014-10-31 18:52:32 +01:00
|
|
|
things_to_set = ['n_shells','shells','n_corr_shells','corr_shells','n_spin_blocs','n_orbitals','n_k','SO','SP','energy_unit']
|
|
|
|
for it in things_to_set: setattr(self,it,locals()[it])
|
2013-07-23 19:49:42 +02:00
|
|
|
except StopIteration : # a more explicit error if the file is corrupted.
|
2014-11-18 11:30:26 +01:00
|
|
|
raise "Wien2k_converter : reading file %s failed!"%filename
|
2013-07-23 19:49:42 +02:00
|
|
|
|
|
|
|
R.close()
|
2014-11-03 14:47:55 +01:00
|
|
|
# Reading done!
|
2013-07-23 19:49:42 +02:00
|
|
|
|
2014-11-03 14:47:55 +01:00
|
|
|
# Save it to the HDF:
|
2013-07-23 19:49:42 +02:00
|
|
|
ar = HDFArchive(self.hdf_file,'a')
|
2014-11-18 11:30:26 +01:00
|
|
|
if not (self.dft_subgrp in ar): ar.create_group(self.dft_subgrp)
|
2014-11-03 14:47:55 +01:00
|
|
|
# The subgroup containing the data. If it does not exist, it is created. If it exists, the data is overwritten!
|
2014-10-31 18:52:32 +01:00
|
|
|
things_to_save = ['energy_unit','n_k','k_dep_projection','SP','SO','charge_below','density_required',
|
|
|
|
'symm_op','n_shells','shells','n_corr_shells','corr_shells','use_rotations','rot_mat',
|
2014-11-15 18:15:45 +01:00
|
|
|
'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']
|
2014-11-18 11:30:26 +01:00
|
|
|
for it in things_to_save: ar[self.dft_subgrp][it] = locals()[it]
|
2013-07-23 19:49:42 +02:00
|
|
|
del ar
|
2014-10-31 18:52:32 +01:00
|
|
|
|
2014-11-03 14:47:55 +01:00
|
|
|
# Symmetries are used, so now convert symmetry information for *correlated* orbitals:
|
2015-01-22 14:15:29 +01:00
|
|
|
self.convert_symmetry_input(orbits=self.corr_shells,symm_file=self.symmcorr_file,symm_subgrp=self.symmcorr_subgrp,SO=self.SO,SP=self.SP)
|
2015-02-10 11:55:44 +01:00
|
|
|
self.convert_misc_input(bandwin_file=self.bandwin_file,struct_file=self.struct_file,outputs_file=self.outputs_file,
|
|
|
|
misc_subgrp=self.misc_subgrp,SO=self.SO,SP=self.SP,n_k=self.n_k)
|
2014-10-31 18:52:32 +01:00
|
|
|
|
2013-07-23 19:49:42 +02:00
|
|
|
|
2014-11-03 14:47:55 +01:00
|
|
|
def convert_parproj_input(self):
|
2013-07-23 19:49:42 +02:00
|
|
|
"""
|
2014-11-03 14:47:55 +01:00
|
|
|
Reads the input for the partial charges projectors from case.parproj, and stores it in the symmpar_subgrp
|
2013-07-23 19:49:42 +02:00
|
|
|
group in the HDF5.
|
|
|
|
"""
|
|
|
|
|
|
|
|
if not (mpi.is_master_node()): return
|
|
|
|
mpi.report("Reading parproj input from %s..."%self.parproj_file)
|
|
|
|
|
2014-11-26 16:24:02 +01:00
|
|
|
dens_mat_below = [ [numpy.zeros([self.shells[ish]['dim'],self.shells[ish]['dim']],numpy.complex_) for ish in range(self.n_shells)]
|
2013-07-23 19:49:42 +02:00
|
|
|
for isp in range(self.n_spin_blocs) ]
|
|
|
|
|
2014-11-08 23:51:24 +01:00
|
|
|
R = ConverterTools.read_fortran_file(self,self.parproj_file,self.fortran_to_replace)
|
2013-07-23 19:49:42 +02:00
|
|
|
|
|
|
|
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:
|
2015-01-22 10:47:53 +01:00
|
|
|
proj_mat_all = numpy.zeros([self.n_k,self.n_spin_blocs,self.n_shells,max(n_parproj),max([sh['dim'] for sh in self.shells]),max(self.n_orbitals)],numpy.complex_)
|
2013-07-23 19:49:42 +02:00
|
|
|
|
2014-11-26 16:24:02 +01:00
|
|
|
rot_mat_all = [numpy.identity(self.shells[ish]['dim'],numpy.complex_) for ish in range(self.n_shells)]
|
2013-07-23 19:49:42 +02:00
|
|
|
rot_mat_all_time_inv = [0 for i in range(self.n_shells)]
|
|
|
|
|
|
|
|
for ish in range(self.n_shells):
|
|
|
|
# read first the projectors for this orbital:
|
2014-11-26 16:24:02 +01:00
|
|
|
for ik in range(self.n_k):
|
2013-07-23 19:49:42 +02:00
|
|
|
for ir in range(n_parproj[ish]):
|
2014-11-03 14:47:55 +01:00
|
|
|
|
2013-07-23 19:49:42 +02:00
|
|
|
for isp in range(self.n_spin_blocs):
|
2014-11-26 16:24:02 +01:00
|
|
|
for i in range(self.shells[ish]['dim']): # read real part:
|
|
|
|
for j in range(self.n_orbitals[ik][isp]):
|
2015-01-22 10:47:53 +01:00
|
|
|
proj_mat_all[ik,isp,ish,ir,i,j] = R.next()
|
2013-07-23 19:49:42 +02:00
|
|
|
|
|
|
|
for isp in range(self.n_spin_blocs):
|
2014-11-26 16:24:02 +01:00
|
|
|
for i in range(self.shells[ish]['dim']): # read imaginary part:
|
|
|
|
for j in range(self.n_orbitals[ik][isp]):
|
2015-01-22 10:47:53 +01:00
|
|
|
proj_mat_all[ik,isp,ish,ir,i,j] += 1j * R.next()
|
2013-07-23 19:49:42 +02:00
|
|
|
|
|
|
|
|
|
|
|
# now read the Density Matrix for this orbital below the energy window:
|
|
|
|
for isp in range(self.n_spin_blocs):
|
2014-11-26 16:24:02 +01:00
|
|
|
for i in range(self.shells[ish]['dim']): # read real part:
|
|
|
|
for j in range(self.shells[ish]['dim']):
|
2013-07-23 19:49:42 +02:00
|
|
|
dens_mat_below[isp][ish][i,j] = R.next()
|
|
|
|
for isp in range(self.n_spin_blocs):
|
2014-11-26 16:24:02 +01:00
|
|
|
for i in range(self.shells[ish]['dim']): # read imaginary part:
|
|
|
|
for j in range(self.shells[ish]['dim']):
|
2013-07-23 19:49:42 +02:00
|
|
|
dens_mat_below[isp][ish][i,j] += 1j * R.next()
|
|
|
|
if (self.SP==0): dens_mat_below[isp][ish] /= 2.0
|
|
|
|
|
|
|
|
# Global -> local rotation matrix for this shell:
|
2014-11-26 16:24:02 +01:00
|
|
|
for i in range(self.shells[ish]['dim']): # read real part:
|
|
|
|
for j in range(self.shells[ish]['dim']):
|
2013-07-23 19:49:42 +02:00
|
|
|
rot_mat_all[ish][i,j] = R.next()
|
2014-11-26 16:24:02 +01:00
|
|
|
for i in range(self.shells[ish]['dim']): # read imaginary part:
|
|
|
|
for j in range(self.shells[ish]['dim']):
|
2013-07-23 19:49:42 +02:00
|
|
|
rot_mat_all[ish][i,j] += 1j * R.next()
|
|
|
|
|
|
|
|
if (self.SP):
|
|
|
|
rot_mat_all_time_inv[ish] = int(R.next())
|
|
|
|
|
|
|
|
R.close()
|
2014-11-03 14:47:55 +01:00
|
|
|
# Reading done!
|
2013-07-23 19:49:42 +02:00
|
|
|
|
2014-11-03 14:47:55 +01:00
|
|
|
# Save it to the HDF:
|
2013-07-23 19:49:42 +02:00
|
|
|
ar = HDFArchive(self.hdf_file,'a')
|
2014-11-03 14:47:55 +01:00
|
|
|
if not (self.parproj_subgrp in ar): ar.create_group(self.parproj_subgrp)
|
|
|
|
# The subgroup containing the data. If it does not exist, it is created. If it exists, the data is overwritten!
|
2015-01-22 10:47:53 +01:00
|
|
|
things_to_save = ['dens_mat_below','n_parproj','proj_mat_all','rot_mat_all','rot_mat_all_time_inv']
|
2014-11-03 14:47:55 +01:00
|
|
|
for it in things_to_save: ar[self.parproj_subgrp][it] = locals()[it]
|
2013-07-23 19:49:42 +02:00
|
|
|
del ar
|
|
|
|
|
2014-11-03 14:47:55 +01:00
|
|
|
# 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)
|
2013-07-23 19:49:42 +02:00
|
|
|
|
|
|
|
|
2014-11-03 14:47:55 +01:00
|
|
|
def convert_bands_input(self):
|
2013-07-23 19:49:42 +02:00
|
|
|
"""
|
|
|
|
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)
|
|
|
|
|
2014-11-08 23:51:24 +01:00
|
|
|
R = ConverterTools.read_fortran_file(self,self.band_file,self.fortran_to_replace)
|
2013-07-23 19:49:42 +02:00
|
|
|
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):
|
2014-11-26 16:24:02 +01:00
|
|
|
for ik in range(n_k):
|
2013-07-23 19:49:42 +02:00
|
|
|
n_orbitals[ik,isp] = int(R.next())
|
|
|
|
|
|
|
|
# Initialise the projectors:
|
2015-01-22 14:15:29 +01:00
|
|
|
proj_mat = numpy.zeros([n_k,self.n_spin_blocs,self.n_corr_shells,max([crsh['dim'] for crsh in self.corr_shells]),max(n_orbitals)],numpy.complex_)
|
2013-07-23 19:49:42 +02:00
|
|
|
|
|
|
|
# Read the projectors from the file:
|
2014-11-26 16:24:02 +01:00
|
|
|
for ik in range(n_k):
|
2013-07-23 19:49:42 +02:00
|
|
|
for icrsh in range(self.n_corr_shells):
|
2014-11-26 16:24:02 +01:00
|
|
|
n_orb = self.corr_shells[icrsh]['dim']
|
2013-07-23 19:49:42 +02:00
|
|
|
# first Real part for BOTH spins, due to conventions in dmftproj:
|
|
|
|
for isp in range(self.n_spin_blocs):
|
2014-11-26 16:24:02 +01:00
|
|
|
for i in range(n_orb):
|
|
|
|
for j in range(n_orbitals[ik,isp]):
|
2013-07-23 19:49:42 +02:00
|
|
|
proj_mat[ik,isp,icrsh,i,j] = R.next()
|
|
|
|
# now Imag part:
|
|
|
|
for isp in range(self.n_spin_blocs):
|
2014-11-26 16:24:02 +01:00
|
|
|
for i in range(n_orb):
|
|
|
|
for j in range(n_orbitals[ik,isp]):
|
2013-07-23 19:49:42 +02:00
|
|
|
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):
|
2014-11-26 16:24:02 +01:00
|
|
|
for ik in range(n_k) :
|
|
|
|
n_orb = n_orbitals[ik,isp]
|
|
|
|
for i in range(n_orb):
|
2013-07-23 19:49:42 +02:00
|
|
|
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:
|
2015-01-22 10:47:53 +01:00
|
|
|
proj_mat_all = 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_)
|
2013-07-23 19:49:42 +02:00
|
|
|
|
|
|
|
for ish in range(self.n_shells):
|
2014-11-26 16:24:02 +01:00
|
|
|
for ik in range(n_k):
|
2013-07-23 19:49:42 +02:00
|
|
|
for ir in range(n_parproj[ish]):
|
|
|
|
for isp in range(self.n_spin_blocs):
|
|
|
|
|
2014-11-26 16:24:02 +01:00
|
|
|
for i in range(self.shells[ish]['dim']): # read real part:
|
|
|
|
for j in range(n_orbitals[ik,isp]):
|
2015-01-22 10:47:53 +01:00
|
|
|
proj_mat_all[ik,isp,ish,ir,i,j] = R.next()
|
2013-07-23 19:49:42 +02:00
|
|
|
|
2014-11-26 16:24:02 +01:00
|
|
|
for i in range(self.shells[ish]['dim']): # read imaginary part:
|
|
|
|
for j in range(n_orbitals[ik,isp]):
|
2015-01-22 10:47:53 +01:00
|
|
|
proj_mat_all[ik,isp,ish,ir,i,j] += 1j * R.next()
|
2013-07-23 19:49:42 +02:00
|
|
|
|
|
|
|
except StopIteration : # a more explicit error if the file is corrupted.
|
2014-09-22 19:24:33 +02:00
|
|
|
raise "Wien2k_converter : reading file band_file failed!"
|
2013-07-23 19:49:42 +02:00
|
|
|
|
|
|
|
R.close()
|
2014-11-03 14:47:55 +01:00
|
|
|
# Reading done!
|
2013-07-23 19:49:42 +02:00
|
|
|
|
2014-11-03 14:47:55 +01:00
|
|
|
# Save it to the HDF:
|
2013-07-23 19:49:42 +02:00
|
|
|
ar = HDFArchive(self.hdf_file,'a')
|
|
|
|
if not (self.bands_subgrp in ar): ar.create_group(self.bands_subgrp)
|
2014-11-03 14:47:55 +01:00
|
|
|
# The subgroup containing the data. If it does not exist, it is created. If it exists, the data is overwritten!
|
2015-01-22 10:47:53 +01:00
|
|
|
things_to_save = ['n_k','n_orbitals','proj_mat','hopping','n_parproj','proj_mat_all']
|
2014-10-31 18:52:32 +01:00
|
|
|
for it in things_to_save: ar[self.bands_subgrp][it] = locals()[it]
|
2013-07-23 19:49:42 +02:00
|
|
|
del ar
|
|
|
|
|
|
|
|
|
2015-02-10 11:55:44 +01:00
|
|
|
def convert_misc_input(self, bandwin_file, struct_file, outputs_file, misc_subgrp, SO, SP, n_k):
|
2014-11-03 11:16:32 +01:00
|
|
|
"""
|
2015-02-10 11:55:44 +01:00
|
|
|
Reads input for the band window from bandwin_file, which is case.oubwin,
|
|
|
|
structure from struct_file, which is case.struct,
|
|
|
|
symmetries from outputs_file, which is case.outputs.
|
|
|
|
"""
|
|
|
|
|
2014-11-03 11:16:32 +01:00
|
|
|
if not (mpi.is_master_node()): return
|
|
|
|
|
2015-02-10 11:55:44 +01:00
|
|
|
# Read relevant data from .oubwin/up/dn files
|
|
|
|
#############################################
|
|
|
|
# band_window: Contains the index of the lowest and highest band within the
|
|
|
|
# projected subspace (used by dmftproj) for each k-point.
|
2014-12-19 11:53:06 +01:00
|
|
|
|
2014-12-11 12:11:48 +01:00
|
|
|
if (SP == 0 or SO == 1):
|
2015-02-10 11:55:44 +01:00
|
|
|
files = [self.bandwin_file]
|
2014-12-11 12:11:48 +01:00
|
|
|
elif SP == 1:
|
2015-02-10 11:55:44 +01:00
|
|
|
files = [self.bandwin_file+'up', self.bandwin_file+'dn']
|
2014-12-11 12:11:48 +01:00
|
|
|
else: # SO and SP can't both be 1
|
2015-02-10 11:55:44 +01:00
|
|
|
assert 0, "convert_transport_input: Reding oubwin error! Check SP and SO!"
|
|
|
|
|
|
|
|
band_window = [numpy.zeros((n_k, 2), dtype=int) for isp in range(SP + 1 - SO)]
|
2014-12-11 12:11:48 +01:00
|
|
|
for isp, f in enumerate(files):
|
2015-02-10 11:55:44 +01:00
|
|
|
if not os.path.exists(f): raise IOError, "convert_misc_input: File %s does not exist" %f
|
2014-12-19 11:53:06 +01:00
|
|
|
print "Reading input from %s..."%f,
|
2015-02-10 11:55:44 +01:00
|
|
|
|
|
|
|
R = ConverterTools.read_fortran_file(self, f, self.fortran_to_replace)
|
|
|
|
assert int(R.next()) == n_k, "convert_misc_input: Number of k-points is inconsistent in oubwin file!"
|
|
|
|
assert int(R.next()) == SO, "convert_misc_input: SO is inconsistent in oubwin file!"
|
2014-12-19 11:53:06 +01:00
|
|
|
for ik in xrange(n_k):
|
|
|
|
R.next()
|
2015-02-10 11:55:44 +01:00
|
|
|
band_window[isp][ik,0] = R.next() # lowest band
|
|
|
|
band_window[isp][ik,1] = R.next() # highest band
|
|
|
|
R.next()
|
|
|
|
|
|
|
|
R.close() # Reading done!
|
2014-11-03 11:16:32 +01:00
|
|
|
|
|
|
|
# Read relevant data from .struct file
|
2014-12-19 11:53:06 +01:00
|
|
|
######################################
|
|
|
|
# lattice_type: bravais lattice type as defined by Wien2k
|
|
|
|
# lattice_constants: unit cell parameters in a. u.
|
|
|
|
# lattice_angles: unit cell angles in rad
|
|
|
|
|
2015-02-10 11:55:44 +01:00
|
|
|
if not (os.path.exists(self.struct_file)) : raise IOError, "convert_misc_input: File %s does not exist" %self.struct_file
|
2014-12-19 11:53:06 +01:00
|
|
|
print "Reading input from %s..."%self.struct_file,
|
2014-11-03 11:16:32 +01:00
|
|
|
|
2014-12-19 11:53:06 +01:00
|
|
|
with open(self.struct_file) as R:
|
2014-12-09 16:47:40 +01:00
|
|
|
try:
|
2014-12-19 11:53:06 +01:00
|
|
|
R.readline()
|
|
|
|
lattice_type = R.readline().split()[0]
|
|
|
|
R.readline()
|
|
|
|
temp = R.readline().strip().split()
|
|
|
|
lattice_constants = numpy.array([float(t) for t in temp[0:3]])
|
|
|
|
lattice_angles = numpy.array([float(t) for t in temp[3:6]]) * numpy.pi / 180.0
|
2014-12-09 16:47:40 +01:00
|
|
|
except IOError:
|
2015-02-10 11:55:44 +01:00
|
|
|
raise "convert_misc_input: reading file %s failed" %self.struct_file
|
2014-11-03 11:16:32 +01:00
|
|
|
|
|
|
|
# Read relevant data from .outputs file
|
2014-12-19 11:53:06 +01:00
|
|
|
#######################################
|
|
|
|
# rot_symmetries: matrix representation of all (space group) symmetry operations
|
2014-11-03 11:16:32 +01:00
|
|
|
|
2015-02-10 11:55:44 +01:00
|
|
|
if not (os.path.exists(self.outputs_file)) : raise IOError, "convert_misc_input: File %s does not exist" %self.outputs_file
|
2014-12-19 11:53:06 +01:00
|
|
|
print "Reading input from %s..."%self.outputs_file,
|
|
|
|
|
|
|
|
rot_symmetries = []
|
|
|
|
with open(self.outputs_file) as R:
|
2014-12-09 16:47:40 +01:00
|
|
|
try:
|
|
|
|
while 1:
|
2014-12-19 11:53:06 +01:00
|
|
|
temp = R.readline().strip(' ').split()
|
2014-12-09 16:47:40 +01:00
|
|
|
if (temp[0] =='PGBSYM:'):
|
2014-12-19 11:53:06 +01:00
|
|
|
n_symmetries = int(temp[-1])
|
2014-12-09 16:47:40 +01:00
|
|
|
break
|
2014-12-19 11:53:06 +01:00
|
|
|
for i in range(n_symmetries):
|
2014-11-03 11:16:32 +01:00
|
|
|
while 1:
|
2014-12-19 11:53:06 +01:00
|
|
|
if (R.readline().strip().split()[0] == 'Symmetry'): break
|
|
|
|
sym_i = numpy.zeros((3, 3), dtype = float)
|
2014-12-09 16:47:40 +01:00
|
|
|
for ir in range(3):
|
2014-12-19 11:53:06 +01:00
|
|
|
temp = R.readline().strip().split()
|
2014-12-09 16:47:40 +01:00
|
|
|
for ic in range(3):
|
2014-12-19 11:53:06 +01:00
|
|
|
sym_i[ir, ic] = float(temp[ic])
|
|
|
|
R.readline()
|
|
|
|
rot_symmetries.append(sym_i)
|
2014-12-09 16:47:40 +01:00
|
|
|
except IOError:
|
2015-02-10 11:55:44 +01:00
|
|
|
raise "convert_misc_input: reading file %s failed" %self.outputs_file
|
2014-11-03 11:16:32 +01:00
|
|
|
|
2015-02-10 11:55:44 +01:00
|
|
|
|
|
|
|
# Save it to the HDF:
|
|
|
|
ar=HDFArchive(self.hdf_file,'a')
|
|
|
|
if not (misc_subgrp in ar): ar.create_group(misc_subgrp)
|
|
|
|
things_to_save = ['band_window', 'lattice_type', 'lattice_constants', 'lattice_angles', 'n_symmetries', 'rot_symmetries']
|
|
|
|
for it in things_to_save: ar[misc_subgrp][it] = locals()[it]
|
|
|
|
del ar
|
|
|
|
|
|
|
|
|
|
|
|
def convert_transport_input(self):
|
|
|
|
"""
|
|
|
|
Reads the input files necessary for transport calculations
|
|
|
|
and stores the data in the HDFfile
|
|
|
|
"""
|
|
|
|
if not (mpi.is_master_node()): return
|
2014-11-03 11:16:32 +01:00
|
|
|
|
2015-02-10 11:55:44 +01:00
|
|
|
# Check if SP, SO and n_k are already in h5
|
|
|
|
ar = HDFArchive(self.hdf_file, 'a')
|
|
|
|
if not (self.dft_subgrp in ar): raise IOError, "convert_transport_input: No %s subgroup in hdf file found! Call convert_dmft_input first." %self.dft_subgrp
|
|
|
|
SP = ar[self.dft_subgrp]['SP']
|
|
|
|
SO = ar[self.dft_subgrp]['SO']
|
|
|
|
n_k = ar[self.dft_subgrp]['n_k']
|
|
|
|
del ar
|
|
|
|
|
|
|
|
# Read relevant data from .pmat/up/dn files
|
|
|
|
###########################################
|
|
|
|
# band_window_optics: Contains the index of the lowest and highest band within the
|
|
|
|
# band window (used by optics) for each k-point.
|
|
|
|
# velocities_k: velocity (momentum) matrix elements between all bands in band_window_optics
|
|
|
|
# and each k-point.
|
|
|
|
|
2014-12-09 16:47:40 +01:00
|
|
|
if (SP == 0 or SO == 1):
|
2015-02-10 11:55:44 +01:00
|
|
|
files = [self.pmat_file]
|
2014-12-09 16:47:40 +01:00
|
|
|
elif SP == 1:
|
2015-02-10 11:55:44 +01:00
|
|
|
files = [self.pmat_file+'up', self.pmat_file+'dn']
|
2014-12-09 16:47:40 +01:00
|
|
|
else: # SO and SP can't both be 1
|
2015-02-10 11:55:44 +01:00
|
|
|
assert 0, "convert_transport_input: Reading velocity file error! Check SP and SO!"
|
|
|
|
|
|
|
|
velocities_k = [[] for f in files]
|
|
|
|
band_window_optics = []
|
2014-12-09 16:47:40 +01:00
|
|
|
for isp, f in enumerate(files):
|
2015-02-10 11:55:44 +01:00
|
|
|
if not os.path.exists(f) : raise IOError, "convert_transport_input: File %s does not exist" %f
|
2014-12-19 11:53:06 +01:00
|
|
|
print "Reading input from %s..."%f,
|
2015-02-10 11:55:44 +01:00
|
|
|
|
|
|
|
R = ConverterTools.read_fortran_file(self, f, {'D':'E','(':'',')':'',',':' '})
|
|
|
|
band_window_optics_isp = []
|
2014-12-09 16:47:40 +01:00
|
|
|
for ik in xrange(n_k):
|
|
|
|
R.next()
|
2015-02-10 11:55:44 +01:00
|
|
|
nu1 = int(R.next())
|
|
|
|
nu2 = int(R.next())
|
|
|
|
band_window_optics_isp.append((nu1, nu2))
|
|
|
|
n_bands = nu2 - nu1 + 1
|
|
|
|
for _ in range(4): R.next()
|
|
|
|
if n_bands <= 0:
|
|
|
|
velocity_xyz = numpy.zeros((1, 1, 3), dtype = complex)
|
|
|
|
else:
|
|
|
|
velocity_xyz = numpy.zeros((n_bands, n_bands, 3), dtype = complex)
|
|
|
|
for nu_i in range(n_bands):
|
|
|
|
for nu_j in range(nu_i, n_bands):
|
|
|
|
for i in range(3):
|
|
|
|
velocity_xyz[nu_i][nu_j][i] = R.next() + R.next()*1j
|
|
|
|
if (nu_i != nu_j): velocity_xyz[nu_j][nu_i][i] = velocity_xyz[nu_i][nu_j][i].conjugate()
|
|
|
|
velocities_k[isp].append(velocity_xyz)
|
|
|
|
band_window_optics.append(numpy.array(band_window_optics_isp))
|
2014-12-19 11:53:06 +01:00
|
|
|
print "DONE!"
|
2014-11-03 11:16:32 +01:00
|
|
|
|
|
|
|
# Put data to HDF5 file
|
|
|
|
ar = HDFArchive(self.hdf_file, 'a')
|
|
|
|
if not (self.transp_subgrp in ar): ar.create_group(self.transp_subgrp)
|
2014-11-06 15:39:48 +01:00
|
|
|
# The subgroup containing the data. If it does not exist, it is created. If it exists, the data is overwritten!!!
|
2015-02-10 11:55:44 +01:00
|
|
|
things_to_save = ['band_window_optics', 'velocities_k']
|
2014-11-06 15:39:48 +01:00
|
|
|
for it in things_to_save: ar[self.transp_subgrp][it] = locals()[it]
|
2014-11-03 11:16:32 +01:00
|
|
|
del ar
|
|
|
|
|
2014-10-31 18:52:32 +01:00
|
|
|
def convert_symmetry_input(self, orbits, symm_file, symm_subgrp, SO, SP):
|
2013-07-23 19:49:42 +02:00
|
|
|
"""
|
|
|
|
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)
|
2014-11-08 23:51:24 +01:00
|
|
|
|
|
|
|
R = ConverterTools.read_fortran_file(self,symm_file,self.fortran_to_replace)
|
2013-07-23 19:49:42 +02:00
|
|
|
|
|
|
|
try:
|
2014-11-14 18:13:43 +01:00
|
|
|
n_symm = int(R.next()) # Number of symmetry operations
|
2013-07-23 19:49:42 +02:00
|
|
|
n_atoms = int(R.next()) # number of atoms involved
|
2014-11-26 16:24:02 +01:00
|
|
|
perm = [ [int(R.next()) for i in range(n_atoms)] for j in range(n_symm) ] # list of permutations of the atoms
|
2013-07-23 19:49:42 +02:00
|
|
|
if SP:
|
2014-11-26 16:24:02 +01:00
|
|
|
time_inv = [ int(R.next()) for j in range(n_symm) ] # time inversion for SO coupling
|
2013-07-23 19:49:42 +02:00
|
|
|
else:
|
2014-11-26 16:24:02 +01:00
|
|
|
time_inv = [ 0 for j in range(n_symm) ]
|
2013-07-23 19:49:42 +02:00
|
|
|
|
|
|
|
# Now read matrices:
|
|
|
|
mat = []
|
2014-11-26 16:24:02 +01:00
|
|
|
for i_symm in range(n_symm):
|
2013-07-23 19:49:42 +02:00
|
|
|
|
2014-11-26 16:24:02 +01:00
|
|
|
mat.append( [ numpy.zeros([orbits[orb]['dim'], orbits[orb]['dim']],numpy.complex_) for orb in range(n_orbits) ] )
|
2013-07-23 19:49:42 +02:00
|
|
|
for orb in range(n_orbits):
|
2014-11-26 16:24:02 +01:00
|
|
|
for i in range(orbits[orb]['dim']):
|
|
|
|
for j in range(orbits[orb]['dim']):
|
2014-11-14 18:13:43 +01:00
|
|
|
mat[i_symm][orb][i,j] = R.next() # real part
|
2014-11-26 16:24:02 +01:00
|
|
|
for i in range(orbits[orb]['dim']):
|
|
|
|
for j in range(orbits[orb]['dim']):
|
2014-11-14 18:13:43 +01:00
|
|
|
mat[i_symm][orb][i,j] += 1j * R.next() # imaginary part
|
2013-07-23 19:49:42 +02:00
|
|
|
|
2014-11-26 16:24:02 +01:00
|
|
|
mat_tinv = [numpy.identity(orbits[orb]['dim'],numpy.complex_)
|
2013-07-23 19:49:42 +02:00
|
|
|
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):
|
2014-11-26 16:24:02 +01:00
|
|
|
for i in range(orbits[orb]['dim']):
|
|
|
|
for j in range(orbits[orb]['dim']):
|
2013-07-23 19:49:42 +02:00
|
|
|
mat_tinv[orb][i,j] = R.next() # real part
|
2014-11-26 16:24:02 +01:00
|
|
|
for i in range(orbits[orb]['dim']):
|
|
|
|
for j in range(orbits[orb]['dim']):
|
2013-07-23 19:49:42 +02:00
|
|
|
mat_tinv[orb][i,j] += 1j * R.next() # imaginary part
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
except StopIteration : # a more explicit error if the file is corrupted.
|
2014-09-22 19:24:33 +02:00
|
|
|
raise "Wien2k_converter : reading file symm_file failed!"
|
2013-07-23 19:49:42 +02:00
|
|
|
|
|
|
|
R.close()
|
2014-11-03 14:47:55 +01:00
|
|
|
# Reading done!
|
2013-07-23 19:49:42 +02:00
|
|
|
|
|
|
|
# Save it to the HDF:
|
|
|
|
ar=HDFArchive(self.hdf_file,'a')
|
|
|
|
if not (symm_subgrp in ar): ar.create_group(symm_subgrp)
|
2014-11-14 18:13:43 +01:00
|
|
|
things_to_save = ['n_symm','n_atoms','perm','orbits','SO','SP','time_inv','mat','mat_tinv']
|
2014-10-31 18:52:32 +01:00
|
|
|
for it in things_to_save: ar[symm_subgrp][it] = locals()[it]
|
2013-07-23 19:49:42 +02:00
|
|
|
del ar
|