radtools.load_poscar#

radtools.load_poscar(file_object=None, return_crystal=True, return_comment=False)[source]#

Read the crystal structure from the POSCAR file.

Parameters:
file_object: str 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 given by the file_object.

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

return_crystal: bool, default True

If True, returns Crystal object. Otherwise returns a tuple of (cell, atoms).

return_comment: bool, default False

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

Returns:
crystal: Crystal

Crystal structure read from the file. If return_crystal is True.

cell: (3, 3) numpy.ndarray

Cell of the crystal structure. If return_crystal is False.

atoms: list of Atom

Atoms of the crystal structure. If return_crystal is False. Positions are always relative to the cell.

comment: str

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