irradiapy.io package
Submodules
- irradiapy.io.bzip2lammpsreader module
- irradiapy.io.bzip2lammpsreadermpi module
- irradiapy.io.bzip2lammpswriter module
- irradiapy.io.bzip2lammpswritermpi module
BZIP2LAMMPSWriterMPIBZIP2LAMMPSWriterMPI.close()BZIP2LAMMPSWriterMPI.commBZIP2LAMMPSWriterMPI.compresslevelBZIP2LAMMPSWriterMPI.encodingBZIP2LAMMPSWriterMPI.excluded_itemsBZIP2LAMMPSWriterMPI.file_pathBZIP2LAMMPSWriterMPI.float_formatBZIP2LAMMPSWriterMPI.int_formatBZIP2LAMMPSWriterMPI.modeBZIP2LAMMPSWriterMPI.write()
- irradiapy.io.lammpslogreader module
- irradiapy.io.lammpsreader module
- irradiapy.io.lammpsreadermpi module
- irradiapy.io.lammpswriter module
- irradiapy.io.lammpswritermpi module
- irradiapy.io.xyzreader module
- irradiapy.io.xyzwriter module
Module contents
This subpackage provides classes for reading and writing various file formats.
- class irradiapy.io.BZIP2LAMMPSReader(file_path, encoding='utf-8')[source]
Bases:
objectA class to read data from a bzip2-compressed LAMMPS dump file.
Note
Assumed orthogonal simulation box.
- Variables:
file_path (Path) – The path to the bzip2-compressed LAMMPS dump file.
encoding (str, optional (default="utf-8")) – The file encoding.
- Yields:
dict[str, Any] – A dictionary containing the timestep data with keys: ‘time’ (optional), ‘timestep’, ‘boundary’, ‘xlo’, ‘xhi’, ‘ylo’, ‘yhi’, ‘zlo’, ‘zhi’, and ‘atoms’ (as a numpy structured array).
- class irradiapy.io.BZIP2LAMMPSReaderMPI(file_path, encoding='utf-8', comm=<factory>, parallelization=0)[source]
Bases:
MPIExceptionHandlerMixinA class to read data from a LAMMPS dump file compressed with bzip2 in parallel using MPI.
Note
Assumed orthogonal simulation box.
Note
Rank 0 performs indexed, multi-threaded decompression using indexed_bzip2 of each timestep one by one, then scatters strings of atom data to all ranks, which build local numpy structured arrays.
- Parameters:
file_path (
Path) – Path to the .bz2 LAMMPS dump file.encoding (
str) – Text encoding used inside the dump (default: ‘utf-8’).comm (
Comm) – The MPI communicator (default: MPI.COMM_WORLD).parallelization (
int) – indexed_bzip2 parallelization setting. 0 = use all cores (recommended); 1 = serial; N > 1 = use N threads.
- Yields:
dict[str, Any] – A dictionary containing the timestep data with keys: ‘time’ (optional), ‘timestep’, ‘boundary’, ‘xlo’, ‘xhi’, ‘ylo’, ‘yhi’, ‘zlo’, ‘zhi’, and ‘atoms’ (as a numpy structured array).
- comm: Comm
- class irradiapy.io.BZIP2LAMMPSWriter(file_path, mode='wt', encoding=<factory>, newline=<factory>, compresslevel=9, int_format=<factory>, float_format=<factory>, excluded_items=<factory>)[source]
Bases:
objectA class to write data like a LAMMPS dump file, but compressed with bzip2.
Note
Assumed orthogonal simulation box.
- Variables:
file_path (Path) – The path to the bzip2-compressed LAMMPS dump file.
mode (str, optional (default="wt")) – The file open mode.
encoding (str, optional (default=irradiapy.config.ENCODING)) – The file encoding.
newline (str, optional (default=irradiapy.config.NEWLINE)) – The newline character for the file.
compresslevel (int, optional (default=9)) – The bzip2 compression level.
int_format (str, optional (default=irradiapy.config.INT_FORMAT)) – The format for integers.
float_format (str, optional (default=irradiapy.config.FLOAT_FORMAT)) – The format for floats.
excluded_items (list[str], optional (default=irradiapy.config.EXCLUDED_ITEMS)) – Atom fields to exclude from output.
- class irradiapy.io.BZIP2LAMMPSWriterMPI(file_path, mode='wb', encoding=<factory>, comm=<factory>, compresslevel=9, int_format=<factory>, float_format=<factory>, excluded_items=<factory>)[source]
Bases:
MPIExceptionHandlerMixinA class to write data like a LAMMPS dump bzip2 compressed file in parallel using MPI.
Note
Assumed orthogonal simulation box.
Note
All ranks compute their local subdomain of atoms, then rank 0 collects and writes the data.
- Parameters:
file_path (
Path) – Output .bz2 path.mode (
str) – File mode for the container file opened on rank 0 (default: ‘wb’).encoding (
str) – The file encoding.comm (
Comm) – The MPI communicator.compresslevel (
int) – Compression level for bzip2.int_format (
str) – The format for integers.float_format (
str) – The format for floats.excluded_items (
list[str]) – Atom fields to exclude from output.
- comm: Comm
- class irradiapy.io.LAMMPSLogReader(log_path)[source]
Bases:
objectClass to read LAMMPS log files.
- Parameters:
log_path (
Path) – The path to the LAMMPS log file.- Yields:
Generator[dict[str, Any], None, None] – A dictionary containing the thermo data.
Note
This generator yields a dictionary with a single key for the thermo data, this ensures compatibility if this reader is extended to read more data in the future.
- thermo: NDArray[float64]
- class irradiapy.io.LAMMPSReader(file_path, encoding='utf-8')[source]
Bases:
objectA class to read data from a LAMMPS dump file.
Note
Assumed orthogonal simulation box.
- Variables:
file_path (Path) – The path to the LAMMPS dump file.
encoding (str, optional (default="utf-8")) – The file encoding.
- Yields:
dict[str, Any] – A dictionary containing the timestep data with keys: ‘time’ (optional), ‘timestep’, ‘boundary’, ‘xlo’, ‘xhi’, ‘ylo’, ‘yhi’, ‘zlo’, ‘zhi’, and ‘atoms’ (as a numpy structured array).
- class irradiapy.io.LAMMPSReaderMPI(file_path, encoding='utf-8', comm=<factory>)[source]
Bases:
MPIExceptionHandlerMixinA class to read data from a LAMMPS dump file in parallel using MPI.
Note
Assumed orthogonal simulation box.
Note
Rank 0 reads each timestep one by one, then scatters strings of atom data to all ranks, which build local numpy structured arrays.
- Variables:
file_path (Path) – The path to the LAMMPS dump file.
encoding (str, optional (default="utf-8")) – The file encoding.
comm (MPI.Comm, optional (default=mpi4py.MPI.COMM_WORLD)) – The MPI communicator.
- Yields:
dict[str, Any] – A dictionary containing the timestep data with keys: ‘time’ (optional), ‘timestep’, ‘boundary’, ‘xlo’, ‘xhi’, ‘ylo’, ‘yhi’, ‘zlo’, ‘zhi’, and ‘atoms’ (as a numpy structured array).
- comm: Comm
- class irradiapy.io.LAMMPSWriter(file_path, mode='w', encoding=<factory>, newline=<factory>, int_format=<factory>, float_format=<factory>, excluded_items=<factory>)[source]
Bases:
objectA class to write data like a LAMMPS dump file.
Note
Assumed orthogonal simulation box.
- Variables:
file_path (Path) – The path to the LAMMPS dump file.
mode (str, optional (default="w")) – The file open mode.
encoding (str, optional (default=irradiapy.config.ENCODING)) – The file encoding.
newline (str, optional (default=irradiapy.config.NEWLINE)) – The newline character for the file.
int_format (str, optional (default=irradiapy.config.INT_FORMAT)) – The format for integers.
float_format (str, optional (default=irradiapy.config.FLOAT_FORMAT)) – The format for floats.
excluded_items (list[str], optional (default=irradiapy.config.EXCLUDED_ITEMS)) – Atom fields to exclude from output.
- class irradiapy.io.LAMMPSWriterMPI(file_path, mode='w', encoding=<factory>, newline=<factory>, comm=<factory>, int_format=<factory>, float_format=<factory>, excluded_items=<factory>)[source]
Bases:
MPIExceptionHandlerMixinA class to write data like a LAMMPS dump file in parallel using MPI.
Note
Assumes orthogonal simulation box.
- Variables:
file_path (Path) – The path to the LAMMPS dump file.
mode (str, optional (default="w")) – The file open mode.
encoding (str, optional (default=irradiapy.config.ENCODING)) – The file encoding.
newline (str, optional (default=irradiapy.config.NEWLINE)) – The newline character for the file.
comm (MPI.Comm, optional (default=mpi4py.MPI.COMM_WORLD)) – The MPI communicator.
int_format (str, optional (default=irradiapy.config.INT_FORMAT)) – The format for integers.
float_format (str, optional (default=irradiapy.config.FLOAT_FORMAT)) – The format for floats.
excluded_items (list[str], optional (default=irradiapy.config.EXCLUDED_ITEMS)) – Atom fields to exclude from output.
- comm: Comm
- class irradiapy.io.XYZReader(file_path, encoding='utf-8')[source]
Bases:
objectA class to read data from an extended XYZ file.
- Variables:
file_path (Path) – The path to the XYZ file.
dtype (npt.DTypeLike) – The data type of the properties in the file. By default, it is set to None and will be determined from the file.
- dtype: DTypeLike = None