Skip to content

Commit 6c81c7e

Browse files
authored
Merge pull request #25153 from julianmorillo/ESPResSo
[foss/2025a] ESPResSo v4.2.2
2 parents 198ec8c + fb4595a commit 6c81c7e

2 files changed

Lines changed: 188 additions & 0 deletions

File tree

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
easyblock = 'CMakeMake'
2+
3+
name = 'ESPResSo'
4+
version = '4.2.2'
5+
6+
homepage = 'https://espressomd.org/wordpress'
7+
description = """A software package for performing and analyzing scientific Molecular Dynamics simulations."""
8+
9+
source_urls = ['https://github.com/espressomd/espresso/releases/download/%(version)s/']
10+
sources = [SOURCELOWER_TAR_GZ]
11+
patches = ['ESPResSo-4.2.2_fix_unit_test_packaging_specifiers.patch',
12+
'ESPResSo-4.2.2_fix_numpy.patch']
13+
checksums = ['2bc02f91632b0030f1203759768bd718bd8a0005f72696980b12331b4bfa0d76',
14+
{'ESPResSo-4.2.2_fix_unit_test_packaging_specifiers.patch':
15+
'6fdb9a61812b7a1178804c82254e837bc69552cfc3d40011de3686ea1a6ff527'},
16+
{'ESPResSo-4.2.2_fix_numpy.patch':
17+
'1365be456d7d0c7c7243faee4a365a4d448e68ed1c044362a0b7be4d8c4b7dd7'},
18+
]
19+
20+
toolchain = {'name': 'foss', 'version': '2025a'}
21+
toolchainopts = {'usempi': True, 'pic': True}
22+
23+
builddependencies = [
24+
('CMake', '3.31.3'),
25+
('Cython', '3.1.1'),
26+
]
27+
28+
dependencies = [
29+
('Python', '3.13.1'),
30+
('SciPy-bundle', '2025.06'),
31+
('Boost.MPI', '1.88.0'),
32+
('HDF5', '1.14.6'),
33+
('Mesa', '25.1.3'),
34+
('GSL', '2.8'),
35+
('IPython', '9.3.0'),
36+
('Pint', '0.24.4'),
37+
]
38+
39+
configopts = ' -DCMAKE_SKIP_RPATH=OFF -DWITH_TESTS=ON -DWITH_CUDA=OFF'
40+
# make sure the right Python is used (note: -DPython3_EXECUTABLE or -DPython_EXECUTABLE does not work!)
41+
configopts += ' -DPYTHON_EXECUTABLE=$EBROOTPYTHON/bin/python '
42+
43+
runtest = 'check_unit_tests && make check_python'
44+
45+
_binaries = ['ipypresso', 'pypresso']
46+
_libs = [
47+
'Espresso_config', 'Espresso_core', 'Espresso_script_interface', 'Espresso_shapes',
48+
'_init', 'analyze', 'code_info', 'electrokinetics', 'galilei',
49+
'integrate', 'interactions', 'lb', 'particle_data', 'polymer', 'profiler',
50+
'script_interface', 'system', 'thermostat', 'utils', 'version',
51+
]
52+
53+
_lib_path = 'lib/python%(pyshortver)s/site-packages/espressomd'
54+
55+
sanity_check_paths = {
56+
'files': ['bin/%s' % x for x in _binaries] +
57+
[_lib_path + '/%s.' % x + SHLIB_EXT for x in _libs],
58+
'dirs': ['bin', 'lib']
59+
}
60+
61+
sanity_check_commands = ['pypresso -h', 'ipypresso -h']
62+
63+
moduleclass = 'chem'
Lines changed: 125 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,125 @@
1+
# improve support for NumPy 2
2+
# https://github.com/espressomd/espresso/pull/4992
3+
# https://github.com/espressomd/espresso/pull/5034
4+
--- a/testsuite/python/thermostats_common.py
5+
+++ b/testsuite/python/thermostats_common.py
6+
@@ -19,2 +19,3 @@
7+
import numpy as np
8+
+import scipy.integrate
9+
10+
@@ -28,3 +29,3 @@
11+
x = np.linspace(x1, x2, 1000)
12+
- return np.trapz(np.exp(-x**2 / (2. * kT)), x) / np.sqrt(2. * np.pi * kT)
13+
+ return scipy.integrate.trapezoid(np.exp(-x**2 / (2. * kT)), x=x) / np.sqrt(2. * np.pi * kT)
14+
15+
--- a/testsuite/python/widom_insertion.py
16+
+++ b/testsuite/python/widom_insertion.py
17+
@@ -24,2 +24,3 @@
18+
import numpy as np
19+
+import scipy.integrate
20+
import espressomd
21+
@@ -52,3 +53,3 @@
22+
# coordinates
23+
- integrateUpToCutOff = 4 * np.pi * np.trapz(
24+
+ integrateUpToCutOff = 4 * np.pi * scipy.integrate.trapezoid(
25+
radius**2 * np.exp(-tests_common.lj_potential(radius,
26+
diff --git a/testsuite/python/brownian_dynamics.py b/testsuite/python/brownian_dynamics.py
27+
index 223340e15..f99d94018 100644
28+
--- a/testsuite/python/brownian_dynamics.py
29+
+++ b/testsuite/python/brownian_dynamics.py
30+
@@ -161,5 +161,5 @@ class BrownianThermostat(ut.TestCase):
31+
system.integrator.run(3)
32+
np.testing.assert_allclose(
33+
- part.omega_lab, [0, 0, 1.3 / 1.5], atol=1e-14)
34+
+ np.copy(part.omega_lab), [0, 0, 1.3 / 1.5], atol=1e-14)
35+
36+
# noise only
37+
@@ -168,5 +168,5 @@ class BrownianThermostat(ut.TestCase):
38+
kT=1, gamma=1, gamma_rotation=1.5, act_on_virtual=False, seed=41)
39+
system.integrator.run(3)
40+
- self.assertGreater(np.linalg.norm(part.omega_lab), 0.)
41+
+ self.assertGreater(np.linalg.norm(np.copy(part.omega_lab)), 0.)
42+
43+
44+
diff --git a/testsuite/python/lees_edwards.py b/testsuite/python/lees_edwards.py
45+
index 002340bd2..4539f1af5 100644
46+
--- a/testsuite/python/lees_edwards.py
47+
+++ b/testsuite/python/lees_edwards.py
48+
@@ -397,5 +397,5 @@ class LeesEdwards(ut.TestCase):
49+
a=k_non_bonded / 2, n=-2, cutoff=r_cut)
50+
system.integrator.run(0)
51+
- r_12 = system.distance_vec(p1, p2)
52+
+ r_12 = np.copy(system.distance_vec(p1, p2))
53+
54+
np.testing.assert_allclose(
55+
@@ -405,5 +405,5 @@ class LeesEdwards(ut.TestCase):
56+
np.testing.assert_allclose(
57+
np.copy(system.analysis.pressure_tensor()["non_bonded"]),
58+
- np.outer(r_12, p2.f) / system.volume())
59+
+ np.outer(r_12, np.copy(p2.f)) / system.volume())
60+
61+
np.testing.assert_almost_equal(
62+
@@ -438,5 +438,5 @@ class LeesEdwards(ut.TestCase):
63+
shear_direction="x", shear_plane_normal="y", protocol=lin_protocol)
64+
# Test position and velocity of VS with Le shift
65+
- old_p3_pos = p3.pos
66+
+ old_p3_pos = np.copy(p3.pos)
67+
expected_p3_pos = old_p3_pos - \
68+
np.array((get_lin_pos_offset(system.time, **params_lin), 0, 0))
69+
@@ -444,5 +444,5 @@ class LeesEdwards(ut.TestCase):
70+
np.testing.assert_allclose(np.copy(p3.pos_folded), expected_p3_pos)
71+
np.testing.assert_allclose(
72+
- p3.v, p1.v + np.array((params_lin["shear_velocity"], 0, 0)))
73+
+ np.copy(p3.v), np.copy(p1.v) + np.array((params_lin["shear_velocity"], 0, 0)))
74+
75+
# Check distances
76+
diff --git a/testsuite/python/test_checkpoint.py b/testsuite/python/test_checkpoint.py
77+
index f295cec44..4b30aaefb 100644
78+
--- a/testsuite/python/test_checkpoint.py
79+
+++ b/testsuite/python/test_checkpoint.py
80+
@@ -217,12 +217,12 @@ class CheckpointTest(ut.TestCase):
81+
np.testing.assert_allclose(np.copy(p3.ext_torque), [0.3, 0.5, 0.7])
82+
if espressomd.has_features('ROTATIONAL_INERTIA'):
83+
- np.testing.assert_allclose(p3.rinertia, [2., 3., 4.])
84+
+ np.testing.assert_allclose(np.copy(p3.rinertia), [2., 3., 4.])
85+
if espressomd.has_features('THERMOSTAT_PER_PARTICLE'):
86+
gamma = 2.
87+
if espressomd.has_features('PARTICLE_ANISOTROPY'):
88+
gamma = np.array([2., 3., 4.])
89+
- np.testing.assert_allclose(p4.gamma, gamma)
90+
+ np.testing.assert_allclose(np.copy(p4.gamma), gamma)
91+
if espressomd.has_features('ROTATION'):
92+
- np.testing.assert_allclose(p3.gamma_rot, 2. * gamma)
93+
+ np.testing.assert_allclose(np.copy(p3.gamma_rot), 2. * gamma)
94+
if espressomd.has_features('ENGINE'):
95+
self.assertEqual(p3.swimming, {"f_swim": 0.03, "mode": "N/A",
96+
@@ -237,9 +237,11 @@ class CheckpointTest(ut.TestCase):
97+
q_ind = ([1, 2, 3, 0],) # convert from scalar-first to scalar-last
98+
vs_id, vs_dist, vs_quat = p2.vs_relative
99+
- d = p2.pos - p1.pos
100+
+ d = np.copy(p2.pos - p1.pos)
101+
+ vs_quat = np.copy(vs_quat)
102+
+ p_quat = np.copy(p1.quat)
103+
theta = np.arccos(d[2] / np.linalg.norm(d))
104+
assert abs(theta - 3. * np.pi / 4.) < 1e-8
105+
q = np.array([0., 0., np.sin(theta / 2.), -np.cos(theta / 2.)])
106+
- r = R.from_quat(p1.quat[q_ind]) * R.from_quat(vs_quat[q_ind])
107+
+ r = R.from_quat(p_quat[q_ind]) * R.from_quat(vs_quat[q_ind])
108+
self.assertEqual(vs_id, p1.id)
109+
np.testing.assert_allclose(vs_dist, np.sqrt(2.))
110+
@@ -500,5 +502,5 @@ class CheckpointTest(ut.TestCase):
111+
self.assertEqual(p_virt.vs_relative[1], np.sqrt(2.))
112+
np.testing.assert_allclose(
113+
- p_real.vs_relative[2], [1., 0., 0., 0.], atol=1e-10)
114+
+ np.copy(p_real.vs_relative[2]), [1., 0., 0., 0.], atol=1e-10)
115+
116+
def test_mean_variance_calculator(self):
117+
@@ -785,6 +787,6 @@ class CheckpointTest(ut.TestCase):
118+
p2 = system.part.add(pos=[system.box_l[0] - 1., 1.6, 0.], type=6)
119+
system.integrator.run(0, recalc_forces=True)
120+
- np.testing.assert_allclose(p1.f, [0., 1e8, 0.], atol=1e-3)
121+
- np.testing.assert_allclose(p2.f, [0., 1e8, 0.], atol=1e-3)
122+
+ np.testing.assert_allclose(np.copy(p1.f), [0., 1e8, 0.], atol=1e-3)
123+
+ np.testing.assert_allclose(np.copy(p2.f), [0., 1e8, 0.], atol=1e-3)
124+
p1.remove()
125+
p2.remove()

0 commit comments

Comments
 (0)