io
asext.io
¶
Modules:
readwrite
¶
Functions:
-
read_extxyz–Read extxyz file. The existing
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 existing
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 existing 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.
-
index(int | slice | str, default:':') –integer or slice object (default: get all frames)
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] | Atoms) -> None
¶
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)
-
units(str, default:'metal') –lammps units for unit transformation between lammps and ase
-
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
-
**kwargs–Additional arguments passed to
ase.io.lammpsrun.read_lammps_dump
Returns:
-
list(list[Atoms]) –List of Atoms object.
write_lmpdata(file: str, atoms: Atoms, *, specorder: list[str] | None = None, reduce_cell: bool = False, force_skew: bool = False, prismobj: Prism | None = 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) -> tuple[list, list]
¶
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 fromextxyztolammpsdatafile.
lmpdata2extxyz(lmpdata_file: str, extxyz_file: str, original_cell_file: str | None = None)
¶
Convert LAMMPS data file to extxyz file.
lmpdump2extxyz(lmpdump_file: str, extxyz_file: str, index: int | slice = -1, original_cell_file: str | None = None, stress_file: str | None = 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.
-
index(int | slice | str, default:-1) –Integer, slice, or string to specify which frames to read from the LAMMPS dump file. Defaults to -1 (last frame).
-
original_cell_file(str | None, 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 | None, default:None) –Path to the text file contains stress tensor. Defaults to None.
-
lammps_units(str, default:'metal') –LAMMPS units for unit transformation between LAMMPS and ASE. Defaults to "metal".
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 ?