IO module
- IO.find_gb_location(filepath)[source]
Determines the location of a grain boundary based on centro-symmetry parameter.
- Parameters:
filepath (str) – Path to the LAMMPS dump file.
- Returns:
average_gb_loc (float): Average z-location of the grain boundary.
extreme_gb_loc_hi (float): Upper bound of GB atom positions.
extreme_gb_loc_lo (float): Lower bound of GB atom positions.
- Return type:
tuple
- IO.read_LAMMPS_datafile(path_r, mode=1)[source]
Reads a LAMMPS data file and extracts atom positions and box dimensions.
- Parameters:
path_r (str) – Path to the data file.
mode (int, optional) – Parsing mode. - 1: Expecting 5 columns per atom line. - 2: Expecting 8 columns per atom line.
- Returns:
- A list containing:
number of atoms (int)
number of types (int)
box dimensions (3x2 np.ndarray)
atom positions (np.ndarray)
- Return type:
list
- IO.read_LAMMPS_dumpfile(path_r)[source]
Reads atomic configurations from a LAMMPS dump file.
- Parameters:
path_r (str) – Path to the LAMMPS dump file.
- Returns:
- A list of snapshots, each containing:
timestep (float)
number of atoms (int)
box dimensions (3x2 np.ndarray)
atomic data (np.ndarray of shape [n_atoms, 7])
- Return type:
list
- IO.read_gridsearch_results(filepath)[source]
Reads grid search results from a custom text file (displacements and GB energy).
- Parameters:
filepath (str) – Path to the results file.
- Returns:
Array with columns [dispy, dispz, GB_energy].
- Return type:
np.ndarray
- IO.read_neb_output_data(path_r, mode)[source]
Reads output from a NEB (nudged elastic band) LAMMPS simulation.
- Parameters:
path_r (str) – Path to NEB output dump file.
mode (int) – Determines number of atom attributes to read (7 or 8 columns).
- Returns:
- A list of snapshots, each with:
timestep (float)
number of atoms (int)
box dimensions (3x2 np.ndarray)
atomic data (np.ndarray of shape [n_atoms, N])
- Return type:
list
- IO.write_LAMMPSoutput_tstep(natoms, Atoms, box, folder, file, tstep)[source]
Writes a single timestep’s atomic configuration to a LAMMPS trajectory file.
- Parameters:
natoms (int) – Total number of atoms.
Atoms (np.ndarray) – Array of atomic data (id, type, x, y, z, PotEng, CentroSym).
box (np.ndarray) – Box dimensions (3x2).
folder (str) – Output folder.
file (str) – File name.
tstep (int) – Timestep to write.
- Returns:
Path to the output trajectory file.
- Return type:
str
- IO.write_gridsearch_results(filepath, data)[source]
Writes displacements and GB energy to a tabulated results file.
- Parameters:
filepath (str) – Output file path.
data (np.ndarray) – Array of shape (N, 3) containing: - dispy (float) - dispz (float) - GB energy (float)
- IO.write_lammps_datafile(folder, file, suffix, g_A, g_B, input_box, mode=2)[source]
Writes a LAMMPS data file for a bicrystal configuration.
- Parameters:
folder (str) – Path to output folder.
file (str) – File name prefix.
suffix (str) – File suffix (e.g., ‘min_shuffle’).
g_A (np.ndarray) – Atom positions for grain A.
g_B (np.ndarray) – Atom positions for grain B.
input_box (np.ndarray) – Original box dimensions (3x3).
mode (int, optional) – Determines which box vector to expand for bicrystal. Default is 2 (z-direction).
- Returns:
Path to the generated data file.
- Return type:
str