From 2b32fc59e5b1045f551af8766cb805f1a5d3d049 Mon Sep 17 00:00:00 2001 From: hjung Date: Tue, 8 Oct 2024 13:21:34 +0000 Subject: [PATCH] mace_desc.py deleted --- wfl/descriptors/mace_desc.py | 65 ------------------------------------ 1 file changed, 65 deletions(-) delete mode 100644 wfl/descriptors/mace_desc.py diff --git a/wfl/descriptors/mace_desc.py b/wfl/descriptors/mace_desc.py deleted file mode 100644 index 9140a4ec..00000000 --- a/wfl/descriptors/mace_desc.py +++ /dev/null @@ -1,65 +0,0 @@ -import numpy as np - -from wfl.autoparallelize import autoparallelize, autoparallelize_docstring -from wfl.utils.parallel import construct_calculator_picklesafe -from ase.atoms import Atoms - - -def _calc_autopara_wrappable(atoms, calculator, key, invariants_only=True, per_atom=False, normalize=True, force=False): - """ - MACE descriptor - - Parameters - ---------- - atoms : ase.atoms.Atoms / list(Atoms) - input configurations - calculator : calculator - In this case MACE calculator - key: str - key in Atoms.info (``not per_atom``) or Atoms.arrays (``per_atom``) to store information - invariants_only : bool, default True - get only invariant part of the descriptor - per_atom: bool, default False - calculate a local (per-atom) descriptor, as opposed to global (per-config) - normalize: bool, default True - normalize final vector (e.g. if contributions from multiple descriptors were concatenated) - force: bool, default False - overwrite key if already exists - - Returns - ------- - atoms : Atoms or list(Atoms) - Input configurations with descriptors in info/arrays - """ - - calculator = construct_calculator_picklesafe(calculator) - - if isinstance(atoms, Atoms): - at_list = [atoms] - else: - at_list = atoms - - descriptor_encoded_atoms = [] - for i, at in enumerate(at_list): - if key in at.info: - if force: - del at.info[key] - else: - raise RuntimeError(f'Got info key {key} which already exists, pass force=True to overwrite') - - if per_atom: - at.info[key] = calculator.get_descriptors(at, invariants_only=invariants_only) - else: - descriptor = np.average(calculator.get_descriptors(at, invariants_only=invariants_only), axis=0) - if normalize: - at.info[key] = descriptor / np.linalg.norm(descriptor) - else: - at.info[key] = descriptor - - descriptor_encoded_atoms.append(at) - - return descriptor_encoded_atoms - -def calculate(*args, **kwargs): - return autoparallelize(_calc_autopara_wrappable, *args, **kwargs) -autoparallelize_docstring(calculate, _calc_autopara_wrappable, "Atoms")