kliff.utils¶
- kliff.utils.split_string(string, length=80, starter=None)[source]¶
Insert n into long string such that each line has size no more than length.
- Parameters:
string (
str) – The string to split.length – Targeted length of the each line.
starter (
Optional[str]) – String to insert at the beginning of each line.
- kliff.utils.download_dataset(dataset_name)[source]¶
Download dataset and untar it.
- Parameters:
dataset_name (
str) – name of the dataset- Return type:
Path- Returns:
Path to the dataset
- kliff.utils.stress_to_voigt(input_stress)[source]¶
Convert stress from 3x3 tensor notation to 6x1 Voigt notation.
- Parameters:
input_stress (
ndarray) – Stress tensor in Voigt notation or tensor notation.- Returns:
Stress tensor Voigt notation.
- Return type:
stress
- kliff.utils.stress_to_tensor(input_stress)[source]¶
Convert stress from 6x1 Voigt notation to 3x3 tensor notation.
- Parameters:
input_stress (
list) – Stress tensor in Voigt notation.- Returns:
Stress tensor notation.
- Return type:
stress
- kliff.utils.is_kim_model_installed(model_name)[source]¶
Check if the KIM model is installed in any collection. :rtype:
bool- Args:
model_name: name of the model.
- kliff.utils.install_kim_model(model_name, collection='user')[source]¶
Install the KIM model
- Parameters:
model_name (
str) – name of the model.collection (
str) – name of the collection.
- Return type:
bool- Returns:
True if the model is now installed, False otherwise.
- kliff.utils.get_n_configs_in_xyz(file_path)[source]¶
Get the number of configurations in a xyz file. It uses the grep command to count the number of lines that contain only numbers. :type file_path:
str:param file_path: Path to the xyz file.Returns:
- Return type:
int
- kliff.utils.str_to_numpy(expression, dtype)[source]¶
Convert a string to numpy array. For reading from SQL/HF databases.
- Parameters:
expression (
str) – Numpy array expression.dtype (
Any) – dtype to convert to.
- Return type:
Union[ndarray,Any]- Returns:
Numpy array of str, else returns the same object.