kliff.utils

kliff.utils.length_equal(a, b)[source]
kliff.utils.torch_available()[source]
kliff.utils.torch_geometric_available()[source]
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.seed_all(seed=35, cudnn_benchmark=False, cudnn_deterministic=False)[source]
kliff.utils.to_path(path)[source]

Convert str (or filename) to pathlib.Path.

Return type:

Path

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.create_directory(path, is_directory=False)[source]
kliff.utils.yaml_dump(data, filename)[source]

Dump data to a yaml file.

kliff.utils.yaml_load(filename)[source]

Load data from a yaml file.

kliff.utils.pickle_dump(data, filename)[source]

Dump data to a pickle file.

kliff.utils.pickle_load(filename)[source]

Load data from a pikel file.

kliff.utils.stress_to_voigt(input_stress)[source]

Convert stress from 3x3 tensor notation to 6x1 Voigt notation. \sigma_{ij} = [\sigma_{11}, \sigma_{22}, \sigma_{33}, \sigma_{23}, \sigma_{13}, \sigma_{12}]

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.