irradiapy.utils.io module

Utility functions for I/O operations.

irradiapy.utils.io.apply_boundary_conditions_to_lammps(in_path, out_path, x, y, z, overwrite=False)[source]

Apply periodic boundary conditions to a LAMMPS dump file.

Parameters:
  • in_path (Path) – Path to the input LAMMPS file (bzip2 compressed or not).

  • out_path (Path) – Path to the output LAMMPS file (bzip2 compressed or not).

  • x (bool) – Whether to apply periodic boundary conditions in the x direction.

  • y (bool) – Whether to apply periodic boundary conditions in the y direction.

  • z (bool) – Whether to apply periodic boundary conditions in the z direction.

  • overwrite (bool) – Whether to overwrite the output file if it exists.

Return type:

None

irradiapy.utils.io.compress_file_bz2(input_path, output_path, compresslevel=9)[source]

Compress a file using bzip2.

Parameters:
  • input_path (str) – Path to the input file to be compressed.

  • output_path (str) – Path where the compressed file will be saved.

  • compresslevel (int) – Compression level for bzip2.

Return type:

None

irradiapy.utils.io.decompress_file_bz2(input_path, output_path)[source]

Decompress a bzip2-compressed file.

Parameters:
  • input_path (str) – Path to the input .bz2 file.

  • output_path (str) – Path to the output decompressed file.

Return type:

None

irradiapy.utils.io.get_last_reader(reader)[source]

Get the last snapshot from a LAMMPS dump file using a reader.

Parameters:

reader (Iterable[dict[str, Any]]) – An instance of a LAMMPS reader.

Returns:

The last snapshot from the LAMMPS file.

Return type:

dict[str, Any]

irradiapy.utils.io.lammps_to_mmonca(path_in, path_out, scale=10.0)[source]

Convert LAMMPS dump file to MMonCa format. Uses LAMMPSReader.

Parameters:
  • path_in (str) – Path to the input LAMMPS dump file.

  • path_out (str) – Path to the output MMonCa file.

  • scale (float) – Divisor applied to coordinates. The default converts angstroms to nanometers.

Return type:

None

Warning

This converter is very basic: defects of type 0 are considered vacancies (V), and all other defect types are considered interstitials (I). Therefore, this will produce wrong results when multiple elements are present.

irradiapy.utils.io.merge_lammps_snapshots(in_path, out_path, overwrite=False)[source]

Merge multiple snapshots in a LAMMPS file into a single snapshot.

Parameters:
  • in_path (Path) – Path to the input LAMMPS file (bzip2 compressed or not).

  • out_path (Path) – Path to the output LAMMPS file (bzip2 compressed or not).

  • overwrite (bool) – Whether to overwrite the output file if it exists.

Returns:

A dictionary containing the merged snapshot data.

Return type:

dict[str, Any]