wulfric.io.dump_poscar#
- wulfric.io.dump_poscar(cell, atoms, file_object='POSCAR', comment: str = None, decimals=8, mode: str = 'Direct')[source]#
Writes crystal structure to the POSCAR file.
- Parameters:
- cell(3, 3) array-like,
Matrix of a cell, rows are interpreted as vectors.
- atomsdict
Dictionary with atoms. Must have a
"positions"with value of (N,3) array-like. Must have either"names"key with value oflistofstrof length N or"species"key with value oflistofstrof length N. If"species"key is not present, try to deduce atom's species from"names", raise error on fail.- file_objectstr of file-like object, optional
File to be written. If str, then file is opened with the given name. Otherwise it has to have
.write()method.- commentstr, optional
Comment to be written in the first line of the file. Has to be a single line. All new lines symbols are replaced with spaces.
- decimalsint, default 8
Number of decimals to be written.
- modestr, default "Direct"
Mode of the coordinates to be written. Can be "Direct" or "Cartesian".
Examples
>>> # Dump a POSCAR file >>> wulfric.io.dump_poscar(cell, atoms, "POSCAR") >>> # If you want to write a comment as well: >>> wulfric.io.dump_poscar( ... cell, atoms, "POSCAR", comment="This is a comment" ... ) >>> # You can control the amount of decimals in the output: >>> wulfric.io.dump_poscar(cell, atoms, "POSCAR", decimals=6) >>> # You can switch the mode of coordinates between 'Cartesian' and 'Direct' (default): >>> wulfric.io.dump_poscar( ... cell, atoms, "POSCAR", mode="Cartesian" ... )