diff --git a/mala/common/parameters.py b/mala/common/parameters.py index 1d2ba9d9..1900649c 100644 --- a/mala/common/parameters.py +++ b/mala/common/parameters.py @@ -389,6 +389,7 @@ def __init__(self): self.bispectrum_twojmax = 10 self.bispectrum_cutoff = 4.67637 self.bispectrum_switchflag = 1 + self.bispectrum_element_weights = None # Everything pertaining to the atomic density. # Seperate cutoff given here because bispectrum descriptors and @@ -473,6 +474,30 @@ def bispectrum_switchflag(self, value): if _int_value > 0: self._snap_switchflag = 1 + @property + def bispectrum_element_weights(self): + """ + Element species weights for the bispectrum calculation. + + They are provided as an ordered list, and will be assigned to the + elements alphabetically, i.e., the first entry will go to the element + coming first in the alphabet and so on. Weights are always relative, so + the list will be rescaled such that the largest value is 1 and all + the other ones are scaled accordingly. + """ + return self._bispectrum_element_weights + + @bispectrum_element_weights.setter + def bispectrum_element_weights(self, value): + if not isinstance(value, list) and value is not None: + raise ValueError("Bispectrum element weights must be list.") + if value is not None: + if np.max(value) != 1.0: + max = np.max(value) + for element in range(len(value)): + value[element] /= max + self._bispectrum_element_weights = value + def _update_mpi(self, new_mpi): self._configuration["mpi"] = new_mpi diff --git a/mala/descriptors/bispectrum.py b/mala/descriptors/bispectrum.py index 2dceabf9..3ecc478c 100755 --- a/mala/descriptors/bispectrum.py +++ b/mala/descriptors/bispectrum.py @@ -153,6 +153,18 @@ def __calculate_lammps(self, outdir, **kwargs): nz = self.grid_dimensions[2] # Create LAMMPS instance. + if ( + len(set(self._atoms.numbers)) > 1 + and self.parameters.bispectrum_element_weights is None + ): + self.parameters.bispectrum_element_weights = [1] * len( + set(self._atoms.numbers) + ) + printout( + "Multielement system selected without providing elemental " + "weights. Set weights to: ", + self.parameters.bispectrum_element_weights, + ) lammps_dict = { "twojmax": self.parameters.bispectrum_twojmax, "rcutfac": self.parameters.bispectrum_cutoff,