From ffe13c502e5c288efdc0515d60cefbabe3e54e2f Mon Sep 17 00:00:00 2001 From: Lenz Fiedler Date: Fri, 15 Nov 2024 11:17:31 +0100 Subject: [PATCH] Bispectrum descriptor calculation for two elements in principle works --- mala/descriptors/bispectrum.py | 17 ++++++++++++++++- .../{in.bgrid.python => in.bgrid_n1.python} | 0 ...id.twoelements.python => in.bgrid_n2.python} | 2 +- 3 files changed, 17 insertions(+), 2 deletions(-) rename mala/descriptors/{in.bgrid.python => in.bgrid_n1.python} (100%) rename mala/descriptors/{in.bgrid.twoelements.python => in.bgrid_n2.python} (96%) diff --git a/mala/descriptors/bispectrum.py b/mala/descriptors/bispectrum.py index 207fac341..691012cff 100755 --- a/mala/descriptors/bispectrum.py +++ b/mala/descriptors/bispectrum.py @@ -137,6 +137,12 @@ def __calculate_lammps(self, outdir, **kwargs): # general LAMMPS import. from lammps import constants as lammps_constants + if len(set(self.atoms.numbers)) > 2: + raise ValueError( + "MALA can only compute bispectrum descriptors for 1- or " + "2-element systems currently." + ) + use_fp64 = kwargs.get("use_fp64", False) keep_logs = kwargs.get("keep_logs", False) @@ -173,7 +179,10 @@ def __calculate_lammps(self, outdir, **kwargs): ) else: self.parameters.lammps_compute_file = os.path.join( - filepath, "in.bgrid.python" + filepath, + "in.bgrid_n{0}.python".format( + len(set(self.atoms.numbers)) + ), ) # Do the LAMMPS calculation and clean up. @@ -279,6 +288,12 @@ def __calculate_python(self, **kwargs): "large systems." ) + if len(set(self.atoms.numbers)) > 1: + raise ValueError( + " MALA cannot compute bispectrum descriptors for " + "multi-element systems with python currently." + ) + # The entire bispectrum calculation may be extensively profiled. profile_calculation = kwargs.get("profile_calculation", False) if profile_calculation: diff --git a/mala/descriptors/in.bgrid.python b/mala/descriptors/in.bgrid_n1.python similarity index 100% rename from mala/descriptors/in.bgrid.python rename to mala/descriptors/in.bgrid_n1.python diff --git a/mala/descriptors/in.bgrid.twoelements.python b/mala/descriptors/in.bgrid_n2.python similarity index 96% rename from mala/descriptors/in.bgrid.twoelements.python rename to mala/descriptors/in.bgrid_n2.python index 941948acd..82d22b7ab 100644 --- a/mala/descriptors/in.bgrid.twoelements.python +++ b/mala/descriptors/in.bgrid_n2.python @@ -43,7 +43,7 @@ compute bgrid all sna/grid grid ${ngridx} ${ngridy} ${ngridz} ${rcutfac} ${rfac0 # is this important? or does it just need to be big enough? -variable rcutneigh equal 2.0*${rcutfac}*${radelem} +variable rcutneigh equal 2.0*${rcutfac}*${radelem1} # for water #variable rcutneigh equal 4.0*${rcutfac}*${radelem1}