Input Output
Dealing with input
Functions
read_xyz(file, extra_cols_indexes=None)
wrapper of read_xyz_movie to read single-frame movies - mostyl for compatibility
Source code in snow/io/xyz.py
read_xyz_movie(file_path, extra_cols_indexes=None)
Obtains the coordinates and elements for each frame of an xyz trajectory.
Parameters
file_path : str Path to the xyz file with the structure extra_frames_indexes : str index for the extra columns of per-atom data to be extracted from the .xyz file. Consider that the first three 'indexes' are element and three cartesian coordinates and are returned by deafult from the function. Example: if your .xyz file has per-atom information like " El pos1 pos2 pos3 force1 force2 force3 charge ", you can get the extra columns force1, force2, charge by passing extra_cols_indexes=[4, 5, 7]. For now only float values parsing is supported.
Returns
Tuple[np.ndarray, np.ndarray] list of lists of chemical symbols and a list of (n_atoms, 3) arrays for the coordinates
Source code in snow/io/xyz.py
write_phantom_xyz(filename, coords, additional_data=None)
Writes atomic data to an XYZ file in OVITO-compatible format.
Parameters
filename: str Name of the output .xyz file. elements: ndarray List of atomic symbols (e.g., ['Au', 'Au', ...]). coords: ndarray) Nx3 array of atomic coordinates. additional_data: list or np.ndarray, optional Additional per-atom data, such as coordination numbers.
Returns:
| Type | Description |
|---|---|
|
An xyz file containing the elements and coordinates of each atom and any additional per atom data (e.g. coordination number, agcn, strain...) |
Source code in snow/io/xyz.py
write_xyz(filename, elements, coords, additional_data=None, box=None, mode='w')
Writes atomic data to an XYZ file in OVITO-compatible format. Currently only accepting numbers as additional data.
Parameters
filename: str Name of the output .xyz file. elements: ndarray List of atomic symbols (e.g., ['Au', 'Au', ...]). coords: ndarray) Nx3 array of atomic coordinates. additional_data: list or np.ndarray, optional Additional per-atom data, such as coordination numbers. box: np.ndarray a box to be written to file mode: str mode for writing ('a'->append, 'w'->(over)write)
Returns:
| Type | Description |
|---|---|
|
None |
Source code in snow/io/xyz.py
write_xyz_movie(filename, elements_list, coords_list, additional_data_list=None, box_list=None)
Writes an xyz movie by reiterating the usage of write_xyz function.
Parameters
filename: str Name of the output .xyz file. elements: ndarray List of atomic symbols (e.g., ['Au', 'Au', ...]). coords: ndarray) Nx3 array of atomic coordinates. additional_data: list or np.ndarray, optional Additional per-atom data, such as coordination numbers. box: np.ndarray a box to be written to file
Returns:
| Type | Description |
|---|---|
|
None |
Source code in snow/io/xyz.py
write_xyz_movie_old(frame, filename, elements, coords, additional_data=None)
Writes atomic data to an XYZ file in OVITO-compatible format.
Parameters
frame: int Frame number. filename: str Name of the output .xyz file. elements: ndarray List of atomic symbols (e.g., ['Au', 'Au', ...]). coords: ndarray) Nx3 array of atomic coordinates. additional_data: list or np.ndarray, optional Additional per-atom data, such as coordination numbers.
Returns:
| Type | Description |
|---|---|
|
An xyz file containing the elements and coordinates of each atom and any additional per atom data (e.g. coordination number, agcn, strain...) |
Source code in snow/io/xyz.py
write_xyz_movie_with_str(frame, filename, elements, coords, additional_data=None)
Writes atomic data to an XYZ file in OVITO-compatible format.
Parameters
frame: int Frame number. filename: str Name of the output .xyz file. elements: list or ndarray List of atomic symbols (e.g., ['Au', 'Au', ...]). coords: ndarray Nx3 array of atomic coordinates. additional_data: list or np.ndarray, optional Additional per-atom data, such as coordination numbers, site types, etc. Can contain both numeric and string data.
Returns
None
Source code in snow/io/xyz.py
read_lammps_data(file_path)
Read structure from a LAMMPS data file at a certain path
Parameters
file_path : str Path to the lammps data file
Returns
Tuple[np.ndarray, np.ndarray] Elements and coordinates array of the system
Source code in snow/io/lammps.py
read_order_lammps_dump(filename, id_index=0, type_index=1, coords_indexes=[2, 3, 4], scaled_coords=True)
Extract a movie ( Tuple[np.ndarray, np.ndarray] ) from a lammps dump file. Atoms are not written in a consistent
order in dump files, so you generally need to reorder them. You can choose the columns to get the information about id, type, and coords from the lammps dump file. Default is to 'atomic' style, which has the shape 'id type xs ys zs'.
Parameters
filename : str filename for the lammps-dump file to extract atoms from. id_index: int index of the column that contains ids of your atoms in the lammps dump - default to 0 type_index: int index of the column that contains the type of atoms in the dump (in lammps these are mapped to numbers) coords_indexes: list of ints list of indexes of the columns that contain the positions of your atoms - default to [1,2,3] scaled_coords: bool bool to check if coordinates are scaled (written in terms of the box sizes length). Default to True, which is lammps' default. Probably this can be dealt with automatically by checking if all positions are between 0 and 1, but not super general and robust
Returns
Tuple[np.ndarray, np.ndarray] species ids and positions from the lammps dump with consistent ordering of atoms. Here, pos[i] is a Nx3 array with positions of the i-th frame and so on.
Source code in snow/io/lammps.py
63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 | |
read_lammps_data(file_path)
Read structure from a LAMMPS data file at a certain path
Parameters
file_path : str Path to the lammps data file
Returns
Tuple[np.ndarray, np.ndarray] Elements and coordinates array of the system
Source code in snow/io/lammps.py
read_order_lammps_dump(filename, id_index=0, type_index=1, coords_indexes=[2, 3, 4], scaled_coords=True)
Extract a movie ( Tuple[np.ndarray, np.ndarray] ) from a lammps dump file. Atoms are not written in a consistent
order in dump files, so you generally need to reorder them. You can choose the columns to get the information about id, type, and coords from the lammps dump file. Default is to 'atomic' style, which has the shape 'id type xs ys zs'.
Parameters
filename : str filename for the lammps-dump file to extract atoms from. id_index: int index of the column that contains ids of your atoms in the lammps dump - default to 0 type_index: int index of the column that contains the type of atoms in the dump (in lammps these are mapped to numbers) coords_indexes: list of ints list of indexes of the columns that contain the positions of your atoms - default to [1,2,3] scaled_coords: bool bool to check if coordinates are scaled (written in terms of the box sizes length). Default to True, which is lammps' default. Probably this can be dealt with automatically by checking if all positions are between 0 and 1, but not super general and robust
Returns
Tuple[np.ndarray, np.ndarray] species ids and positions from the lammps dump with consistent ordering of atoms. Here, pos[i] is a Nx3 array with positions of the i-th frame and so on.
Source code in snow/io/lammps.py
63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 | |
read_xyz(file, extra_cols_indexes=None)
wrapper of read_xyz_movie to read single-frame movies - mostyl for compatibility
Source code in snow/io/xyz.py
read_xyz_movie(file_path, extra_cols_indexes=None)
Obtains the coordinates and elements for each frame of an xyz trajectory.
Parameters
file_path : str Path to the xyz file with the structure extra_frames_indexes : str index for the extra columns of per-atom data to be extracted from the .xyz file. Consider that the first three 'indexes' are element and three cartesian coordinates and are returned by deafult from the function. Example: if your .xyz file has per-atom information like " El pos1 pos2 pos3 force1 force2 force3 charge ", you can get the extra columns force1, force2, charge by passing extra_cols_indexes=[4, 5, 7]. For now only float values parsing is supported.
Returns
Tuple[np.ndarray, np.ndarray] list of lists of chemical symbols and a list of (n_atoms, 3) arrays for the coordinates
Source code in snow/io/xyz.py
write_xyz(filename, elements, coords, additional_data=None, box=None, mode='w')
Writes atomic data to an XYZ file in OVITO-compatible format. Currently only accepting numbers as additional data.
Parameters
filename: str Name of the output .xyz file. elements: ndarray List of atomic symbols (e.g., ['Au', 'Au', ...]). coords: ndarray) Nx3 array of atomic coordinates. additional_data: list or np.ndarray, optional Additional per-atom data, such as coordination numbers. box: np.ndarray a box to be written to file mode: str mode for writing ('a'->append, 'w'->(over)write)
Returns:
| Type | Description |
|---|---|
|
None |
Source code in snow/io/xyz.py
write_xyz_movie(filename, elements_list, coords_list, additional_data_list=None, box_list=None)
Writes an xyz movie by reiterating the usage of write_xyz function.
Parameters
filename: str Name of the output .xyz file. elements: ndarray List of atomic symbols (e.g., ['Au', 'Au', ...]). coords: ndarray) Nx3 array of atomic coordinates. additional_data: list or np.ndarray, optional Additional per-atom data, such as coordination numbers. box: np.ndarray a box to be written to file
Returns:
| Type | Description |
|---|---|
|
None |