Multi-element Kernels (Separate Parameters)

Multicomponent kernels (simple) restrict all signal variance and length scale of hyperparameters to a single value. The kernels in this module allow you to have different sets of hyperparameters and cutoffs for different interactions, and have flexible groupings of elements. It also allows you to do partial hyper-parameter training, keeping some components fixed.

To use this set of kernels, we need a hyps_mask dictionary for GaussianProcess, MappedGaussianProcess, and AtomicEnvironment (if you also set up different cutoffs). A simple example is shown below.

Examples

>>> from flare.util.parameter_helper import ParameterHelper
>>> from flare.gp import GaussianProcess
>>> pm = ParameterHelper(species=['O', 'C', 'H'],
...                      kernels={'twobody':[['*', '*'], ['O','O']],
...                               'threebody':[['*', '*', '*'], ['O','O', 'O']]},
...                      parameters={'twobody0':[1, 0.5, 1], 'twobody1':[2, 0.2, 2],
...                            'triplet0':[1, 0.5], 'triplet1':[2, 0.2],
...                            'cutoff_twobody':2, 'cutoff_threebody':1, 'noise': 0.05},
...                      constraints={'twobody0':[False, True]})
>>> hyps_mask = pm1.as_dict()
>>> hyps = hyps_mask.pop('hyps')
>>> cutoffs = hyps_mask.pop('cutoffs')
>>> hyp_labels = hyps_mask.pop('hyp_labels')
>>> kernels = hyps_mask['kernels']
>>> gp_model = GaussianProcess(kernels=kernels,
...                            hyps=hyps, cutoffs=cutoffs,
...                            hyp_labels=hyp_labels,
...                            parallel=True, per_atom_par=False,
...                            n_cpus=n_cpus,
...                            multihyps=True, hyps_mask=hm)

In the example above, Parameters class generates the arrays needed for these kernels and store all the grouping and mapping information in the hyps_mask dictionary. It stores following keys and values:

  • spec_mask: 118-long integer array descirbing which elements belong to
    like groups for determining which bond hyperparameters to use. For instance, [0,0,1,1,0 …] assigns H to group 0, He and Li to group 1, and Be to group 0 (the 0th register is ignored).
  • nspec: Integer, number of different species groups (equal to number of
    unique values in spec_mask).
  • nbond: Integer, number of different hyperparameter sets to associate with
    different 2-body pairings of atoms in groups defined in spec_mask.
  • bond_mask: Array of length nspec^2, which describes the hyperparameter sets to
    associate with different pairings of species types. For example, if there are atoms of type 0 and 1, then bond_mask defines which hyperparameters to use for parings [0-0, 0-1, 1-0, 1-1]: if we wanted hyperparameter set 0 for 0-0 parings and set 1 for 0-1 and 1-1 pairings, then we would make bond_mask [0, 1, 1, 1].
  • ntriplet: Integer, number of different hyperparameter sets to associate
    with different 3-body pariings of atoms in groups defined in spec_mask.
  • triplet_mask: Similar to bond mask: Triplet pairings of type 0 and 1 atoms
    would go {0-0-0, 0-0-1, 0-1-0, 0-1-1, 1-0-0, 1-0-1, 1-1-0, 1-1-1}, and if we wanted hyp. set 0 for triplets with only atoms of type 0 and hyp. set 1 for all the rest, then the triplet_mask array would read [0,1,1,1,1,1,1,1]. The user should make sure that the mask has a permutational symmetry.
  • cutoff_2b: Array of length nbond, which stores the cutoff used for different
    types of bonds defined in bond_mask
  • ncut3b: Integer, number of different cutoffs sets to associate
    with different 3-body pariings of atoms in groups defined in spec_mask.
  • cut3b_mask: Array of length nspec^2, which describes the cutoff to
    associate with different bond types in triplets. For example, in a triplet (C, O, H) , there are three cutoffs. Cutoffs for CH bond, CO bond and OH bond. If C and O are associate with atom group 1 in spec_mask and H are associate with group 0 in spec_mask, the cut3b_mask[1*nspec+0] determines the C/O-H bond cutoff, and cut3b_mask[1*nspec+1] determines the C-O bond cutoff. If we want the former one to use the 1st cutoff in cutoff_3b and the later to use the 2nd cutoff in cutoff_3b, the cut3b_mask should be [0, 0, 0, 1]
  • cutoff_3b: Array of length ncut3b, which stores the cutoff used for different
    types of bonds in triplets.
  • nmb : Integer, number of different cutoffs set to associate with different coordination
    numbers
  • mb_mask: similar to bond_mask and cut3b_mask.
  • cutoff_mb: Array of length nmb, stores the cutoff used for different many body terms

For selective optimization. one can define ‘map’, ‘train_noise’ and ‘original’ to identify which element to be optimized. All three have to be defined. train_noise = Bool (True/False), whether the noise parameter can be optimized original: np.array. Full set of initial values for hyperparmeters map: np.array, array to map the hyper parameter back to the full set. map[i]=j means the i-th element in hyps should be the j-th element in hyps_mask[‘original’]

For example, the full set of hyper parmeters may include [ls21, ls22, sig21, sig22, ls3 sg3, noise] but suppose you wanted only the set 21 optimized. The full set of hyperparameters is defined in ‘original’; include all those you want to leave static, and set initial guesses for those you want to vary. Have the ‘map’ list contain the indices of the hyperparameters in ‘original’ that correspond to the hyperparameters you want to vary. Have a hyps list which contain those which you want to vary. Below, ls21, ls22 etc… represent floating-point variables which correspond to the initial guesses / static values. You would then pass in:

hyps = [ls21, sig21] hyps_mask = { …, ‘train_noise’: False, ‘map’:[0, 2],

‘original’: [ls21, ls22, sig21, sig22, ls3, sg3, noise]}

the hyps argument should only contain the values that need to be optimized. If you want noise to be trained as well include noise as the final hyperparameter value in hyps.

