File: 20_set_potentials_path.patch

package info (click to toggle)
lammps 20250204%2Bdfsg.1-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 474,368 kB
  • sloc: cpp: 1,060,070; python: 27,785; ansic: 8,956; f90: 7,254; sh: 6,044; perl: 4,171; fortran: 2,442; xml: 1,714; makefile: 1,352; objc: 238; lisp: 188; yacc: 58; csh: 16; awk: 14; tcl: 6; javascript: 2
file content (60 lines) | stat: -rw-r--r-- 2,852 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
Description: _set_potentials_path
Index: lammps-4Feb2025/src/ML-IAP/mliap_model_python.cpp
===================================================================
--- lammps-4Feb2025.orig/src/ML-IAP/mliap_model_python.cpp
+++ lammps-4Feb2025/src/ML-IAP/mliap_model_python.cpp
@@ -69,6 +69,8 @@ MLIAPModelPython::MLIAPModelPython(LAMMP
   if (potentials_path != nullptr) {
     PyList_Append(py_path, PY_STRING_FROM_STRING(potentials_path));
   }
+  const char *debian_potentials_path = "/usr/share/lammps/potentials";
+  PyList_Append(py_path, PY_STRING_FROM_STRING(debian_potentials_path));
   PyGILState_Release(gstate);
   if (coefffilename) read_coeffs(coefffilename);
 
Index: lammps-4Feb2025/src/PYTHON/pair_python.cpp
===================================================================
--- lammps-4Feb2025.orig/src/PYTHON/pair_python.cpp
+++ lammps-4Feb2025/src/PYTHON/pair_python.cpp
@@ -63,6 +63,8 @@ PairPython::PairPython(LAMMPS *lmp) : Pa
   if (potentials_path != nullptr) {
     PyList_Append(py_path, PY_STRING_FROM_STRING(potentials_path));
   }
+  const char *debian_potentials_path = "/usr/share/lammps/potentials";
+  PyList_Append(py_path, PY_STRING_FROM_STRING(debian_potentials_path));
 }
 
 /* ---------------------------------------------------------------------- */
Index: lammps-4Feb2025/src/utils.cpp
===================================================================
--- lammps-4Feb2025.orig/src/utils.cpp
+++ lammps-4Feb2025/src/utils.cpp
@@ -1748,6 +1748,10 @@ std::string utils::get_potential_file_pa
       auto filepath = platform::path_join(dir, pot);
       if (platform::file_is_readable(filepath)) return filepath;
     }
+    const auto debian_dir = "/usr/share/lammps/potentials";
+    auto pot = platform::path_basename(path);
+    auto filepath = platform::path_join(debian_dir, pot);
+    if (platform::file_is_readable(filepath)) return filepath;
   }
   return "";
 }
Index: lammps-4Feb2025/unittest/utils/test_utils.cpp
===================================================================
--- lammps-4Feb2025.orig/unittest/utils/test_utils.cpp
+++ lammps-4Feb2025/unittest/utils/test_utils.cpp
@@ -1053,6 +1053,13 @@ TEST(Utils, potential_file)
         EXPECT_THAT(utils::get_potential_units(path, "EAM"), Eq("metal"));
     }
 
+    const char *debian_folder = "/usr/share/lammps/potentials";
+    if (debian_folder != nullptr) {
+        std::string path = platform::path_join(debian_folder, "Cu_u3.eam");
+        EXPECT_THAT(utils::get_potential_file_path("Cu_u3.eam"), Eq(path));
+        EXPECT_THAT(utils::get_potential_units(path, "EAM"), Eq("metal"));
+    }
+
     ASSERT_THAT(utils::get_potential_date("ctest1.txt", "Test"), Eq("2020-02-20"));
     ASSERT_THAT(utils::get_potential_units("ctest1.txt", "Test"), Eq("real"));
     ASSERT_THAT(utils::get_potential_date("ctest2.txt", "Test"), Eq(""));