io
asext.io
¶
Modules:
lmpdata
¶
Functions:
-
read_lammps_dump_text–Process cleartext lammps dumpfiles
-
write_lammps_data–Write atomic structure data to a LAMMPS data file.
read_lammps_dump_text(file: str, index=-1, **kwargs)
¶
Process cleartext lammps dumpfiles
:param fileobj: filestream providing the trajectory data :param index: integer or slice object (default: get the last timestep) :returns: list of Atoms objects :rtype: list
Notes:
- This function is a modified version of ase.io.lammpsrun.read_lammps_dump_text to allow storing atom types if type column is given in the LAMMPS dump file.
write_lammps_data(file: str, atoms: Atoms, *, specorder: list = None, reduce_cell: bool = False, force_skew: bool = False, prismobj: Prism = None, write_image_flags: bool = False, masses: bool = False, velocities: bool = False, units: str = 'metal', bonds: bool = True, atom_style: str = 'atomic')
¶
Write atomic structure data to a LAMMPS data file.
Parameters¶
fd : file|str
File to which the output will be written.
atoms : Atoms
Atoms to be written.
specorder : list[str], optional
Chemical symbols in the order of LAMMPS atom types, by default None
force_skew : bool, optional
Force to write the cell as a
triclinic <https://docs.lammps.org/Howto_triclinic.html>__ box,
by default False
reduce_cell : bool, optional
Whether the cell shape is reduced or not, by default False
prismobj : Prism|None, optional
Prism, by default None
write_image_flags : bool, default False
If True, the image flags, i.e., in which images of the periodic
simulation box the atoms are, are written.
masses : bool, optional
Whether the atomic masses are written or not, by default False
velocities : bool, optional
Whether the atomic velocities are written or not, by default False
units : str, optional
LAMMPS units <https://docs.lammps.org/units.html>,
by default 'metal'
bonds : bool, optional
Whether the bonds are written or not. Bonds can only be written
for atom_style='full', by default True
atom_style : {'atomic', 'charge', 'full'}, optional
LAMMPS atom style <https://docs.lammps.org/atom_style.html>,
by default 'atomic'
Notes:
- This function is a modified version of ase.io.lammpsdata.write_lammps_data to allow writing atom types based on atoms.arrays['type'] if it exists. Otherwise, the atom types are assigned based on the order of specorder or sorted chemical symbols.
readwrite
¶
Functions:
-
read_extxyz–Read extxyz file. The exited
ase.io.readreturns a single Atoms object if file contains only one frame. This function will return a list of Atoms object. -
write_extxyz–Write a list of Atoms object to an extxyz file. The exited
ase.io.writefunction does not support writing file if the parent directory does not exist. This function will overcome this problem. -
read_lmpdump–Shortcut to
ase.io.lammpsrun.read_lammps_dumpfunction. -
write_lmpdata–Shortcut to
ase.io.lammpsdata.write_lammps_datafunction. -
extxyz2lmpdata–Convert extxyz file to LAMMPS data file.
-
lmpdata2extxyz–Convert LAMMPS data file to extxyz file.
-
lmpdump2extxyz–Convert LAMMPS dump file to extxyz file.
read_extxyz(extxyz_file: str, index=':') -> list[Atoms]
¶
Read extxyz file. The exited ase.io.read returns a single Atoms object if file contains only one frame. This function will return a list of Atoms object.
Parameters:
-
extxyz_file(str) –Path to the output file.
Returns:
-
list(list[Atoms]) –List of Atoms object.
Note
ase.io.readreturns a single Atoms object or a list of Atoms object, depending on theindexargument.index=":"will always return a list.index=0orindex=-1will return a single Atoms object.
- this function will always return a list of Atoms object, even
index=0orindex=-1
write_extxyz(outfile: str, structs: list[Atoms]) -> None
¶
Write a list of Atoms object to an extxyz file. The exited ase.io.write function does not support writing file if the parent directory does not exist. This function will overcome this problem.
Parameters:
-
structs(list) –List of Atoms object.
-
outfile(str) –Path to the output file.
read_lmpdump(lmpdump_file: str, index=-1, units='metal', **kwargs) -> list[Atoms]
¶
Shortcut to ase.io.lammpsrun.read_lammps_dump function.
Parameters:
-
lmpdump_file(str) –Path to the LAMMPS dump file.
-
index(int | list[int], default:-1) –integer or slice object (default: get the last timestep)
-
order(bool) –sort atoms by id. Might be faster to turn off. Default: True
-
specorder(list[str]) –list of species to map lammps types to ase-species. Default: None
-
units(str, default:'metal') –lammps units for unit transformation between lammps and ase
Returns:
-
list(list[Atoms]) –List of Atoms object.
write_lmpdata(file: str, atoms: Atoms, *, specorder: list = None, reduce_cell: bool = False, force_skew: bool = False, prismobj: Prism = None, write_image_flags: bool = False, masses: bool = True, velocities: bool = False, units: str = 'metal', bonds: bool = True, atom_style: str = 'atomic') -> None
¶
Shortcut to ase.io.lammpsdata.write_lammps_data function.
Parameters:
-
file(str) –File to which the output will be written.
-
atoms(Atoms) –Atoms to be written.
-
specorder(list[str], default:None) –Chemical symbols in the order of LAMMPS atom types, by default None
-
force_skew(bool, default:False) –Force to write the cell as a
triclinic <https://docs.lammps.org/Howto_triclinic.html>box, by default False -
reduce_cell(bool, default:False) –Whether the cell shape is reduced or not, by default False
-
prismobj(Prism | None, default:None) –Prism, by default None
-
write_image_flags(bool, default:False) –default False. If True, the image flags, i.e., in which images of the periodic simulation box the atoms are, are written.
-
masses(bool, default:True) –Whether the atomic masses are written or not, by default True
-
velocities(bool, default:False) –Whether the atomic velocities are written or not, by default False
-
units(str, default:'metal') –LAMMPS units <https://docs.lammps.org/units.html>, by default 'metal' -
bonds(bool, default:True) –Whether the bonds are written or not. Bonds can only be written for atom_style='full', by default True
-
atom_style–{'atomic', 'charge', 'full'}, optional.
LAMMPS atom style <https://docs.lammps.org/atom_style.html>, by default 'atomic'
Returns:
-
None–None
extxyz2lmpdata(extxyz_file: str, lmpdata_file: str, masses: bool = True, units: str = 'metal', atom_style: str = 'atomic', **kwargs) -> list[str]
¶
Convert extxyz file to LAMMPS data file.
Note:
- need to save 'original_cell' to able to revert the original orientation of the crystal.
- Use atoms.arrays['type'] to set atom types when convert from extxyz to lammpsdata file.
lmpdata2extxyz(lmpdata_file: str, extxyz_file: str, original_cell_file: str = None)
¶
Convert LAMMPS data file to extxyz file.
lmpdump2extxyz(lmpdump_file: str, extxyz_file: str, index: int | slice = -1, original_cell_file: str = None, stress_file: str = None, lammps_units: str = 'metal')
¶
Convert LAMMPS dump file to extxyz file.
Parameters:
-
lmpdump_file(str) –Path to the LAMMPS dump file.
-
extxyz_file(str) –Path to the output extxyz file.
-
original_cell_file(str, default:None) –Path to the text file contains original_cell. It should a simple text file that can write/read with numpy. If not provided, try to find in the same directory as
lmpdump_filewith the extension.original_cell. Defaults to None. -
stress_file(str, default:None) –Path to the text file contains stress tensor. Defaults to None.
Restriction
- Current ver: stress is mapped based on frame_index, it requires that frames in text stress file must be in the same "length and order" as in the LAMMPS dump file.
struct.info.get("timestep")is a new feature in ASE 3.25 ?