flare.kernels.mc_sephyps.many_body_mc(env1, env2, d1, d2, cutoff_2b, cutoff_3b, cutoff_mb, nspec, spec_mask, nbond, bond_mask, ntriplet, triplet_mask, ncut3b, cut3b_mask, nmb, mb_mask, sig2, ls2, sig3, ls3, sigm, lsm, cutoff_func=<function quadratic_cutoff>)

many-body multi-element kernel between two force components.

Parameters:
  • env1 (AtomicEnvironment) – First local environment.
  • env2 (AtomicEnvironment) – Second local environment.
  • d1 (int) – Force component of the first environment.
  • d2 (int) – Force component of the second environment.
  • cutoff_2b – dummy
  • cutoff_3b – dummy
  • cutoff_mb (float, np.ndarray) – cutoff(s) for coordination-based manybody interaction
  • nspec (int) – number of different species groups
  • spec_mask (np.ndarray) – 118-long integer array that determines specie group
  • nbond – dummy
  • bond_mask – dummy
  • ntriplet – dummy
  • triplet_mask – dummy
  • ncut3b – dummy
  • cut3b_mask – dummy
  • nmb (int) – number of different hyperparameter sets to associate with manybody pairings
  • mb_mask (np.ndarray) – nspec^2 long integer array
  • sig2 – dummy
  • ls2 – dummy
  • sig3 – dummy
  • ls3 – dummy
  • sigm (np.ndarray) – signal variances associates with manybody term
  • lsm (np.ndarray) – length scales associates with manybody term
  • cutoff_func (Callable) – Cutoff function of the kernel.
Returns:

Value of the 2+3+many-body kernel.

Return type:

float

flare.kernels.mc_sephyps.many_body_mc_en(env1, env2, cutoff_2b, cutoff_3b, cutoff_mb, nspec, spec_mask, nbond, bond_mask, ntriplet, triplet_mask, ncut3b, cut3b_mask, nmb, mb_mask, sig2, ls2, sig3, ls3, sigm, lsm, cutoff_func=<function quadratic_cutoff>)

many-body multi-element kernel between two local energies.

Parameters:
  • env1 (AtomicEnvironment) – First local environment.
  • env2 (AtomicEnvironment) – Second local environment.
  • hyps (np.ndarray) – Hyperparameters of the kernel function (sig, ls).
  • cutoffs (np.ndarray) – One-element array containing the 2-body cutoff.
  • cutoff_func (Callable) – Cutoff function of the kernel.
Returns:

Value of the 2-body force/energy kernel.

Return type:

float

flare.kernels.mc_sephyps.many_body_mc_force_en(env1, env2, d1, cutoff_2b, cutoff_3b, cutoff_mb, nspec, spec_mask, nbond, bond_mask, ntriplet, triplet_mask, ncut3b, cut3b_mask, nmb, mb_mask, sig2, ls2, sig3, ls3, sigm, lsm, cutoff_func=<function quadratic_cutoff>)

many-body single-element kernel between two local energies.

Parameters:
  • env1 (AtomicEnvironment) – First local environment.
  • env2 (AtomicEnvironment) – Second local environment.
  • hyps (np.ndarray) – Hyperparameters of the kernel function (sig, ls).
  • cutoffs (np.ndarray) – Two-element array containing the 2-, 3-, and many-body cutoffs.
  • cutoff_func (Callable) – Cutoff function of the kernel.
Returns:

Value of the many-body force/energy kernel.

Return type:

float

flare.kernels.mc_sephyps.many_body_mc_grad(env1, env2, d1, d2, cutoff_2b, cutoff_3b, cutoff_mb, nspec, spec_mask, nbond, bond_mask, ntriplet, triplet_mask, ncut3b, cut3b_mask, nmb, mb_mask, sig2, ls2, sig3, ls3, sigm, lsm, cutoff_func=<function quadratic_cutoff>)

manybody multi-element kernel between two force components and its gradient with respect to the hyperparameters.

Parameters:
  • env1 (AtomicEnvironment) – First local environment.
  • env2 (AtomicEnvironment) – Second local environment.
  • d1 (int) – Force component of the first environment.
  • d2 (int) – Force component of the second environment.
  • cutoff_2b – dummy
  • cutoff_3b – dummy
  • cutoff_mb (float, np.ndarray) – cutoff(s) for coordination-based manybody interaction
  • nspec (int) – number of different species groups
  • spec_mask (np.ndarray) – 118-long integer array that determines specie group
  • nbond – dummy
  • bond_mask – dummy
  • ntriplet – dummy
  • triplet_mask – dummy
  • ncut3b – dummy
  • cut3b_mask – dummy
  • nmb (int) – number of different hyperparameter sets to associate with manybody pairings
  • mb_mask (np.ndarray) – nspec^2 long integer array
  • sig2 – dummy
  • ls2 – dummy
  • sig3 – dummy
  • ls3 – dummy
  • sigm (np.ndarray) – signal variances associates with manybody term
  • lsm (np.ndarray) – length scales associates with manybody term
  • cutoff_func (Callable) – Cutoff function of the kernel.
Returns:

Value of the 2+3+manybody kernel and its gradient with respect to the hyperparameters.

Return type:

(float, np.ndarray)

flare.kernels.mc_sephyps.three_body_mc(env1, env2, d1, d2, cutoff_2b, cutoff_3b, cutoff_mb, nspec, spec_mask, nbond, bond_mask, ntriplet, triplet_mask, ncut3b, cut3b_mask, nmb, mb_mask, sig2, ls2, sig3, ls3, sigm, lsm, cutoff_func=<function quadratic_cutoff>)

3-body multi-element kernel between two force components.

