Skip to content

Commit f2ae740

Browse files
committed
Drop support for ESPResSo 4.2
1 parent f20b221 commit f2ae740

14 files changed

Lines changed: 122 additions & 211 deletions

.github/actions/dependencies/action.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ runs:
1111
using: "composite"
1212
steps:
1313
- run: |
14+
test "${RUNNER_ARCH}" = "X64" && module use /cvmfs/dev.eessi.io/espresso/versions/${EESSI_VERSION}/software/linux/x86_64/amd/zen2/modules/all
1415
module load ${{ inputs.modules }}
1516
module save pymbe
1617
python3 -m venv --system-site-packages venv

.github/workflows/samples.yml

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -17,28 +17,29 @@ jobs:
1717
OMPI_MCA_mtl_ofi_provider_exclude: psm3
1818
strategy:
1919
matrix:
20-
espresso:
21-
- version: "4.2.2"
22-
eessi_modules: ESPResSo/4.2.2-foss-2023b
23-
eessi_stack_version: "2023.06"
24-
upload_artifact: true
25-
- version: "5.0.1"
20+
software:
21+
- label: "ESPResSo 5.0.1"
2622
eessi_modules: ESPResSo/5.0.1-foss-2025a
2723
eessi_stack_version: "2025.06"
24+
upload_artifact: true
25+
- label: "ESPResSo 5.1-dev"
26+
eessi_modules: ESPResSo/cd7547c43b2dae8e96487bf149d049d701dddd43-foss-2025a
27+
eessi_stack_version: "2025.06"
2828
upload_artifact: false
29-
name: ubuntu - ESPResSo ${{ matrix.espresso.version }}
29+
name: ubuntu - ${{ matrix.software.label }}
3030
steps:
31+
- name: Checkout repository
32+
uses: actions/checkout@main
3133
- name: Setup EESSI
3234
uses: eessi/github-action-eessi@v3
3335
with:
34-
eessi_stack_version: ${{ matrix.espresso.eessi_stack_version }}
35-
- name: Checkout repository
36-
uses: actions/checkout@main
36+
eessi_stack_version: ${{ matrix.software.eessi_stack_version }}
37+
use_eessi_module: false
3738
- name: Install dependencies
3839
uses: ./.github/actions/dependencies
3940
with:
4041
modules: |-
41-
${{ matrix.espresso.eessi_modules }}
42+
${{ matrix.software.eessi_modules }}
4243
- name: Run testsuite
4344
run: |
4445
export NUM_PROC=$(nproc)

.github/workflows/testsuite.yml

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,13 @@ jobs:
1717
strategy:
1818
matrix:
1919
software:
20-
- label: "ESPResSo 4.2.2, LAMMPS 2024"
21-
eessi_modules: ESPResSo/4.2.2-foss-2023b LAMMPS/29Aug2024-foss-2023b-kokkos
22-
eessi_stack_version: "2023.06"
23-
upload_artifact: true
2420
- label: "ESPResSo 5.0.1"
2521
eessi_modules: ESPResSo/5.0.1-foss-2025a
2622
eessi_stack_version: "2025.06"
23+
upload_artifact: true
24+
- label: "ESPResSo 5.1-dev"
25+
eessi_modules: ESPResSo/cd7547c43b2dae8e96487bf149d049d701dddd43-foss-2025a
26+
eessi_stack_version: "2025.06"
2727
upload_artifact: false
2828
name: ubuntu - ${{ matrix.software.label }}
2929
steps:
@@ -37,6 +37,7 @@ jobs:
3737
uses: eessi/github-action-eessi@v3
3838
with:
3939
eessi_stack_version: ${{ matrix.software.eessi_stack_version }}
40+
use_eessi_module: false
4041
- name: Install dependencies
4142
uses: ./.github/actions/dependencies
4243
with:

pyMBE/simulation_builder/espresso_engine.py

