@@ -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
0 commit comments