Parameters:
  • env1 (AtomicEnvironment) – First local environment.
  • env2 (AtomicEnvironment) – Second local environment.
  • d1 (int) – Force component of the first environment.
  • d2 (int) – Force component of the second environment.
  • cutoff_2b – dummy
  • cutoff_3b (float, np.ndarray) – cutoff(s) for three-body interaction
  • nspec (int) – number of different species groups
  • spec_mask (np.ndarray) – 118-long integer array that determines specie group
  • nbond – dummy
  • bond_mask – dummy
  • ntriplet (int) – number of different hyperparameter sets to associate with 3-body pairings
  • triplet_mask (np.ndarray) – nspec^3 long integer array
  • ncut3b (int) – number of different 3-body cutoff sets to associate with 3-body pairings
  • cut3b_mask (np.ndarray) – nspec^2 long integer array
  • sig2 – dummy
  • ls2 – dummy
  • sig3 (np.ndarray) – signal variances associates with three-body term
  • ls3 (np.ndarray) – length scales associates with three-body term
  • cutoff_func (Callable) – Cutoff function of the kernel.
Returns:

Value of the 2+3-body force/force kernel.

Return type:

float

flare.kernels.mc_sephyps.three_body_mc_en(env1, env2, cutoff_2b, cutoff_3b, cutoff_mb, nspec, spec_mask, nbond, bond_mask, ntriplet, triplet_mask, ncut3b, cut3b_mask, nmb, mb_mask, sig2, ls2, sig3, ls3, sigm, lsm, cutoff_func=<function quadratic_cutoff>)

3-body multi-element kernel between two local energies

Parameters:
  • env1 (AtomicEnvironment) – First local environment.
  • env2 (AtomicEnvironment) – Second local environment.
  • d1 (int) – Force component of the first environment.
  • d2 (int) – Force component of the second environment.
  • cutoff_2b – dummy
  • cutoff_3b (float, np.ndarray) – cutoff(s) for three-body interaction
  • nspec (int) – number of different species groups
  • spec_mask (np.ndarray) – 118-long integer array that determines specie group
  • nbond – dummy
  • bond_mask – dummy
  • ntriplet (int) – number of different hyperparameter sets to associate with 3-body pairings
  • triplet_mask (np.ndarray) – nspec^3 long integer array
  • ncut3b (int) – number of different 3-body cutoff sets to associate with 3-body pairings
  • cut3b_mask (np.ndarray) – nspec^2 long integer array
  • sig2 – dummy
  • ls2 – dummy
  • sig3 (np.ndarray) – signal variances associates with three-body term
  • ls3 (np.ndarray) – length scales associates with three-body term
  • cutoff_func (Callable) – Cutoff function of the kernel.
Returns:

Value of the 2+3-body energy/energy kernel.

Return type:

float

flare.kernels.mc_sephyps.three_body_mc_force_en(env1, env2, d1, cutoff_2b, cutoff_3b, cutoff_mb, nspec, spec_mask, nbond, bond_mask, ntriplet, triplet_mask, ncut3b, cut3b_mask, nmb, mb_mask, sig2, ls2, sig3, ls3, sigm, lsm, cutoff_func=<function quadratic_cutoff>)

3-body multi-element kernel between a force component and local energies

Parameters:
  • env1 (AtomicEnvironment) – First local environment.
  • env2 (AtomicEnvironment) – Second local environment.
  • d1 (int) – Force component of the first environment.
  • d2 (int) – Force component of the second environment.
  • cutoff_2b – dummy
  • cutoff_3b (float, np.ndarray) – cutoff(s) for three-body interaction
  • nspec (int) – number of different species groups
  • spec_mask (np.ndarray) – 118-long integer array that determines specie group
  • nbond – dummy
  • bond_mask – dummy
  • ntriplet (int) – number of different hyperparameter sets to associate with 3-body pairings
  • triplet_mask (np.ndarray) – nspec^3 long integer array
  • ncut3b (int) – number of different 3-body cutoff sets to associate with 3-body pairings
  • cut3b_mask (np.ndarray) – nspec^2 long integer array
  • sig2 – dummy
  • ls2 – dummy
  • sig3 (np.ndarray) – signal variances associates with three-body term
  • ls3 (np.ndarray) – length scales associates with three-body term
  • cutoff_func (Callable) – Cutoff function of the kernel.
Returns:

Value of the 2+3-body force/energy kernel.

Return type:

float

flare.kernels.mc_sephyps.three_body_mc_force_en_jit(bond_array_1, c1, etypes1, bond_array_2, c2, etypes2, cross_bond_inds_1, cross_bond_inds_2, cross_bond_dists_1, cross_bond_dists_2, triplets_1, triplets_2, d1, sig, ls, r_cut, cutoff_func, nspec, spec_mask, triplet_mask, cut3b_mask)

Kernel for 3-body force/energy comparisons.

flare.kernels.mc_sephyps.three_body_mc_grad(env1, env2, d1, d2, cutoff_2b, cutoff_3b, cutoff_mb, nspec, spec_mask, nbond, bond_mask, ntriplet, triplet_mask, ncut3b, cut3b_mask, nmb, mb_mask, sig2, ls2, sig3, ls3, sigm, lsm, cutoff_func=<function quadratic_cutoff>)

3-body multi-element kernel between two force components and its gradient with respect to the hyperparameters.

Parameters:
  • env1 (AtomicEnvironment) – First local environment.
  • env2 (AtomicEnvironment) – Second local environment.
  • d1 (int) – Force component of the first environment.
  • d2 (int) – Force component of the second environment.
  • cutoff_2b – dummy
  • cutoff_3b (float, np.ndarray) – cutoff(s) for three-body interaction
  • nspec (int) – number of different species groups
  • spec_mask (np.ndarray) – 118-long integer array that determines specie group
  • nbond – dummy
  • bond_mask – dummy
  • ntriplet (int) – number of different hyperparameter sets to associate with 3-body pairings
  • triplet_mask (np.ndarray) – nspec^3 long integer array
  • ncut3b (int) – number of different 3-body cutoff sets to associate with 3-body pairings
  • cut3b_mask (np.ndarray) – nspec^2 long integer array
  • sig2 – dummy
  • ls2 – dummy
  • sig3 (np.ndarray) – signal variances associates with three-body term
  • ls3 (np.ndarray) – length scales associates with three-body term
  • cutoff_func (Callable) – Cutoff function of the kernel.
Returns:

