mirror of
https://github.com/triqs/dft_tools
synced 2025-04-19 06:50:19 +02:00
[transport] Preliminary tidiying up of transport converter
This commit is contained in:
parent
cf1099a8ce
commit
6f1ffdfb86
@ -21,7 +21,7 @@
|
||||
################################################################################
|
||||
|
||||
from types import *
|
||||
import numpy, os.path
|
||||
import numpy
|
||||
from pytriqs.archive import *
|
||||
from converter_tools import *
|
||||
import os.path
|
||||
@ -388,18 +388,16 @@ class Wien2kConverter(ConverterTools):
|
||||
# Read relevant data from .pmat file
|
||||
############################################
|
||||
|
||||
vk = []
|
||||
kp = []
|
||||
vk = [[] for sp in spinbl]
|
||||
kp = [[] for sp in spinbl]
|
||||
bandwin_opt = []
|
||||
|
||||
for ispinbl in spinbl:
|
||||
vks = []
|
||||
kps = []
|
||||
bandwins_opt = []
|
||||
if not (os.path.exists(self.vel_file + ispinbl)) : raise IOError, "File %s does not exist" %self.vel_file+ispinbl
|
||||
print "Reading input from %s..."%self.vel_file+ispinbl
|
||||
for isp, sp in enumerate(spinbl):
|
||||
bandwin_opt_isp = []
|
||||
if not (os.path.exists(self.vel_file + sp)) : raise IOError, "File %s does not exist" %self.vel_file+sp
|
||||
print "Reading input from %s..."%self.vel_file+sp
|
||||
|
||||
with open(self.vel_file + ispinbl) as f:
|
||||
with open(self.vel_file + sp) as f:
|
||||
while 1:
|
||||
try:
|
||||
s = f.readline()
|
||||
@ -409,12 +407,11 @@ class Wien2kConverter(ConverterTools):
|
||||
break
|
||||
try:
|
||||
[k, nu1, nu2] = [int(x) for x in s.strip().split()]
|
||||
bandwins_opt.append((nu1,nu2))
|
||||
bandwin_opt_isp.append((nu1,nu2))
|
||||
dim = nu2 - nu1 +1
|
||||
v_xyz = numpy.zeros((dim,dim,3), dtype = complex)
|
||||
# kp.append(f.readline().strip().split())
|
||||
temp = f.readline().strip().split()
|
||||
kps.append(numpy.array([float(t) for t in temp[0:3]]))
|
||||
kp[isp].append(numpy.array([float(t) for t in temp[0:3]]))
|
||||
for nu_i in xrange(dim):
|
||||
for nu_j in xrange(nu_i, dim):
|
||||
for i in xrange(3):
|
||||
@ -423,13 +420,11 @@ class Wien2kConverter(ConverterTools):
|
||||
if (nu_i != nu_j):
|
||||
v_xyz[nu_j][nu_i][i] = v_xyz[nu_i][nu_j][i].conjugate()
|
||||
|
||||
vks.append(v_xyz)
|
||||
vk[isp].append(v_xyz)
|
||||
|
||||
except IOError:
|
||||
raise "Wien2k_converter : reading file %s failed" %self.vel_file
|
||||
vk.append(vks)
|
||||
kp.append(kps)
|
||||
bandwin_opt.append(numpy.array(bandwins_opt))
|
||||
bandwin_opt.append(numpy.array(bandwin_opt_isp))
|
||||
|
||||
print "Read in %s file done!" %self.vel_file
|
||||
|
||||
@ -445,14 +440,12 @@ class Wien2kConverter(ConverterTools):
|
||||
temp = f.readline() #lattice
|
||||
#latticetype = temp[0:10].split()[0]
|
||||
latticetype = temp.split()[0]
|
||||
|
||||
print 'Lattice: ', latticetype
|
||||
|
||||
f.readline()
|
||||
temp = f.readline().strip().split() # lattice constants
|
||||
latticeconstants = numpy.array([float(t) for t in temp[0:3]])
|
||||
latticeangles = numpy.array([float(t) for t in temp[3:6]])
|
||||
latticeangles *= numpy.pi/180.0
|
||||
print 'Lattice: ', latticetype
|
||||
print 'Lattice constants: ', latticeconstants
|
||||
print 'Lattice angles: ', latticeangles
|
||||
|
||||
@ -497,7 +490,7 @@ class Wien2kConverter(ConverterTools):
|
||||
symmcartesian.append(symmt)
|
||||
taucartesian.append(taut)
|
||||
except IOError:
|
||||
raise "Wien2k_converter : reading file %s failed" %self.outputs_file
|
||||
raise "Wien2k_converter: reading file %s failed" %self.outputs_file
|
||||
|
||||
print "Read in %s file done!" %self.outputs_file
|
||||
|
||||
@ -505,33 +498,26 @@ class Wien2kConverter(ConverterTools):
|
||||
# Read relevant data from .oubwin/up/down files
|
||||
############################################
|
||||
|
||||
# convert_dmft_inputar = HDFArchive(self.hdf_file, 'a')
|
||||
|
||||
if (SP == 0 or SO == 1):
|
||||
files = [self.oubwin_file]
|
||||
elif SP == 1:
|
||||
files = [self.oubwin_file+'up', self.oubwin_file+'dn']
|
||||
else: # SO and SP can't both be 1
|
||||
assert 0, "Reding oubwin error! Check SP and SO!"
|
||||
bandwin = [numpy.zeros((n_k, 2), dtype=int) for isp in range(SP + 1 - SO)]
|
||||
|
||||
for isp in range(SP + 1 - SO):
|
||||
if(SP == 0 or SO == 1):
|
||||
if not (os.path.exists(self.oubwin_file)) : raise IOError, "File %s does not exist" %self.oubwin_file
|
||||
print "Reading input from %s..."%self.oubwin_file
|
||||
f = ConverterTools.read_fortran_file(self, self.oubwin_file, self.fortran_to_replace)
|
||||
elif (SP == 1 and isp == 0):
|
||||
if not (os.path.exists(self.oubwin_file+'up')) : raise IOError, "File %s does not exist" %self.oubwin_file+'up'
|
||||
print "Reading input from %s..."%self.oubwin_file+'up'
|
||||
f = ConverterTools.read_fortran_file(self, self.oubwin_file+'up', self.fortran_to_replace)
|
||||
elif (SP == 1 and isp ==1):
|
||||
if not (os.path.exists(self.oubwin_file+'dn')) : raise IOError, "File %s does not exist" %self.oubwin_file+'dn'
|
||||
print "Reading input from %s..."%self.oubwin_file+'dn'
|
||||
f = ConverterTools.read_fortran_file(self, self.oubwin_file+'dn', self.fortran_to_replace)
|
||||
else:
|
||||
assert 0, "Reding oubwin error! Check SP and SO!"
|
||||
assert int(f.next()) == n_k, "Number of k-points is unconsistent in oubwin file!"
|
||||
assert int(f.next()) == SO, "SO is unconsistent in oubwin file!"
|
||||
for isp, f in enumerate(files):
|
||||
if not os.path.exists(f): raise IOError, "File %s does not exist" %f
|
||||
print "Reading input from %s..."%f
|
||||
R = ConverterTools.read_fortran_file(self, f, self.fortran_to_replace)
|
||||
assert int(R.next()) == n_k, "Wien2k_converter: Number of k-points is inconsistent in oubwin file!"
|
||||
assert int(R.next()) == SO, "Wien2k_converter: SO is inconsistent in oubwin file!"
|
||||
|
||||
for i in xrange(n_k):
|
||||
f.next()
|
||||
bandwin[isp][i, 0] = f.next()
|
||||
bandwin[isp][i, 1] = f.next()
|
||||
f.next()
|
||||
for ik in xrange(n_k):
|
||||
R.next()
|
||||
bandwin[isp][ik,0] = R.next()
|
||||
bandwin[isp][ik,1] = R.next()
|
||||
R.next()
|
||||
|
||||
print "Read in %s files done!" %self.oubwin_file
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user