Lines changed: 24 additions & 77 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@ def __init__(self,box_l,db,espresso_system,units,kT,Kw,seed):
3737
self.kT=kT
3838
self.Kw=Kw
3939
self.seed=seed
40-
pass
4140

4241
def _add_angle(self,particle_id1,particle_id2,particle_id3, angle_inst):
4342
"""
@@ -365,36 +364,6 @@ def change_volume_and_rescale_particles(self, d_new, dir="xyz"):
365364

366365
self.espresso_system.change_volume_and_rescale_particles(d_new=d_new,
367366
dir=dir)
368-
369-
370-
def do_reaction(self,algorithm, steps):
371-
"""
372-
Executes reaction steps using an ESPResSo reaction algorithm with
373-
version-compatible calling semantics.
374-
375-
This function wraps the `reaction` method of an ESPResSo reaction
376-
algorithm to account for differences in the method signature between
377-
ESPResSo versions.
378-
379-
Args:
380-
algorithm ('espressomd.reaction_methods'):
381-
ESPResSo reaction algorithm object (e.g. constant pH,
382-
reaction ensemble, or similar).
383-
steps ('int'):
384-
Number of reaction steps to perform.
385-
386-
Notes:
387-
- In ESPResSo 4.2, the `reaction` method expects the number of steps
388-
to be passed as the keyword argument `reaction_steps`.
389-
- In newer ESPResSo versions, the keyword argument is `steps`.
390-
- This helper function provides a stable interface across ESPResSo
391-
versions by dispatching to the appropriate keyword internally.
392-
"""
393-
import espressomd.version
394-
if espressomd.version.friendly() == '4.2':
395-
algorithm.reaction(reaction_steps=steps)
396-
else:
397-
algorithm.reaction(steps=steps)
398367

399368
def enable_motion_of_rigid_object(self, instance_id, pmb_type):
400369
"""
@@ -442,35 +411,6 @@ def enable_motion_of_rigid_object(self, instance_id, pmb_type):
442411
pid = self.espresso_system.part.by_id(particle_id)
443412
pid.vs_auto_relate_to(rigid_object_center.id)
444413