Value of the 2+3+manybody kernel and its gradient with respect to the hyperparameters.

Return type:

(float, np.ndarray)

flare.kernels.mc_sephyps.three_body_mc_grad_jit(bond_array_1, c1, etypes1, bond_array_2, c2, etypes2, cross_bond_inds_1, cross_bond_inds_2, cross_bond_dists_1, cross_bond_dists_2, triplets_1, triplets_2, d1, d2, sig, ls, r_cut, cutoff_func, nspec, spec_mask, ntriplet, triplet_mask, cut3b_mask)

Kernel gradient for 3-body force comparisons.

flare.kernels.mc_sephyps.two_body_mc(env1, env2, d1, d2, cutoff_2b, cutoff_3b, cutoff_mb, nspec, spec_mask, nbond, bond_mask, ntriplet, triplet_mask, ncut3b, cut3b_mask, nmb, mb_mask, sig2, ls2, sig3, ls3, sigm, lsm, cutoff_func=<function quadratic_cutoff>)

2-body multi-element kernel between two force components.

Parameters:
  • env1 (AtomicEnvironment) – First local environment.
  • env2 (AtomicEnvironment) – Second local environment.
  • d1 (int) – Force component of the first environment.
  • d2 (int) – Force component of the second environment.
  • cutoff_2b (float, np.ndarray) – cutoff(s) for two-body interaction
  • cutoff_3b – dummy
  • nspec (int) – number of different species groups
  • spec_mask (np.ndarray) – 118-long integer array that determines specie group
  • nbond (int) – number of different hyperparameter sets to associate with two-body pairings
  • bond_mask (np.ndarray) – nspec^2 long integer array
  • ntriplet – dummy
  • triplet_mask – dummy
  • ncut3b – dummy
  • cut3b_mask – dummy
  • sig2 – dummy
  • ls2 – dummy
  • sig3 – dummy
  • ls3 – dummy
  • cutoff_func (Callable) – Cutoff function of the kernel.
Returns:

Value of the 2-body force/force kernel.

Return type:

float

flare.kernels.mc_sephyps.two_body_mc_en(env1, env2, cutoff_2b, cutoff_3b, cutoff_mb, nspec, spec_mask, nbond, bond_mask, ntriplet, triplet_mask, ncut3b, cut3b_mask, nmb, mb_mask, sig2, ls2, sig3, ls3, sigm, lsm, cutoff_func=<function quadratic_cutoff>)

2-body multi-element kernel between two local energies

Parameters:
  • env1 (AtomicEnvironment) – First local environment.
  • env2 (AtomicEnvironment) – Second local environment.
  • d1 (int) – Force component of the first environment.
  • d2 (int) – Force component of the second environment.
  • cutoff_2b (float, np.ndarray) – cutoff(s) for two-body interaction
  • cutoff_3b – dummy
  • nspec (int) – number of different species groups
  • spec_mask (np.ndarray) – 118-long integer array that determines specie group
  • nbond (int) – number of different hyperparameter sets to associate with two-body pairings
  • bond_mask (np.ndarray) – nspec^2 long integer array
  • ntriplet – dummy
  • triplet_mask – dummy
  • ncut3b – dummy
  • cut3b_mask – dummy
  • sig2 – dummy
  • ls2 – dummy
  • sig3 – dummy
  • ls3 – dummy
  • cutoff_func (Callable) – Cutoff function of the kernel.
Returns:

Value of the 2-body energy/energy kernel.

Return type:

float

flare.kernels.mc_sephyps.two_body_mc_en_jit(bond_array_1, c1, etypes1, bond_array_2, c2, etypes2, sig, ls, r_cut, cutoff_func, nspec, spec_mask, bond_mask)

Multicomponent two-body energy/energy kernel accelerated with Numba’s njit decorator.

flare.kernels.mc_sephyps.two_body_mc_force_en(env1, env2, d1, cutoff_2b, cutoff_3b, cutoff_mb, nspec, spec_mask, nbond, bond_mask, ntriplet, triplet_mask, ncut3b, cut3b_mask, nmb, mb_mask, sig2, ls2, sig3, ls3, sigm, lsm, cutoff_func=<function quadratic_cutoff>)

2-body multi-element kernel between a force components and local energy

Parameters:
  • env1 (AtomicEnvironment) – First local environment.
  • env2 (AtomicEnvironment) – Second local environment.
  • d1 (int) – Force component of the first environment.
  • d2 (int) – Force component of the second environment.
  • cutoff_2b (float, np.ndarray) – cutoff(s) for two-body interaction
  • cutoff_3b – dummy
  • nspec (int) – number of different species groups
  • spec_mask (np.ndarray) – 118-long integer array that determines specie group
  • nbond (int) – number of different hyperparameter sets to associate with two-body pairings
  • bond_mask (np.ndarray) – nspec^2 long integer array
  • ntriplet – dummy
  • triplet_mask – dummy
  • ncut3b – dummy
  • cut3b_mask – dummy
  • sig2 – dummy
  • ls2 – dummy
  • sig3 – dummy
  • ls3 – dummy
  • cutoff_func (Callable) – Cutoff function of the kernel.
Returns:

Value of the 2-body force/energy kernel.

Return type:

float

flare.kernels.mc_sephyps.two_body_mc_force_en_jit(bond_array_1, c1, etypes1, bond_array_2, c2, etypes2, d1, sig, ls, r_cut, cutoff_func, nspec, spec_mask, bond_mask)

Multicomponent two-body force/energy kernel accelerated with Numba’s njit decorator.

flare.kernels.mc_sephyps.two_body_mc_grad(env1, env2, d1, d2, cutoff_2b, cutoff_3b, cutoff_mb, nspec, spec_mask, nbond, bond_mask, ntriplet, triplet_mask, ncut3b, cut3b_mask, nmb, mb_mask, sig2, ls2, sig3, ls3, sigm, lsm, cutoff_func=<function quadratic_cutoff>)

2-body multi-element kernel between two force components and its gradient with respect to the hyperparameters.

