Example #1
0
def read_xyz(f: io.TextIOWrapper):
    n = int(next(f))
    comment = next(f)
    m = read_matrix(f, n)
    symbols = m[:, 0]
    positions = m[:, 1:4].astype(np.float64)
    return comment, symbols, positions
Example #2
0
def read_outcar_a_lattice(f):
    skip_until(f, "VOLUME and BASIS-vectors are now :")
    next(f)
    next(f)
    next(f)
    next(f)
    lattices = read_matrix(f, 3)
    return lattices[:, 0:3].astype(np.float64)
Example #3
0
def read_outcar_a_position_force(f, n):
    skip_until(
        f,
        "POSITION                                       TOTAL-FORCE (eV/Angst)"
    )
    next(f)
    pf = read_matrix(f, n)
    return pf[:, :3].astype(np.float64), pf[:, 3:6].astype(np.float64)
Example #4
0
def read_a_results_tag(f: io.TextIOWrapper):
    name, tds = next(f).split()
    _, t, d, s = tds.split(":")
    _ = int(d)
    shape = tuple(map(int, s.split(",")))
    if t == "real":
        dtype = np.float64
    else:
        raise RuntimeError()
    vec = read_matrix(f, int(np.ceil(np.prod(shape) / 3))).astype(dtype)
    return name, vec.reshape(shape)
Example #5
0
def read_poscar(f: io.TextIOWrapper):
    """system, cell, symbols, coordinate, selective"""
    title = next(f).strip()
    unit = float(next(f).strip())
    cell = read_matrix(f, 3).astype(np.float64)
    sym = next(f).split()
    num = [int(w) for w in next(f).split()]
    symbols = expand(num, sym)
    selective, cartesian = read_poscar_switch(f)
    ct = read_matrix(f, len(symbols))
    if cartesian:
        coordinate = ct[:, 0:3].astype(np.float64)
    else:
        coordinate = ct[:, 0:3].astype(np.float64) @ cell
    if selective:
        selectived = np.logical_or(ct[:, 3:6] == "T", ct[:, 3:6] == "t")
    else:
        # selectived = np.full((len(symbols), 3), True)]
        selectived = None
    return title, unit, cell * unit, symbols, coordinate * unit, selectived
Example #6
0
def read_doscar(f: io.TextIOWrapper):
    # pylint: disable=W0612
    (number_of_ions_including_empty_spheres, number_of_ions, including_pdos,
     NCDIJ) = map(int,
                  next(f).split())
    (volume_of_unit_cell, la, lb, lc, POTIM) = map(float, next(f).split())
    TEBEG = float(next(f))
    next(f)
    SYSTEM = next(f)
    Emax, Emin, FEDOS, Efermi, _ = map(float, next(f).split())
    NEDOS = int(FEDOS)
    DOS = read_matrix(f, NEDOS).astype(np.float64)
    if including_pdos:
        PDOS = []
        for _ in range(number_of_ions):
            next(f)
            PDOS.append(read_matrix(f, NEDOS).astype(np.float64))
        PDOS = np.array(PDOS)
    else:
        PDOS = None
    return Emax, Emin, NEDOS, Efermi, DOS, PDOS
Example #7
0
def read_outcar_a_frequency(f: io.TextIOWrapper, n):
    head = next(f).split()
    if head[1] == "f":
        body = head[3:]
        im = False
    elif head[1] == "f/i=":
        body = head[2:]
        im = True
    else:
        raise NotImplementedError()
    energy = float(body[4]) * kayser
    next(f)
    pos_freq = read_matrix(f, n).astype(np.float64)
    next(f)
    return im, energy, pos_freq
Example #8
0
 def read_convvec(self, f):
     self.convvec.append(read_matrix(f, 3).astype(np.float64) * angstrom)
     return next(f).split()