445-
def get_number_of_particles(self, ptype):
446-
"""
447-
Returns the number of particles of a given ESPResSo particle type.
448-
449-
Args:
450-
ptype ('int'):
451-
ESPResSo particle type identifier.
452-
453-
Returns:
454-
('int'):
455-
Number of particles in `espresso_system` with particle type `ptype`.
456-
457-
Notes:
458-
- In ESPResSo 4.2, `number_of_particles` expects the particle type
459-
as a positional argument.
460-
- In later ESPResSo versions, the particle type must be passed as a
461-
keyword argument (`type=ptype`).
462-
- This helper function hides these API differences and provides
463-
a uniform interface across ESPResSo versions.
464-
"""
465-
import espressomd.version
466-
if espressomd.version.friendly() == "4.2":
467-
args = (ptype,)
468-
kwargs = {}
469-
else:
470-
args = ()
471-
kwargs = {"type": ptype}
472-
return self.espresso_system.number_of_particles(*args, **kwargs)
473-
474414
def relax_espresso_system(self, seed, gamma=1e-3, Nsteps_steepest_descent=5000, max_displacement=0.01, Nsteps_iter_relax=500):
475415
"""
476416
Relaxes the energy of the given ESPResSo system by performing the following steps:
@@ -610,19 +550,13 @@ def setup_electrostatic_interactions(self,units, kT, c_salt=None, solvent_permit
610550

611551
if tune_p3m:
612552
self.espresso_system.time_step=0.01
613-
if espressomd.version.friendly() == "4.2":
614-
self.espresso_system.actors.add(coulomb)
615-
else:
616-
self.espresso_system.electrostatics.solver = coulomb
553+
self.espresso_system.electrostatics.solver = coulomb
617554

618555

619556
# save the optimal parameters and add them by hand
620557

621558
p3m_params = coulomb.get_params()
622-
if espressomd.version.friendly() == "4.2":
623-
self.espresso_system.actors.remove(coulomb)
624-
else:
625-
self.espresso_system.electrostatics.solver = None
559+
self.espresso_system.electrostatics.solver = None
626560
coulomb = espressomd.electrostatics.P3M(prefactor = COULOMB_PREFACTOR.m_as("reduced_length * reduced_energy"),
627561
accuracy = accuracy,
628562
mesh = p3m_params['mesh'],
@@ -641,10 +575,7 @@ def setup_electrostatic_interactions(self,units, kT, c_salt=None, solvent_permit
641575
coulomb = espressomd.electrostatics.DH(prefactor = COULOMB_PREFACTOR.m_as("reduced_length * reduced_energy"),
642576
kappa = (1./KAPPA).to('1/ reduced_length').magnitude,
643577
r_cut = r_cut)
644-
if espressomd.version.friendly() == "4.2":
645-
self.espresso_system.actors.add(coulomb)
646-
else:
647-
self.espresso_system.electrostatics.solver = coulomb
578+
self.espresso_system.electrostatics.solver = coulomb
648579
logging.debug("*** Electrostatics successfully added to the system ***")
649580

650581
def setup_cpH (self, counter_ion, constant_pH, exclusion_range=None, use_exclusion_radius_per_type = False):
@@ -676,11 +607,15 @@ def setup_cpH (self, counter_ion, constant_pH, exclusion_range=None, use_exclusi
676607
exclusion_radius_per_type = self.db.get_radius_map()
677608
else:
678609
exclusion_radius_per_type = {}
610+
kwargs = {}
611+
if espressomd.version.version() >= (5, 1, 0):
612+
kwargs["system"] = self.espresso_system
679613
RE = reaction_methods.ConstantpHEnsemble(kT=self.kT.to('reduced_energy').magnitude,
680614
exclusion_range=exclusion_range,
681615
seed=self.seed,
682616
constant_pH=constant_pH,
683-
exclusion_radius_per_type = exclusion_radius_per_type)
617+
exclusion_radius_per_type = exclusion_radius_per_type,
618+
**kwargs)
684619
conterion_tpl = self.db.get_template(name=counter_ion,
685620
pmb_type="particle")
686621
conterion_state = self.db.get_template(name=conterion_tpl.initial_state,
@@ -749,10 +684,14 @@ def setup_gcmc(self, c_salt_res, salt_cation_name, salt_anion_name, activity_coe
749684
exclusion_radius_per_type = self.db.get_radius_map()
750685
else:
751686
exclusion_radius_per_type = {}
687+
kwargs = {}
688+
if espressomd.version.version() >= (5, 1, 0):
689+
kwargs["system"] = self.espresso_system
752690
RE = reaction_methods.ReactionEnsemble(kT=self.kT.to('reduced_energy').magnitude,
753691
exclusion_range=exclusion_range,
754692
seed=self.seed,
755-
exclusion_radius_per_type = exclusion_radius_per_type)
693+
exclusion_radius_per_type = exclusion_radius_per_type,
694+
**kwargs)
756695
# Determine the concentrations of the various species in the reservoir and the equilibrium constants
757696
determined_activity_coefficient = activity_coefficient(c_salt_res)
758697
K_salt = (c_salt_res.to('1/(N_A * reduced_length**3)')**2) * determined_activity_coefficient
@@ -846,10 +785,14 @@ def setup_grxmc_reactions(self, pH_res, c_salt_res, proton_name, hydroxide_name,
846785
exclusion_radius_per_type = self.db.get_radius_map()
847786
else:
848787
exclusion_radius_per_type = {}
788+
kwargs = {}
789+
if espressomd.version.version() >= (5, 1, 0):
790+
kwargs["system"] = self.espresso_system
849791
RE = reaction_methods.ReactionEnsemble(kT=self.kT.to('reduced_energy').magnitude,
850792
exclusion_range=exclusion_range,
851793
seed=self.seed,
852-
exclusion_radius_per_type = exclusion_radius_per_type)
794+
exclusion_radius_per_type = exclusion_radius_per_type,
795+
**kwargs)
853796
# Determine the concentrations of the various species in the reservoir and the equilibrium constants
854797
cH_res, cOH_res, cNa_res, cCl_res = self.determine_reservoir_concentrations(pH_res, c_salt_res, activity_coefficient)
855798
ionic_strength_res = 0.5*(cNa_res+cCl_res+cOH_res+cH_res)
@@ -1142,10 +1085,14 @@ def setup_grxmc_unified(self, pH_res, c_salt_res, cation_name, anion_name, activ
11421085
exclusion_radius_per_type = self.db.get_radius_map()
11431086
else:
11441087
exclusion_radius_per_type = {}
1088+
kwargs = {}
1089+
if espressomd.version.version() >= (5, 1, 0):
1090+
kwargs["system"] = self.espresso_system
11451091
RE = reaction_methods.ReactionEnsemble(kT=self.kT.to('reduced_energy').magnitude,
11461092
exclusion_range=exclusion_range,
11471093
seed=self.seed,
1148-
exclusion_radius_per_type = exclusion_radius_per_type)
1094+
exclusion_radius_per_type = exclusion_radius_per_type,
1095+
**kwargs)
11491096
# Determine the concentrations of the various species in the reservoir and the equilibrium constants
11501097
cH_res, cOH_res, cNa_res, cCl_res = self.determine_reservoir_concentrations(pH_res, c_salt_res, activity_coefficient)
11511098
ionic_strength_res = 0.5*(cNa_res+cCl_res+cOH_res+cH_res)
@@ -1319,7 +1266,7 @@ def setup_lj_interactions(self, shift_potential=True, combining_rule='Lorentz-Be
13191266
13201267
Notes:
13211268
- Currently, the only 'combining_rule' supported is Lorentz-Berthelot.
1322-
- Check the documentation of ESPResSo for more info about the potential https://espressomd.github.io/doc4.2.0/inter_non-bonded.html
1269+
- Check the documentation of ESPResSo for more info about the potential https://espressomd.github.io/doc5.0.1/inter_non-bonded.html
13231270
13241271
"""
13251272
from itertools import combinations_with_replacement