Parameters:
  • env1 (AtomicEnvironment) – First local environment.
  • env2 (AtomicEnvironment) – Second local environment.
  • d1 (int) – Force component of the first environment.
  • d2 (int) – Force component of the second environment.
  • cutoff_2b (float, np.ndarray) – cutoff(s) for two-body interaction
  • cutoff_3b – dummy
  • nspec (int) – number of different species groups
  • spec_mask (np.ndarray) – 118-long integer array that determines specie group
  • nbond (int) – number of different hyperparameter sets to associate with two-body pairings
  • bond_mask (np.ndarray) – nspec^2 long integer array
  • ntriplet – dummy
  • triplet_mask – dummy
  • ncut3b – dummy
  • cut3b_mask – dummy
  • sig2 (np.ndarray) – signal variances associates with two-body term
  • ls2 (np.ndarray) – length scales associates with two-body term
  • sig3 – dummy
  • ls3 – dummy
  • cutoff_func (Callable) – Cutoff function of the kernel.
Returns:

Value of the 2-body kernel and its gradient with respect to the hyperparameters.

Return type:

(float, np.ndarray)

flare.kernels.mc_sephyps.two_body_mc_grad_jit(bond_array_1, c1, etypes1, bond_array_2, c2, etypes2, d1, d2, sig, ls, r_cut, cutoff_func, nspec, spec_mask, nbond, bond_mask)

Multicomponent two-body force/force kernel gradient accelerated with Numba’s njit decorator.

flare.kernels.mc_sephyps.two_body_mc_jit(bond_array_1, c1, etypes1, bond_array_2, c2, etypes2, d1, d2, sig, ls, r_cut, cutoff_func, nspec, spec_mask, bond_mask)

Multicomponent two-body force/force kernel accelerated with Numba’s njit decorator. Loops over bonds in two environments and adds to the kernel if bonds are of the same type.

flare.kernels.mc_sephyps.two_plus_three_body_mc(env1, env2, d1, d2, cutoff_2b, cutoff_3b, cutoff_mb, nspec, spec_mask, nbond, bond_mask, ntriplet, triplet_mask, ncut3b, cut3b_mask, nmb, mb_mask, sig2, ls2, sig3, ls3, sigm, lsm, cutoff_func=<function quadratic_cutoff>)

2+3-body multi-element kernel between two force components.

Parameters:
  • env1 (AtomicEnvironment) – First local environment.
  • env2 (AtomicEnvironment) – Second local environment.
  • d1 (int) – Force component of the first environment.
  • d2 (int) – Force component of the second environment.
  • cutoff_2b (float, np.ndarray) – cutoff(s) for two-body interaction
  • cutoff_3b (float, np.ndarray) – cutoff(s) for three-body interaction
  • cutoff_mb (float, np.ndarray) – cutoff(s) for coordination-based manybody interaction
  • nspec (int) – number of different species groups
  • spec_mask (np.ndarray) – 118-long integer array that determines specie group
  • nbond (int) – number of different hyperparameter sets to associate with two-body pairings
  • bond_mask (np.ndarray) – nspec^2 long integer array
  • ntriplet (int) – number of different hyperparameter sets to associate with 3-body pairings
  • triplet_mask (np.ndarray) – nspec^3 long integer array
  • ncut3b (int) – number of different 3-body cutoff sets to associate with 3-body pairings
  • cut3b_mask (np.ndarray) – nspec^2 long integer array
  • sig2 (np.ndarray) – signal variances associates with two-body term
  • ls2 (np.ndarray) – length scales associates with two-body term
  • sig3 (np.ndarray) – signal variances associates with three-body term
  • ls3 (np.ndarray) – length scales associates with three-body term
  • cutoff_func (Callable) – Cutoff function of the kernel.
Returns:

Value of the 2+3-body force/force kernel.

Return type:

float

flare.kernels.mc_sephyps.two_plus_three_body_mc_grad(env1, env2, d1, d2, cutoff_2b, cutoff_3b, cutoff_mb, nspec, spec_mask, nbond, bond_mask, ntriplet, triplet_mask, ncut3b, cut3b_mask, nmb, mb_mask, sig2, ls2, sig3, ls3, sigm, lsm, cutoff_func=<function quadratic_cutoff>)

2+3-body multi-element kernel between two force components and its gradient with respect to the hyperparameters.

Parameters:
  • env1 (AtomicEnvironment) – First local environment.
  • env2 (AtomicEnvironment) – Second local environment.
  • d1 (int) – Force component of the first environment.
  • d2 (int) – Force component of the second environment.
  • cutoff_2b (float, np.ndarray) – cutoff(s) for two-body interaction
  • cutoff_3b (float, np.ndarray) – cutoff(s) for three-body interaction
  • nspec (int) – number of different species groups
  • spec_mask (np.ndarray) – 118-long integer array that determines specie group
  • nbond (int) – number of different hyperparameter sets to associate with two-body pairings
  • bond_mask (np.ndarray) – nspec^2 long integer array
  • ntriplet (int) – number of different hyperparameter sets to associate with 3-body pairings
  • triplet_mask (np.ndarray) – nspec^3 long integer array
  • ncut3b (int) – number of different 3-body cutoff sets to associate with 3-body pairings
  • cut3b_mask (np.ndarray) – nspec^2 long integer array
  • sig2 (np.ndarray) – signal variances associates with two-body term
  • ls2 (np.ndarray) – length scales associates with two-body term
  • sig3 (np.ndarray) – signal variances associates with three-body term
  • ls3 (np.ndarray) – length scales associates with three-body term
  • cutoff_func (Callable) – Cutoff function of the kernel.
Returns:

Value of the 2+3-body kernel and its gradient with respect to the hyperparameters.

Return type:

(float, np.ndarray)

flare.kernels.mc_sephyps.two_plus_three_mc_en(env1, env2, cutoff_2b, cutoff_3b, cutoff_mb, nspec, spec_mask, nbond, bond_mask, ntriplet, triplet_mask, ncut3b, cut3b_mask, nmb, mb_mask, sig2, ls2, sig3, ls3, sigm, lsm, cutoff_func=<function quadratic_cutoff>)

