Repository: pyiron/structuretoolkit (language: python)

Issue:
Merge main



Discussion / hints:

Fix patch:
diff --git a/.ci_support/environment.yml b/.ci_support/environment.yml
index 56509260c..3b1b5a136 100644
--- a/.ci_support/environment.yml
+++ b/.ci_support/environment.yml
@@ -4,6 +4,7 @@ dependencies:
 - aimsgb =1.1.0
 - ase =3.22.1
 - coverage
+- dscribe =2.1.0
 - matplotlib-base =3.8.2
 - nglview =3.1.1
 - notebook
diff --git a/pyproject.toml b/pyproject.toml
index d948c4e84..e2236d253 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -36,6 +36,7 @@ Documentation = "https://github.com/pyiron/structuretoolkit"
 Repository = "https://github.com/pyiron/structuretoolkit"
 
 [project.optional-dependencies]
+dscribe = ["dscribe==2.1.0"]
 grainboundary = [
     "aimsgb==1.1.0",
     "pymatgen==2024.2.8",
diff --git a/structuretoolkit/analyse/__init__.py b/structuretoolkit/analyse/__init__.py
index 34d4a8115..c1835f0a7 100644
--- a/structuretoolkit/analyse/__init__.py
+++ b/structuretoolkit/analyse/__init__.py
@@ -1,6 +1,7 @@
 import numpy as np
 
 from structuretoolkit.analyse.distance import find_mic, get_distances_array
+from structuretoolkit.analyse.dscribe import soap_descriptor_per_atom
 from structuretoolkit.analyse.neighbors import get_neighborhood, get_neighbors
 from structuretoolkit.analyse.phonopy import get_equivalent_atoms
 from structuretoolkit.analyse.pyscal import (
diff --git a/structuretoolkit/analyse/dscribe.py b/structuretoolkit/analyse/dscribe.py
new file mode 100644
index 000000000..f82545353
--- /dev/null
+++ b/structuretoolkit/analyse/dscribe.py
@@ -0,0 +1,44 @@
+def soap_descriptor_per_atom(
+    structure,
+    r_cut=None,
+    n_max=None,
+    l_max=None,
+    sigma=1.0,
+    rbf="gto",
+    weighting=None,
+    average="off",
+    compression={"mode": "off", "species_weighting": None},
+    species=None,
+    periodic=True,
+    sparse=False,
+    dtype="float64",
+    centers=None,
+    n_jobs=1,
+    only_physical_cores=False,
+    verbose=False,
+):
+    from dscribe.descriptors import SOAP
+
+    if species is None:
+        species = list(set(structure.get_chemical_symbols()))
+    periodic_soap = SOAP(
+        r_cut=r_cut,
+        n_max=n_max,
+        l_max=l_max,
+        sigma=sigma,
+        rbf=rbf,
+        weighting=weighting,
+        average=average,
+        compression=compression,
+        species=species,
+        periodic=periodic,
+        sparse=sparse,
+        dtype=dtype,
+    )
+    return periodic_soap.create(
+        system=structure,
+        centers=centers,
+        n_jobs=n_jobs,
+        only_physical_cores=only_physical_cores,
+        verbose=verbose,
+    )


Test patch:
diff --git a/tests/test_dscribe.py b/tests/test_dscribe.py
new file mode 100644
index 000000000..128e2a088
--- /dev/null
+++ b/tests/test_dscribe.py
@@ -0,0 +1,26 @@
+# coding: utf-8
+# Copyright (c) Max-Planck-Institut für Eisenforschung GmbH - Computational Materials Design (CM) Department
+# Distributed under the terms of "New BSD License", see the LICENSE file.
+
+import unittest
+from ase.build import bulk
+import numpy as np
+import structuretoolkit as stk
+
+try:
+    import dscribe
+
+    skip_dscribe_test = False
+except ImportError:
+    skip_dscribe_test = True
+
+
+@unittest.skipIf(
+    skip_dscribe_test, "dscribe is not installed, so the dscribe tests are skipped."
+)
+class Testdscribe(unittest.TestCase):
+    def test_soap_descriptor_per_atom(self):
+        structure = bulk('Cu', 'fcc', a=3.6, cubic=True)
+        soap = stk.analyse.soap_descriptor_per_atom(structure=structure, r_cut=6.0, n_max=8, l_max=6)
+        self.assertEqual(soap.shape, (4, 252))
+        self.assertTrue(np.isclose(soap.sum(), 39450.03009, atol=1.e-5))