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