2+3-body multi-element kernel between two local energies

Parameters:
  • env1 (AtomicEnvironment) – First local environment.
  • env2 (AtomicEnvironment) – Second local environment.
  • d1 (int) – Force component of the first environment.
  • d2 (int) – Force component of the second environment.
  • cutoff_2b (float, np.ndarray) – cutoff(s) for two-body interaction
  • cutoff_3b (float, np.ndarray) – cutoff(s) for three-body interaction
  • cutoff_mb (float, np.ndarray) – cutoff(s) for coordination-based manybody interaction
  • nspec (int) – number of different species groups
  • spec_mask (np.ndarray) – 118-long integer array that determines specie group
  • nbond (int) – number of different hyperparameter sets to associate with two-body pairings
  • bond_mask (np.ndarray) – nspec^2 long integer array
  • ntriplet (int) – number of different hyperparameter sets to associate with 3-body pairings
  • triplet_mask (np.ndarray) – nspec^3 long integer array
  • ncut3b (int) – number of different 3-body cutoff sets to associate with 3-body pairings
  • cut3b_mask (np.ndarray) – nspec^2 long integer array
  • sig2 (np.ndarray) – signal variances associates with two-body term
  • ls2 (np.ndarray) – length scales associates with two-body term
  • sig3 (np.ndarray) – signal variances associates with three-body term
  • ls3 (np.ndarray) – length scales associates with three-body term
  • cutoff_func (Callable) – Cutoff function of the kernel.
Returns:

Value of the 2+3-body energy/energy kernel.

Return type:

float

flare.kernels.mc_sephyps.two_plus_three_mc_force_en(env1, env2, d1, cutoff_2b, cutoff_3b, cutoff_mb, nspec, spec_mask, nbond, bond_mask, ntriplet, triplet_mask, ncut3b, cut3b_mask, nmb, mb_mask, sig2, ls2, sig3, ls3, sigm, lsm, cutoff_func=<function quadratic_cutoff>)

2+3-body multi-element kernel between force and local energy

Parameters:
  • env1 (AtomicEnvironment) – First local environment.
  • env2 (AtomicEnvironment) – Second local environment.
  • d1 (int) – Force component of the first environment.
  • d2 (int) – Force component of the second environment.
  • cutoff_2b (float, np.ndarray) – cutoff(s) for two-body interaction
  • cutoff_3b (float, np.ndarray) – cutoff(s) for three-body interaction
  • cutoff_mb (float, np.ndarray) – cutoff(s) for coordination-based manybody interaction
  • nspec (int) – number of different species groups
  • spec_mask (np.ndarray) – 118-long integer array that determines specie group
  • nbond (int) – number of different hyperparameter sets to associate with two-body pairings
  • bond_mask (np.ndarray) – nspec^2 long integer array
  • ntriplet (int) – number of different hyperparameter sets to associate with 3-body pairings
  • triplet_mask (np.ndarray) – nspec^3 long integer array
  • ncut3b (int) – number of different 3-body cutoff sets to associate with 3-body pairings
  • cut3b_mask (np.ndarray) – nspec^2 long integer array
  • sig2 (np.ndarray) – signal variances associates with two-body term
  • ls2 (np.ndarray) – length scales associates with two-body term
  • sig3 (np.ndarray) – signal variances associates with three-body term
  • ls3 (np.ndarray) – length scales associates with three-body term
  • cutoff_func (Callable) – Cutoff function of the kernel.
Returns:

Value of the 2+3-body force/energy kernel.

Return type:

float

flare.kernels.mc_sephyps.two_three_many_body_mc(env1, env2, d1, d2, cutoff_2b, cutoff_3b, cutoff_mb, nspec, spec_mask, nbond, bond_mask, ntriplet, triplet_mask, ncut3b, cut3b_mask, nmb, mb_mask, sig2, ls2, sig3, ls3, sigm, lsm, cutoff_func=<function quadratic_cutoff>)

2+3+manybody multi-element kernel between two force components.

Parameters:
  • env1 (AtomicEnvironment) – First local environment.
  • env2 (AtomicEnvironment) – Second local environment.
  • d1 (int) – Force component of the first environment.
  • d2 (int) – Force component of the second environment.
  • cutoff_2b (float, np.ndarray) – cutoff(s) for two-body interaction
  • cutoff_3b (float, np.ndarray) – cutoff(s) for three-body interaction
  • cutoff_mb (float, np.ndarray) – cutoff(s) for coordination-based manybody interaction
  • nspec (int) – number of different species groups
  • spec_mask (np.ndarray) – 118-long integer array that determines specie group
  • nbond (int) – number of different hyperparameter sets to associate with two-body pairings
  • bond_mask (np.ndarray) – nspec^2 long integer array
  • ntriplet (int) – number of different hyperparameter sets to associate with 3-body pairings
  • triplet_mask (np.ndarray) – nspec^3 long integer array
  • ncut3b (int) – number of different 3-body cutoff sets to associate with 3-body pairings
  • cut3b_mask (np.ndarray) – nspec^2 long integer array
  • nmb (int) – number of different hyperparameter sets to associate with manybody pairings
  • mb_mask (np.ndarray) – nspec^2 long integer array
  • sig2 (np.ndarray) – signal variances associates with two-body term
  • ls2 (np.ndarray) – length scales associates with two-body term
  • sig3 (np.ndarray) – signal variances associates with three-body term
  • ls3 (np.ndarray) – length scales associates with three-body term
  • sigm (np.ndarray) – signal variances associates with manybody term
  • lsm (np.ndarray) – length scales associates with manybody term
  • cutoff_func (Callable) – Cutoff function of the kernel.
Returns:

Value of the 2+3+many-body kernel.

Return type:

float

flare.kernels.mc_sephyps.two_three_many_body_mc_grad(env1, env2, d1, d2, cutoff_2b, cutoff_3b, cutoff_mb, nspec, spec_mask, nbond, bond_mask, ntriplet, triplet_mask, ncut3b, cut3b_mask, nmb, mb_mask, sig2, ls2, sig3, ls3, sigm, lsm, cutoff_func=<function quadratic_cutoff>)

