irradiapy.io package

Submodules

irradiapy.io.bzip2lammpsreader module

This module contains the BZIP2LAMMPSReader class.

class irradiapy.io.bzip2lammpsreader.BZIP2LAMMPSReader(file_path, encoding='utf-8')[source]

Bases: object

A class to read data from a bzip2-compressed LAMMPS dump file.

Note

Assumed orthogonal simulation box.

Note

If you only need to decompress a file, use irradiapy.io.io_utils.decompress_file_bz2 instead.

file_path

The path to the bzip2-compressed LAMMPS dump file.

Type:

Path

encoding

The file encoding.

Type:

str, optional (default=”utf-8”)

close()[source]

Close the file associated with this reader.

Return type:

None

encoding: str = 'utf-8'
file: BinaryIO = None
file_path: Path

irradiapy.io.bzip2lammpswriter module

This module contains the BZIP2LAMMPSWriter class.

class irradiapy.io.bzip2lammpswriter.BZIP2LAMMPSWriter(file_path, mode='wt', excluded_items=<factory>, encoding=<factory>, int_format=<factory>, float_format=<factory>, compresslevel=9)[source]

Bases: object

A class to write data like a LAMMPS dump file, but compressed with bzip2.

Note

If you only need to compress a file, use irradiapy.io.io_utils.compress_file_bz2 instead.

file_path

The path to the bzip2-compressed LAMMPS dump file.

Type:

Path

mode

The file open mode.

Type:

str, optional (default=”wt”)

excluded_items

Atom fields to exclude from output.

Type:

list[str], optional (default=irradiapy.config.EXCLUDED_ITEMS)

encoding

The file encoding.

Type:

str, optional (default=irradiapy.config.ENCODING)

int_format

The format for integers.

Type:

str, optional (default=irradiapy.config.INT_FORMAT)

float_format

The format for floats.

Type:

str, optional (default=irradiapy.config.FLOAT_FORMAT)

compresslevel

The bzip2 compression level.

Type:

int, optional (default=9)

close()[source]

Closes the file associated with this writer.

Return type:

None

compresslevel: int = 9
encoding: str
excluded_items: list[str]
file: BinaryIO = None
file_path: Path
float_format: str
int_format: str
mode: str = 'wt'
write(data)[source]

Writes the data (from LAMMPSReader/BZIP2LAMMPSReader) to the file.

Parameters:

data (dict) – The dictionary containing the data.

Return type:

None

irradiapy.io.lammpslogreader module

Class to read LAMMPS log files.

class irradiapy.io.lammpslogreader.LAMMPSLogReader(path_log)[source]

Bases: object

Class to read LAMMPS log files.

Parameters:

