Predict

Helper functions which obtain forces and energies corresponding to atoms in structures. These functions automatically cast atoms into their respective atomic environments.

flare.predict.predict_on_atom(param: Tuple[flare.struc.Structure, int, flare.gp.GaussianProcess]) -> ('np.ndarray', 'np.ndarray')

Return the forces/std. dev. uncertainty associated with an individual atom in a structure, without necessarily having cast it to a chemical environment. In order to work with other functions, all arguments are passed in as a tuple.

Parameters:param (Tuple(Structure, integer, GaussianProcess)) – tuple of FLARE Structure, atom index, and Gaussian Process object
Returns:3-element force array and associated uncertainties
Return type:(np.ndarray, np.ndarray)
flare.predict.predict_on_atom_efs(param)

Predict the local energy, forces, and partial stresses and predictive variances of a chemical environment.

flare.predict.predict_on_atom_en(param: Tuple[flare.struc.Structure, int, flare.gp.GaussianProcess]) -> ('np.ndarray', 'np.ndarray', <class 'float'>)

Return the forces/std. dev. uncertainty / energy associated with an individual atom in a structure, without necessarily having cast it to a chemical environment. In order to work with other functions, all arguments are passed in as a tuple.

Parameters:param (Tuple(Structure, integer, GaussianProcess)) – tuple of FLARE Structure, atom index, and Gaussian Process object
Returns:3-element force array, associated uncertainties, and local energy
Return type:(np.ndarray, np.ndarray, float)
flare.predict.predict_on_atom_en_std(param)

Predict local energy and predictive std of a chemical environment.

flare.predict.predict_on_structure(structure: flare.struc.Structure, gp: flare.gp.GaussianProcess, n_cpus: int = None, write_to_structure: bool = True, selective_atoms: List[int] = None, skipped_atom_value=0) -> ('np.ndarray', 'np.ndarray')

Return the forces/std. dev. uncertainty associated with each individual atom in a structure. Forces are stored directly to the structure and are also returned.

Parameters:
  • structure – FLARE structure to obtain forces for, with N atoms
  • gp – Gaussian Process model
  • write_to_structure – Write results to structure’s forces, std attributes
  • selective_atoms – Only predict on these atoms; e.g. [0,1,2] will only predict and return for those atoms
  • skipped_atom_value – What value to use for atoms that are skipped. Defaults to 0 but other options could be e.g. NaN. Will NOT write this to the structure if write_to_structure is True.
Returns:

N x 3 numpy array of foces, Nx3 numpy array of uncertainties

Return type:

(np.ndarray, np.ndarray)

flare.predict.predict_on_structure_en(structure: flare.struc.Structure, gp: flare.gp.GaussianProcess, n_cpus: int = None, write_to_structure: bool = True, selective_atoms: List[int] = None, skipped_atom_value=0) -> ('np.ndarray', 'np.ndarray', 'np.ndarray')

Return the forces/std. dev. uncertainty / local energy associated with each individual atom in a structure. Forces are stored directly to the structure and are also returned.

Parameters:
  • structure – FLARE structure to obtain forces for, with N atoms
  • gp – Gaussian Process model
  • n_cpus – Dummy parameter passed as an argument to allow for flexibility when the callable may or may not be parallelized
Returns:

N x 3 array of forces, N x 3 array of uncertainties, N-length array of energies

Return type:

(np.ndarray, np.ndarray, np.ndarray)

flare.predict.predict_on_structure_mgp(structure: flare.struc.Structure, mgp: flare.mgp.mgp.MappedGaussianProcess, output=None, output_name=None, n_cpus: int = None, write_to_structure: bool = True, selective_atoms: List[int] = None, skipped_atom_value: Union[float, int] = 0, energy: bool = False) → Union[Tuple[<sphinx.ext.autodoc.importer._MockObject object at 0x7f53bde87b90>, <sphinx.ext.autodoc.importer._MockObject object at 0x7f53bde87350>, float], Tuple[<sphinx.ext.autodoc.importer._MockObject object at 0x7f53bde875d0>, <sphinx.ext.autodoc.importer._MockObject object at 0x7f53bde87550>]]

Assign forces to structure based on an mgp

flare.predict.predict_on_structure_par(structure: flare.struc.Structure, gp: flare.gp.GaussianProcess, n_cpus: int = None, write_to_structure: bool = True, selective_atoms: List[int] = None, skipped_atom_value=0) -> ('np.ndarray', 'np.ndarray')

Return the forces/std. dev. uncertainty associated with each individual atom in a structure. Forces are stored directly to the structure and are also returned.

Parameters:
  • structure – FLARE structure to obtain forces for, with N atoms
  • gp – Gaussian Process model
  • n_cpus – Number of cores to parallelize over
  • write_to_structure – Write results to structure’s forces, std attributes
  • selective_atoms – Only predict on these atoms; e.g. [0,1,2] will only predict and return for those atoms
  • skipped_atom_value – What value to use for atoms that are skipped. Defaults to 0 but other options could be e.g. NaN. Will NOT write this to the structure if write_to_structure is True.
Returns:

N x 3 array of forces, N x 3 array of uncertainties

Return type:

(np.ndarray, np.ndarray)

flare.predict.predict_on_structure_par_en(structure: flare.struc.Structure, gp: flare.gp.GaussianProcess, n_cpus: int = None, write_to_structure: bool = True, selective_atoms: List[int] = None, skipped_atom_value=0) -> ('np.ndarray', 'np.ndarray', 'np.ndarray')

Return the forces/std. dev. uncertainty / local energy associated with each individual atom in a structure, parallelized over atoms. Forces are stored directly to the structure and are also returned.

Parameters:
  • structure – FLARE structure to obtain forces for, with N atoms
  • gp – Gaussian Process model
  • n_cpus – Number of cores to parallelize over
Returns:

N x 3 array of forces, N x 3 array of uncertainties, N-length array of energies

Return type:

(np.ndarray, np.ndarray, np.ndarray)