2+3+manybody multi-element kernel between two force components and its gradient with respect to the hyperparameters.

Parameters:
  • env1 (AtomicEnvironment) – First local environment.
  • env2 (AtomicEnvironment) – Second local environment.
  • d1 (int) – Force component of the first environment.
  • d2 (int) – Force component of the second environment.
  • cutoff_2b (float, np.ndarray) – cutoff(s) for two-body interaction
  • cutoff_3b (float, np.ndarray) – cutoff(s) for three-body interaction
  • cutoff_mb (float, np.ndarray) – cutoff(s) for coordination-based manybody interaction
  • nspec (int) – number of different species groups
  • spec_mask (np.ndarray) – 118-long integer array that determines specie group
  • nbond (int) – number of different hyperparameter sets to associate with two-body pairings
  • bond_mask (np.ndarray) – nspec^2 long integer array
  • ntriplet (int) – number of different hyperparameter sets to associate with 3-body pairings
  • triplet_mask (np.ndarray) – nspec^3 long integer array
  • ncut3b (int) – number of different 3-body cutoff sets to associate with 3-body pairings
  • cut3b_mask (np.ndarray) – nspec^2 long integer array
  • nmb (int) – number of different hyperparameter sets to associate with manybody pairings
  • mb_mask (np.ndarray) – nspec^2 long integer array
  • sig2 (np.ndarray) – signal variances associates with two-body term
  • ls2 (np.ndarray) – length scales associates with two-body term
  • sig3 (np.ndarray) – signal variances associates with three-body term
  • ls3 (np.ndarray) – length scales associates with three-body term
  • sigm (np.ndarray) – signal variances associates with manybody term
  • lsm (np.ndarray) – length scales associates with manybody term
  • cutoff_func (Callable) – Cutoff function of the kernel.
Returns:

Value of the 2+3+manybody kernel and its gradient with respect to the hyperparameters.

Return type:

(float, np.ndarray)

flare.kernels.mc_sephyps.two_three_many_mc_en(env1, env2, cutoff_2b, cutoff_3b, cutoff_mb, nspec, spec_mask, nbond, bond_mask, ntriplet, triplet_mask, ncut3b, cut3b_mask, nmb, mb_mask, sig2, ls2, sig3, ls3, sigm, lsm, cutoff_func=<function quadratic_cutoff>)

2+3+many-body multi-element kernel between two local energies.

Parameters:
  • env1 (AtomicEnvironment) – First local environment.
  • env2 (AtomicEnvironment) – Second local environment.
  • d1 (int) – Force component of the first environment.
  • d2 (int) – Force component of the second environment.
  • cutoff_2b (float, np.ndarray) – cutoff(s) for two-body interaction
  • cutoff_3b (float, np.ndarray) – cutoff(s) for three-body interaction
  • cutoff_mb (float, np.ndarray) – cutoff(s) for coordination-based manybody interaction
  • nspec (int) – number of different species groups
  • spec_mask (np.ndarray) – 118-long integer array that determines specie group
  • nbond (int) – number of different hyperparameter sets to associate with two-body pairings
  • bond_mask (np.ndarray) – nspec^2 long integer array
  • ntriplet (int) – number of different hyperparameter sets to associate with 3-body pairings
  • triplet_mask (np.ndarray) – nspec^3 long integer array
  • ncut3b (int) – number of different 3-body cutoff sets to associate with 3-body pairings
  • cut3b_mask (np.ndarray) – nspec^2 long integer array
  • nmb (int) – number of different hyperparameter sets to associate with manybody pairings
  • mb_mask (np.ndarray) – nspec^2 long integer array
  • sig2 (np.ndarray) – signal variances associates with two-body term
  • ls2 (np.ndarray) – length scales associates with two-body term
  • sig3 (np.ndarray) – signal variances associates with three-body term
  • ls3 (np.ndarray) – length scales associates with three-body term
  • sigm (np.ndarray) – signal variances associates with manybody term
  • lsm (np.ndarray) – length scales associates with manybody term
  • cutoff_func (Callable) – Cutoff function of the kernel.
Returns:

Value of the 2+3+many-body energy/energy kernel.

Return type:

float

flare.kernels.mc_sephyps.two_three_many_mc_force_en(env1, env2, d1, cutoff_2b, cutoff_3b, cutoff_mb, nspec, spec_mask, nbond, bond_mask, ntriplet, triplet_mask, ncut3b, cut3b_mask, nmb, mb_mask, sig2, ls2, sig3, ls3, sigm, lsm, cutoff_func=<function quadratic_cutoff>)

2+3+manybody multi-element kernel between a force component and a local energy.

Parameters:
  • env1 (AtomicEnvironment) – First local environment.
  • env2 (AtomicEnvironment) – Second local environment.
  • d1 (int) – Force component of the first environment.
  • d2 (int) – Force component of the second environment.
  • cutoff_2b (float, np.ndarray) – cutoff(s) for two-body interaction
  • cutoff_3b (float, np.ndarray) – cutoff(s) for three-body interaction
  • cutoff_mb (float, np.ndarray) – cutoff(s) for coordination-based manybody interaction
  • nspec (int) – number of different species groups
  • spec_mask (np.ndarray) – 118-long integer array that determines specie group
  • nbond (int) – number of different hyperparameter sets to associate with two-body pairings
  • bond_mask (np.ndarray) – nspec^2 long integer array
  • ntriplet (int) – number of different hyperparameter sets to associate with 3-body pairings
  • triplet_mask (np.ndarray) – nspec^3 long integer array
  • ncut3b (int) – number of different 3-body cutoff sets to associate with 3-body pairings
  • cut3b_mask (np.ndarray) – nspec^2 long integer array
  • nmb (int) – number of different hyperparameter sets to associate with manybody pairings
  • mb_mask (np.ndarray) – nspec^2 long integer array
  • sig2 (np.ndarray) – signal variances associates with two-body term
  • ls2 (np.ndarray) – length scales associates with two-body term
  • sig3 (np.ndarray) – signal variances associates with three-body term
  • ls3 (np.ndarray) – length scales associates with three-body term
  • sigm (np.ndarray) – signal variances associates with manybody term
  • lsm (np.ndarray) – length scales associates with manybody term
  • cutoff_func (Callable) – Cutoff function of the kernel.
