Exemplo n.º 1
0
    poscar = Poscar(structure).get_string()

    # Basis vector of the unit cell of lattice [(x1, y1, z1), (x2, y2, z2), (x3, y3, z3)]
    lattice_vector = np.array([])
    # Atom type (Element1, Element2, ...)
    atom_type = np.array([])
    # Atom type (# of Element1, # of Element2, ...)
    atom_number = np.array([])
    # Atom position [(x1, y1, z1), (x2, y2, z2), (x3, y3, z3), ...]
    r = np.array([])

    line = 0
    print(f"Processing {fileNumber + 1} / {len(inputs)} files.")

    # -- Reading from poscar (vasp format)
    for i, line in enumerate(poscar.split("\n")):
        n_line = i
        # Lattice constant:
        if i == 1:
            lattice_cnst = float(line)
        # Lattice vector 1:
        elif i >= 2 and i <= 4:
            lattice_vector = np.append(lattice_vector, line.split(' '))
            # Removing redundant elements
            lattice_vector = lattice_vector[lattice_vector != ''].astype(
                np.float)
        elif i == 5:
            atom_type = np.append(atom_type, line.split(' '))
        # Atom number
        elif i == 6:
            atom_number = np.array(line.split(' '))