3
0
mirror of https://github.com/triqs/dft_tools synced 2024-12-22 04:13:47 +01:00

[transport] Preliminary tidiying up of transport converter

This commit is contained in:
Priyanka Seth 2014-12-09 16:47:40 +01:00
parent cf1099a8ce
commit 6f1ffdfb86

View File

@ -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,48 +388,43 @@ 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()
if (s == ''): if (s == ''):
break
except:
break break
try: except:
[k, nu1, nu2] = [int(x) for x in s.strip().split()] break
bandwins_opt.append((nu1,nu2)) try:
dim = nu2 - nu1 +1 [k, nu1, nu2] = [int(x) for x in s.strip().split()]
v_xyz = numpy.zeros((dim,dim,3), dtype = complex) bandwin_opt_isp.append((nu1,nu2))
# kp.append(f.readline().strip().split()) dim = nu2 - nu1 +1
temp = f.readline().strip().split() v_xyz = numpy.zeros((dim,dim,3), dtype = complex)
kps.append(numpy.array([float(t) for t in temp[0:3]])) temp = f.readline().strip().split()
for nu_i in xrange(dim): kp[isp].append(numpy.array([float(t) for t in temp[0:3]]))
for nu_j in xrange(nu_i, dim): for nu_i in xrange(dim):
for i in xrange(3): for nu_j in xrange(nu_i, dim):
s = f.readline().strip("\n ()").split(',') for i in xrange(3):
v_xyz[nu_i][nu_j][i] = float(s[0]) + float(s[1])*1j s = f.readline().strip("\n ()").split(',')
if (nu_i != nu_j): v_xyz[nu_i][nu_j][i] = float(s[0]) + float(s[1])*1j
v_xyz[nu_j][nu_i][i] = v_xyz[nu_i][nu_j][i].conjugate() 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: 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
@ -440,24 +435,22 @@ class Wien2kConverter(ConverterTools):
print "Reading input from %s..."%self.struct_file print "Reading input from %s..."%self.struct_file
with open(self.struct_file) as f: with open(self.struct_file) as f:
try: try:
f.readline() #title f.readline() #title
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]
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
print 'Lattice: ', latticetype except IOError:
raise "Wien2k_converter : reading file %s failed" %self.struct_file
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 constants: ', latticeconstants
print 'Lattice angles: ', latticeangles
except IOError:
raise "Wien2k_converter : reading file %s failed" %self.struct_file
print "Read in %s file done!" %self.struct_file print "Read in %s file done!" %self.struct_file
@ -471,33 +464,33 @@ class Wien2kConverter(ConverterTools):
taucartesian = [] taucartesian = []
with open(self.outputs_file) as f: with open(self.outputs_file) as f:
try: try:
while 1:
temp = f.readline().strip(' ').split()
if (temp[0] =='PGBSYM:'):
nsymm = int(temp[-1])
break
for i in range(nsymm):
while 1: while 1:
temp = f.readline().strip(' ').split()
if (temp[0] =='PGBSYM:'):
nsymm = int(temp[-1])
break
for i in range(nsymm):
while 1:
temp = f.readline().strip().split()
if (temp[0] == 'Symmetry'):
break
# read cartesian symmetries
symmt = numpy.zeros((3, 3), dtype = float)
taut = numpy.zeros(3, dtype = float)
for ir in range(3):
temp = f.readline().strip().split()
for ic in range(3):
symmt[ir, ic] = float(temp[ic])
temp = f.readline().strip().split() temp = f.readline().strip().split()
for ir in range(3): if (temp[0] == 'Symmetry'):
taut[ir] = float(temp[ir]) break
symmcartesian.append(symmt) # read cartesian symmetries
taucartesian.append(taut) symmt = numpy.zeros((3, 3), dtype = float)
except IOError: taut = numpy.zeros(3, dtype = float)
raise "Wien2k_converter : reading file %s failed" %self.outputs_file for ir in range(3):
temp = f.readline().strip().split()
for ic in range(3):
symmt[ir, ic] = float(temp[ic])
temp = f.readline().strip().split()
for ir in range(3):
taut[ir] = float(temp[ir])
symmcartesian.append(symmt)
taucartesian.append(taut)
except IOError:
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