wulfric.io.load_poscar#

wulfric.io.load_poscar(file_object=None, return_comment=False)[source]#

Reads crystal structure from the POSCAR file.

Parameters:
file_objectstr of file-like object, optional

File to be read. If str, then file is opened with the given name. Otherwise it has to have .readlines() method. By default it looks for the "POSCAR" file in the current directory. Behaviour for str:

  • Tries to open the file with the name file_object.

  • Tries to open the file with the name "POSCAR" in the directory file_object.

return_commentbool, default False

Whether to return the comment from the first line of the POSCAR file.

Returns:
cell(3, 3) numpy.ndarray

Cell of a crystal structure, rows are interpreted as vectors.

cell = [[a1_x, a1_y, a1_z],
        [a2_x, a2_y, a2_z],
        [a3_x, a3_y, a3_z]]
atomsdict

Atoms of the crystal structure. Positions are always relative to the cell.

commentstr

Comment from the first line of the file. If return_comment is True.

Examples

>>> # Load a POSCAR file
>>> cell, atoms = wulf.io.load_poscar('POSCAR')
>>> # It can return the comment from the file as well:
>>> cell, atoms, comment = wulf.io.load_poscar('POSCAR', return_comment=True)