Returns:

Value of the 2+3+many-body force/energy kernel.

Return type:

float

Implementation of three-body kernels using different cutoffs.

The kernels are slightly slower.

flare.kernels.mc_3b_sepcut.three_body_mc_force_en_sepcut_jit(bond_array_1, c1, etypes1, bond_array_2, c2, etypes2, cross_bond_inds_1, cross_bond_inds_2, cross_bond_dists_1, cross_bond_dists_2, triplets_1, triplets_2, d1, sig, ls, r_cut, cutoff_func, nspec, spec_mask, triplet_mask, cut3b_mask)

Kernel for 3-body force/energy comparisons.

flare.kernels.mc_3b_sepcut.three_body_mc_grad_sepcut_jit(bond_array_1, c1, etypes1, bond_array_2, c2, etypes2, cross_bond_inds_1, cross_bond_inds_2, cross_bond_dists_1, cross_bond_dists_2, triplets_1, triplets_2, d1, d2, sig, ls, r_cut, cutoff_func, nspec, spec_mask, ntriplet, triplet_mask, cut3b_mask)

Kernel gradient for 3-body force comparisons.

Implementation of three-body kernels using different cutoffs.

The kernels are slightly slower.

flare.kernels.mc_mb_sepcut.many_body_mc_en_sepcut_jit(q_array_1, q_array_2, c1, c2, species1, species2, sig, ls, nspec, spec_mask, mb_mask)

many-body many-element kernel between energy components accelerated with Numba.

Parameters:
  • bond_array_1 (np.ndarray) – many-body bond array of the first local environment.
  • bond_array_2 (np.ndarray) – many-body bond array of the second local environment.
  • c1 (int) – atomic species of the central atom in env 1
  • c2 (int) – atomic species of the central atom in env 2
  • etypes1 (np.ndarray) – atomic species of atoms in env 1
  • etypes2 (np.ndarray) – atomic species of atoms in env 2
  • species1 (np.ndarray) – all the atomic species present in trajectory 1
  • species2 (np.ndarray) – all the atomic species present in trajectory 2
  • sig (float) – many-body signal variance hyperparameter.
  • ls (float) – many-body length scale hyperparameter.
  • r_cut (float) – many-body cutoff radius.
  • cutoff_func (Callable) – Cutoff function.
Returns:

Value of the many-body kernel.

Return type:

float

flare.kernels.mc_mb_sepcut.many_body_mc_force_en_sepcut_jit(q_array_1, q_array_2, q_neigh_array_1, q_neigh_grads_1, c1, c2, etypes1, species1, species2, d1, sig, ls, nspec, spec_mask, mb_mask)

many-body many-element kernel between force and energy components accelerated with Numba.

Parameters:
  • To be complete
  • c1 (int) – atomic species of the central atom in env 1
  • c2 (int) – atomic species of the central atom in env 2
  • etypes1 (np.ndarray) – atomic species of atoms in env 1
  • species1 (np.ndarray) – all the atomic species present in trajectory 1
  • species2 (np.ndarray) – all the atomic species present in trajectory 2
  • d1 (int) – Force component of the first environment.
  • sig (float) – many-body signal variance hyperparameter.
  • ls (float) – many-body length scale hyperparameter.
Returns:

Value of the many-body kernel.

Return type:

float

flare.kernels.mc_mb_sepcut.many_body_mc_grad_sepcut_jit(q_array_1, q_array_2, q_neigh_array_1, q_neigh_array_2, q_neigh_grads_1, q_neigh_grads_2, c1, c2, etypes1, etypes2, species1, species2, d1, d2, sig, ls, nspec, spec_mask, nmb, mb_mask)

gradient of many-body multi-element kernel between two force components w.r.t. the hyperparameters, accelerated with Numba.

Parameters:
  • c1 (int) – atomic species of the central atom in env 1
  • c2 (int) – atomic species of the central atom in env 2
  • etypes1 (np.ndarray) – atomic species of atoms in env 1
  • etypes2 (np.ndarray) – atomic species of atoms in env 2
  • species1 (np.ndarray) – all the atomic species present in trajectory 1
  • species2 (np.ndarray) – all the atomic species present in trajectory 2
  • d1 (int) – Force component of the first environment.
  • d2 (int) – Force component of the second environment.
  • sig (float) – many-body signal variance hyperparameter.
  • ls (float) – many-body length scale hyperparameter.
Returns:

Value of the many-body kernel and its gradient w.r.t. sig and ls

Return type:

array

flare.kernels.mc_mb_sepcut.many_body_mc_sepcut_jit(q_array_1, q_array_2, q_neigh_array_1, q_neigh_array_2, q_neigh_grads_1, q_neigh_grads_2, c1, c2, etypes1, etypes2, species1, species2, d1, d2, sig, ls, nspec, spec_mask, mb_mask)

many-body multi-element kernel between two force components accelerated with Numba.

Parameters:
  • c1 (int) – atomic species of the central atom in env 1
  • c2 (int) – atomic species of the central atom in env 2
  • etypes1 (np.ndarray) – atomic species of atoms in env 1
  • etypes2 (np.ndarray) – atomic species of atoms in env 2
  • species1 (np.ndarray) – all the atomic species present in trajectory 1
  • species2 (np.ndarray) – all the atomic species present in trajectory 2
  • d1 (int) – Force component of the first environment.
  • d2 (int) – Force component of the second environment.
  • sig (float) – many-body signal variance hyperparameter.
  • ls (float) – many-body length scale hyperparameter.
Returns:

Value of the many-body kernel.

Return type:

float