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

Reading misc_input files only if present

This commit is contained in:
Manuel Zingl 2015-02-20 15:15:17 +01:00
parent c19babd33a
commit 8db46b16b5

View File

@ -395,17 +395,17 @@ class Wien2kConverter(ConverterTools):
band_window = [numpy.zeros((n_k, 2), dtype=int) for isp in range(SP + 1 - SO)] band_window = [numpy.zeros((n_k, 2), dtype=int) for isp in range(SP + 1 - SO)]
for isp, f in enumerate(files): for isp, f in enumerate(files):
if not os.path.exists(f): raise IOError, "convert_misc_input: File %s does not exist" %f if os.path.exists(f):
mpi.report("Reading input from %s..."%f) mpi.report("Reading input from %s..."%f)
R = ConverterTools.read_fortran_file(self, f, self.fortran_to_replace) 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()) == 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!" assert int(R.next()) == SO, "convert_misc_input: SO is inconsistent in oubwin file!"
for ik in xrange(n_k): for ik in xrange(n_k):
R.next() R.next()
band_window[isp][ik,0] = R.next() # lowest band band_window[isp][ik,0] = R.next() # lowest band
band_window[isp][ik,1] = R.next() # highest band band_window[isp][ik,1] = R.next() # highest band
R.next() R.next()
R.close() # Reading done! R.close() # Reading done!
@ -415,48 +415,47 @@ class Wien2kConverter(ConverterTools):
# lattice_constants: unit cell parameters in a. u. # lattice_constants: unit cell parameters in a. u.
# lattice_angles: unit cell angles in rad # lattice_angles: unit cell angles in rad
if not (os.path.exists(self.struct_file)) : raise IOError, "convert_misc_input: File %s does not exist" %self.struct_file if (os.path.exists(self.struct_file)):
mpi.report("Reading input from %s..."%self.struct_file) mpi.report("Reading input from %s..."%self.struct_file)
with open(self.struct_file) as R: with open(self.struct_file) as R:
try: try:
R.readline() R.readline()
lattice_type = R.readline().split()[0] lattice_type = R.readline().split()[0]
R.readline() R.readline()
temp = R.readline().strip().split() temp = R.readline().strip().split()
lattice_constants = numpy.array([float(t) for t in temp[0:3]]) 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 lattice_angles = numpy.array([float(t) for t in temp[3:6]]) * numpy.pi / 180.0
except IOError: except IOError:
raise "convert_misc_input: reading file %s failed" %self.struct_file raise "convert_misc_input: reading file %s failed" %self.struct_file
# Read relevant data from .outputs file # Read relevant data from .outputs file
####################################### #######################################
# rot_symmetries: matrix representation of all (space group) symmetry operations # rot_symmetries: matrix representation of all (space group) symmetry operations
if not (os.path.exists(self.outputs_file)) : raise IOError, "convert_misc_input: File %s does not exist" %self.outputs_file if (os.path.exists(self.outputs_file)):
mpi.report("Reading input from %s..."%self.outputs_file) mpi.report("Reading input from %s..."%self.outputs_file)
rot_symmetries = [] rot_symmetries = []
with open(self.outputs_file) as R: with open(self.outputs_file) as R:
try: try:
while 1:
temp = R.readline().strip(' ').split()
if (temp[0] =='PGBSYM:'):
n_symmetries = int(temp[-1])
break
for i in range(n_symmetries):
while 1: while 1:
if (R.readline().strip().split()[0] == 'Symmetry'): break temp = R.readline().strip(' ').split()
sym_i = numpy.zeros((3, 3), dtype = float) if (temp[0] =='PGBSYM:'):
for ir in range(3): n_symmetries = int(temp[-1])
temp = R.readline().strip().split() break
for ic in range(3): for i in range(n_symmetries):
sym_i[ir, ic] = float(temp[ic]) while 1:
R.readline() if (R.readline().strip().split()[0] == 'Symmetry'): break
rot_symmetries.append(sym_i) sym_i = numpy.zeros((3, 3), dtype = float)
except IOError: for ir in range(3):
raise "convert_misc_input: reading file %s failed" %self.outputs_file temp = R.readline().strip().split()
for ic in range(3):
sym_i[ir, ic] = float(temp[ic])
R.readline()
rot_symmetries.append(sym_i)
except IOError:
raise "convert_misc_input: reading file %s failed" %self.outputs_file
# Save it to the HDF: # Save it to the HDF:
ar=HDFArchive(self.hdf_file,'a') ar=HDFArchive(self.hdf_file,'a')