path_log (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.

data: dict
path_log: Path
thermo: ndarray[tuple[Any, ...], dtype[float64]]

irradiapy.io.lammpsreader module

This module contains the LAMMPSReader class.

class irradiapy.io.lammpsreader.LAMMPSReader(file_path, encoding='utf-8')[source]

Bases: object

A class to read data from a LAMMPS dump file.

Note

Assumed orthogonal simulation box.

file_path

The path to the LAMMPS dump file.

Type:

Path

encoding

The file encoding.

Type:

str, optional (default=”utf-8”)

close()[source]

Close the file associated with this reader.

Return type:

None

encoding: str = 'utf-8'
file: TextIO = None
file_path: Path

irradiapy.io.lammpsreadermpi module

This module contains the LAMMPSReaderMPI class.

class irradiapy.io.lammpsreadermpi.LAMMPSReaderMPI(file_path, encoding='utf-8', comm=<factory>)[source]

Bases: MPIExceptionHandlerMixin

A class to read data from a LAMMPS dump file in parallel using MPI.

Note

Assumed orthogonal simulation box.

file_path

The path to the LAMMPS dump file.

Type:

Path

encoding

The file encoding.

Type:

str, optional (default=”utf-8”)

comm

The MPI communicator.

Type:

MPI.Comm, optional (default=mpi4py.MPI.COMM_WORLD)

close()[source]

Closes the file associated with this writer.

Return type:

None

comm: Comm
encoding: str = 'utf-8'
file: TextIO = None
file_path: Path

irradiapy.io.lammpswriter module

This module contains the LAMMPSWriter class.

class irradiapy.io.lammpswriter.LAMMPSWriter(file_path, mode='w', excluded_items=<factory>, encoding=<factory>, int_format=<factory>, float_format=<factory>)[source]

Bases: object

A class to write data like a LAMMPS dump file.

file_path

The path to the LAMMPS dump file.

Type:

Path

mode

The file open mode.

Type:

str, optional (default=”w”)

excluded_items

Atom fields to exclude from output.

Type:

list[str], optional (default=irradiapy.config.EXCLUDED_ITEMS)

encoding

The file encoding.

Type:

str, optional (default=irradiapy.config.ENCODING)

int_format

The format for integers.

Type:

str, optional (default=irradiapy.config.INT_FORMAT)

float_format

The format for floats.

Type:

str, optional (default=irradiapy.config.FLOAT_FORMAT)

close()[source]

Closes the file associated with this writer.

Return type:

None

encoding: str
excluded_items: list[str]
file: TextIO = None
file_path: Path
float_format: str
int_format: str
mode: str = 'w'
write(data)[source]

Writes the data (from LAMMPSReader/BZIP2LAMMPSReader) to the file.

Parameters:

data (dict) – The dictionary containing the timestep data.

Return type:

None

irradiapy.io.lammpswritermpi module

This module contains the LAMMPSWriterMPI class.

class irradiapy.io.lammpswritermpi.LAMMPSWriterMPI(file_path, mode='w', excluded_items=<factory>, encoding=<factory>, int_format=<factory>, float_format=<factory>, comm=<factory>)[source]

Bases: MPIExceptionHandlerMixin

A class to write data like a LAMMPS dump file in parallel using MPI.

file_path

The path to the LAMMPS dump file.

Type:

Path

mode

The file open mode.

Type:

str, optional (default=”w”)

excluded_items

Atom fields to exclude from output.

Type:

list[str], optional (default=irradiapy.config.EXCLUDED_ITEMS)

encoding

The file encoding.

Type:

str, optional (default=irradiapy.config.ENCODING)

int_format

The format for integers.

Type:

str, optional (default=irradiapy.config.INT_FORMAT)

float_format

The format for floats.

Type:

str, optional (default=irradiapy.config.FLOAT_FORMAT)

comm

The MPI communicator.

Type:

MPI.Comm, optional (default=mpi4py.MPI.COMM_WORLD)

close()[source]

Closes the file associated with this writer.

Return type:

None

comm: Comm
encoding: str
excluded_items: list[str]
file: TextIO = None
file_path: Path
float_format: str
int_format: str
mode: str = 'w'
write(data)[source]

Writes the data to the file.

Note

Assumes orthogonal simulation box.

Parameters:

data (dict[str, Any]) – A dictionary containing the data to be written. The keys should include ‘timestep’, ‘boundary’, ‘xlo’, ‘xhi’, ‘ylo’, ‘yhi’, ‘zlo’, ‘zhi’, and any other fields to be written as atom properties.

Return type:

None

irradiapy.io.xyzreader module

This module contains the XYZReader class.

class irradiapy.io.xyzreader.XYZReader(file_path, encoding='utf-8')[source]

Bases: object

A class to read data from an extended XYZ file.

file_path

The path to the XYZ file.

Type:

Path

dtype

The data type of the properties in the file. By default, it is set to None and will be determined from the file.

Type:

npt.DTypeLike

dtype: Union[type[Any], dtype[Any], _SupportsDType[dtype[Any]], tuple[Any, Any], list[Any], _DTypeDict, str, None] = None
encoding: str = 'utf-8'
file: TextIO = None
file_path: Path

irradiapy.io.xyzwriter module

This module contains the XYZWriter class.

class irradiapy.io.xyzwriter.XYZWriter(file_path, mode='w', encoding=<factory>, int_format=<factory>, float_format=<factory>)[source]

Bases: object

Class for writing structured data to an XYZ file format.

Parameters:
  • file_path (Path) – Path to the file where data will be written.

  • mode (str, optional (default="w")) – File open mode.

  • encoding (str, optional (default=irradiapy.config.ENCODING)) – The file encoding.

  • int_format (str, optional (default=irradiapy.config.INT_FORMAT)) – Format for integers.

  • float_format (str, optional (default=irradiapy.config.FLOAT_FORMAT)) – Format for floats.

close()[source]

Close the file associated with this writer.

Return type:

None

encoding: str
file: TextIO = None
file_path: Path
float_format: str
int_format: str
mode: str = 'w'
write(datas, extra_comment='')[source]

Writes the given data into the file.

Parameters:
  • datas (npt.NDArray) – Data to write.

  • extra_comment (str, optional) – Additional info to add at the end of the comment. Must follow xyz guidelines. Example: ‘Info=”Fe irradiatied in Fe, Ion 1”’

Return type:

None

Module contents

This subpackage provides classes for reading and writing various file formats.