samples/Beyer2024/globular_protein.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
from pathlib import Path
2020
import tqdm
2121
import espressomd
22+
import espressomd.version
2223
import argparse
2324
import numpy as np
2425
import pandas as pd
@@ -268,8 +269,8 @@
268269
print(pmb.get_reactions_df())
269270

270271
type_map = pmb.get_type_map()
271-
types = list (type_map.values())
272-
espresso_system.setup_type_map( type_list = types)
272+
if espressomd.version.version() < (5, 1, 0):
273+
espresso_system.setup_type_map(type_list = type_map.values())
273274

274275
# Setup the non-interacting type for speeding up the sampling of the reactions
275276
non_interacting_type = max(type_map.values())+1
@@ -320,7 +321,7 @@
320321

321322
for step in tqdm.trange(N_samples, disable=not verbose):
322323
espresso_system.integrator.run (steps = integ_steps)
323-
pmb.simulation_engine.do_reaction(cpH, steps=total_ionisable_groups)
324+
cpH.reaction(steps=total_ionisable_groups)
324325
protein_net_charge = pmb.calculate_net_charge(
325326
object_name=protein_name,
326327
pmb_type="protein",

samples/Beyer2024/peptide.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
# Load espresso, pyMBE and other necessary libraries
2020
from pathlib import Path
2121
import espressomd
22+
import espressomd.version
2223
import pandas as pd
2324
import argparse
2425
import tqdm
@@ -184,11 +185,11 @@
184185
print(pmb.get_reactions_df())
185186

186187
# Setup espresso to track the ionization of the acid/basic groups in peptide
187-
type_map =pmb.get_type_map()
188-
espresso_system.setup_type_map(type_list = list(type_map.values()))
188+
if espressomd.version.version() < (5, 1, 0):
189+
espresso_system.setup_type_map(type_list = pmb.get_type_map().values())
189190

190191
# Setup the non-interacting type for speeding up the sampling of the reactions
191-
non_interacting_type = max(type_map.values())+1
192+
non_interacting_type = max(pmb.get_type_map().values())+1
192193
cpH.set_non_interacting_type (type=non_interacting_type)
193194
if verbose:
194195
print(f"The non-interacting type is set to {non_interacting_type}")
@@ -224,7 +225,7 @@
224225
# Run LD
225226
espresso_system.integrator.run(steps=MD_steps_per_sample)
226227
# Run MC
227-
pmb.simulation_engine.do_reaction(cpH, steps=len(sequence))
228+
cpH.reaction(steps=len(sequence))
228229
# Sample observables
229230
charge_dict=pmb.calculate_net_charge(
230231
object_name=sequence,

samples/Beyer2024/weak_polyelectrolyte_dialysis.py

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,9 @@
1616
# You should have received a copy of the GNU General Public License
1717
# along with this program. If not, see <http://www.gnu.org/licenses/>.
1818

19-
#######################################################
20-
# Loading modules
21-
#######################################################
22-
2319
# Load python modules
2420
import espressomd
21+
import espressomd.version
2522
from pathlib import Path
2623
import numpy as np
2724
import pandas as pd
@@ -36,8 +33,6 @@
3633
# Create an instance of pyMBE library
3734
pmb = pyMBE.pymbe_library(seed=42)
3835

39-
# Load some functions from the handy_scripts library for convenience
40-
4136

4237
#######################################################
4338
# Setting parameters for the simulation
@@ -209,13 +204,12 @@
209204
print("The acid-base reaction has been successfully set up for:")
210205
print(pmb.get_reactions_df())
211206

212-
# Setup espresso to track the ionization of the acid groups
213-
type_map = pmb.get_type_map()
214-
types = list(type_map.values())
215-
espresso_system.setup_type_map(type_list = types)
207+
# Setup espresso to track the ionization of the acid/basic groups in peptide
208+
if espressomd.version.version() < (5, 1, 0):
209+
espresso_system.setup_type_map(type_list = pmb.get_type_map().values())
216210

217211
# Setup the non-interacting type for speeding up the sampling of the reactions
218-
non_interacting_type = max(type_map.values())+1
212+
non_interacting_type = max(pmb.get_type_map().values())+1
219213
grxmc.set_non_interacting_type (type=non_interacting_type)
220214

221215
#Set up the interactions
@@ -233,7 +227,7 @@
233227
print("Running warmup without electrostatics")
234228
for i in tqdm.trange(100, disable=not verbose):
235229
espresso_system.integrator.run(steps=1000)
236-
pmb.simulation_engine.do_reaction(grxmc, steps=1000)
230+
grxmc.reaction(steps=1000)
237231

238232
pmb.simulation_engine.setup_electrostatic_interactions(units=pmb.units,
239233
kT=pmb.kT,
@@ -257,7 +251,7 @@
257251
N_warmup_loops = 100
258252
for i in tqdm.trange(N_warmup_loops, disable=not verbose):
259253
espresso_system.integrator.run(steps=1000)
260-
pmb.simulation_engine.do_reaction(grxmc, steps=100)
254+
grxmc.reaction(steps=100)
261255

262256
# Main loop
263257
print("Started production run.")
@@ -273,7 +267,7 @@
273267
N_production_loops = 100
274268
for i in tqdm.trange(N_production_loops, disable=not verbose):
275269
espresso_system.integrator.run(steps=1000)
276-
pmb.simulation_engine.do_reaction(grxmc, steps=100)
270+
grxmc.reaction(steps=100)
277271
# Measure time
278272
time_series["time"].append(espresso_system.time)
279273
# Measure degree of ionization

0 commit comments

Comments
 (0)