From 7256907c7235afb7393fe1c565d1bb19224cf3b1 Mon Sep 17 00:00:00 2001 From: "Oleg E. Peil" Date: Thu, 27 Aug 2015 11:36:19 +0200 Subject: [PATCH] Added input of a ctrl-file to the converter Implemented a basic input of a ctrl-file. First, the JSON-header is read and parsed, then k-points and their weights are read in. --- .../converters/vasp/python/vasp_converter.py | 22 ++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/python/converters/vasp/python/vasp_converter.py b/python/converters/vasp/python/vasp_converter.py index 2450e671..c58a323e 100644 --- a/python/converters/vasp/python/vasp_converter.py +++ b/python/converters/vasp/python/vasp_converter.py @@ -99,7 +99,27 @@ class VaspConverter(ConverterTools): mpi.report("Reading input from %s..."%self.dft_file) # R is a generator : each R.Next() will return the next number in the file - R = ConverterTools.read_fortran_file(self,self.dft_file,self.fortran_to_replace) + jheader, rf = self.read_header_and_data(self, self.ctrl_file) + ctrl_head = json.loads(jheader) + + ng = ctrl_head['ngroups'] + nk = ctrl_head['nk'] + ns = ctrl_head['ns'] + nc_flag = ctrl_head['nc_flag'] + + kpts = numpy.zeros((nk, 3)) + kweights = numpy.zeros(nk) + try: + for ik in xrange(nk): + kx, ky, kz = rf.next(), rf.next(), rf.next() + kpts[ik, :] = kx, ky, kz + kweights[ik] = rf.next() + except StopIteration: + raise "VaspConverter: error reading %s"%self.ctrl_file + +# Read PLO groups + for ig in xrange(ng): + try: energy_unit = R.next() # read the energy convertion factor n_k = int(R.next()) # read the number of k points