Exemple #1
0
    def read_txt(self, args_p, fname):
        from mbpt_lcao_utils import read_file, str2float
        data = list()
        dim = list()
        end_box = 10

        if args_p.quantity == 'Efield':
            A = []
            for i in enumerate(fname):
                LINE = read_file(i[1])

                for j in range(end_box):
                    if LINE[j][1] != '#':
                        nb = str2float(LINE[j])
                        data.append(nb)

                dr = np.array(data[0])
                origin = np.array(data[1])
                lbound = np.array(data[2])
                ubound = np.array(data[3])
                box, dim = self.determine_box(dr, ubound, lbound, origin)

                A.append(np.zeros((dim[0], dim[1], dim[2]), dtype=float))

                l = end_box
                for k in range(int(dim[2])):
                    for j in range(int(dim[1])):
                        A[i[0]][:, j, k] = np.array(str2float(LINE[l]))
                        l = l + 1

            Array = np.zeros((A[0].shape[0], A[0].shape[1], A[0].shape[2], 3),
                             dtype=float)
            Array[:, :, :, 0] = A[0]
            Array[:, :, :, 1] = A[1]
            Array[:, :, :, 2] = A[2]

        elif args_p.quantity == 'polarizability':
            self.freq = np.loadtxt(fname)[:, 0]
            Array = np.loadtxt(fname)[:, 2:11].reshape(self.freq.shape[0], 3,
                                                       3)
            dr = 0.0
            origin = 0.0
            lbound = 0.0
            ubound = 0.0
            box = 0.0
            dim = 0.0
        else:
            LINE = read_file(fname)

            for i in range(end_box):
                if LINE[i][1] != '#':
                    nb = str2float(LINE[i])
                    data.append(nb)

            dr = np.array(data[0])
            origin = np.array(data[1])
            lbound = np.array(data[2])
            ubound = np.array(data[3])
            box, dim = self.determine_box(dr, ubound, lbound, origin)

            Array = np.zeros((dim[0], dim[1], dim[2]), dtype=float)

            l = end_box
            for k in range(int(dim[2])):
                for j in range(int(dim[1])):
                    Array[:, j, k] = np.array(str2float(LINE[l]))
                    l = l + 1

        return dr, origin, lbound, ubound, Array, box, dim
    def read_txt(self, args_p, fname):
        from mbpt_lcao_utils import read_file, str2float
        data = list()
        dim = list()
        end_box = 10

        if args_p.quantity == 'Efield':
            A = []
            for i in enumerate(fname):
                LINE = read_file(i[1])

                for j in range(end_box):
                    if LINE[j][1] != '#':
                        nb = str2float(LINE[j])
                        data.append(nb)

                dr = np.array(data[0])
                origin = np.array(data[1])
                lbound = np.array(data[2])
                ubound = np.array(data[3])
                box, dim = self.determine_box(dr, ubound, lbound, origin)

                A.append(np.zeros((dim[0], dim[1], dim[2]), dtype=float))

                l = end_box
                for k in range(int(dim[2])):
                    for j in range(int(dim[1])):
                        A[i[0]][:, j, k] = np.array(str2float(LINE[l]))
                        l = l + 1

            Array = np.zeros(
                (A[0].shape[0],
                 A[0].shape[1],
                    A[0].shape[2],
                    3),
                dtype=float)
            Array[:, :, :, 0] = A[0]
            Array[:, :, :, 1] = A[1]
            Array[:, :, :, 2] = A[2]

        elif args_p.quantity == 'polarizability':
            self.freq = np.loadtxt(fname)[:, 0]
            Array = np.loadtxt(fname)[:, 2:11].reshape(
                self.freq.shape[0], 3, 3)
            dr = 0.0
            origin = 0.0
            lbound = 0.0
            ubound = 0.0
            box = 0.0
            dim = 0.0
        else:
            LINE = read_file(fname)

            for i in range(end_box):
                if LINE[i][1] != '#':
                    nb = str2float(LINE[i])
                    data.append(nb)

            dr = np.array(data[0])
            origin = np.array(data[1])
            lbound = np.array(data[2])
            ubound = np.array(data[3])
            box, dim = self.determine_box(dr, ubound, lbound, origin)

            Array = np.zeros((dim[0], dim[1], dim[2]), dtype=float)

            l = end_box
            for k in range(int(dim[2])):
                for j in range(int(dim[1])):
                    Array[:, j, k] = np.array(str2float(LINE[l]))
                    l = l + 1

        return dr, origin, lbound, ubound, Array, box, dim