porereax.utils¶
Module providing utility functions for the PoreReax package.
This module includes functions for saving and loading Python objects using pickle, loading YAML configuration files, and common mathematical operations such as the minimum-image convention.
Functions¶
|
Save a Python object to a file using pickle. |
|
Load a Python object from a file using pickle. |
|
Load a YAML file and return its contents as a dictionary. |
|
Apply the minimal image convention to a vector given the simulation box dimensions. |
|
Calculate the midpoint between two vectors considering the minimal image convention. |
|
Retrieve the list of identifiers from a data file. |
|
Retrieve the data for a specific identifier from a data file. |
|
Read a YAML file containing pore system properties and extract relevant depending on the pore shape. |
Module Contents¶
- porereax.utils.save_object(obj, filename)[source]¶
Save a Python object to a file using pickle.
- Parameters:
obj (any) – The Python object to be saved.
filename (str) – The path to the file where the object will be saved.
- porereax.utils.load_object(file_path)[source]¶
Load a Python object from a file using pickle.
- Parameters:
file_path (str) – The path to the file from which the object will be loaded.
- Returns:
The loaded Python object.
- Return type:
any
- porereax.utils.load_yaml(file_path: str) dict[source]¶
Load a YAML file and return its contents as a dictionary.
- porereax.utils.min_image_convention(vec: numpy.ndarray, box: numpy.ndarray) numpy.ndarray[source]¶
Apply the minimal image convention to a vector given the simulation box dimensions.
- Parameters:
vec (np.ndarray) – The input vector (shape: (N, 3)).
box (np.ndarray) – The simulation box dimensions (shape: (3,)).
- Returns:
The vector adjusted by the minimal image convention (shape: (N, 3)).
- Return type:
np.ndarray
- porereax.utils.min_image_midpoint(vec1: numpy.ndarray, vec2: numpy.ndarray, box: numpy.ndarray) numpy.ndarray[source]¶
Calculate the midpoint between two vectors considering the minimal image convention.
- Parameters:
vec1 (np.ndarray) – The first vector (shape: (N, 3)).
vec2 (np.ndarray) – The second vector (shape: (N, 3)).
box (np.ndarray) – The simulation box dimensions (shape: (3,)).
- Returns:
The midpoint vector adjusted by the minimal image convention (shape: (N, 3)).
- Return type:
np.ndarray
- porereax.utils.get_identifiers(link_data: str) list[source]¶
Retrieve the list of identifiers from a data file.
- porereax.utils.get_data(link_data: str, identifier: str) dict[source]¶
Retrieve the data for a specific identifier from a data file.