Skip to content

Commit

Permalink
python: Rename MC method reaction argument
Browse files Browse the repository at this point in the history
For consistency with the integrator.run() method.

Co-authored-by: Pablo Miguel Blanco Andrés <[email protected]>
  • Loading branch information
jngrad and pm-blanco committed Feb 13, 2023
1 parent 4cfc4ce commit 881d214
Show file tree
Hide file tree
Showing 11 changed files with 23 additions and 23 deletions.
4 changes: 2 additions & 2 deletions doc/tutorials/constant_pH/constant_pH.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -686,7 +686,7 @@
"source": [
"```python\n",
"def equilibrate_reaction(reaction_steps=1):\n",
" RE.reaction(reaction_steps=reaction_steps)\n",
" RE.reaction(steps=reaction_steps)\n",
"```"
]
},
Expand Down Expand Up @@ -743,7 +743,7 @@
" if USE_WCA and np.random.random() < prob_integration:\n",
" system.integrator.run(integration_steps)\n",
" # we should do at least one reaction attempt per reactive particle\n",
" RE.reaction(reaction_steps=reaction_steps) \n",
" RE.reaction(steps=reaction_steps)\n",
" num_As[i] = system.number_of_particles(type=type_A)\n",
"```"
]
Expand Down
6 changes: 3 additions & 3 deletions maintainer/benchmarks/mc_acid_base_reservoir.py
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ def calc_donnan_coefficient(c_acid, I_res, charge=-1):


def equilibrate_reaction(reaction_steps=1):
RE.reaction(reaction_steps=reaction_steps)
RE.reaction(steps=reaction_steps)


def report_progress(system, i, next_i):
Expand Down Expand Up @@ -295,7 +295,7 @@ def report_progress(system, i, next_i):

if MC_STEPS_PER_SAMPLE > 0:
tick_MC = time.time()
RE.reaction(reaction_steps=MC_STEPS_PER_SAMPLE)
RE.reaction(steps=MC_STEPS_PER_SAMPLE)
tock_MC = time.time()

t_MC = (tock_MC - tick_MC) / MC_STEPS_PER_SAMPLE
Expand Down Expand Up @@ -332,7 +332,7 @@ def report_progress(system, i, next_i):
for i in range(NUM_SAMPLES):
if RUN_INTEGRATION:
system.integrator.run(INTEGRATION_STEPS_PER_SAMPLE)
RE.reaction(reaction_steps=MC_STEPS_PER_SAMPLE)
RE.reaction(steps=MC_STEPS_PER_SAMPLE)
n_A = system.number_of_particles(type=TYPES['A'])
n_As.append(n_A)
n_All = len(system.part)
Expand Down
6 changes: 3 additions & 3 deletions samples/grand_canonical.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@
# up the simulation
RE.set_non_interacting_type(type=max(types) + 1)

RE.reaction(reaction_steps=10000)
RE.reaction(steps=10000)

p3m = espressomd.electrostatics.P3M(prefactor=2.0, accuracy=1e-3)
system.actors.add(p3m)
Expand Down Expand Up @@ -134,14 +134,14 @@
system.thermostat.set_langevin(kT=temperature, gamma=.5, seed=42)

# MC warmup
RE.reaction(reaction_steps=1000)
RE.reaction(steps=1000)

n_int_cycles = 10000
n_int_steps = 600
num_As = []
deviation = None
for i in range(n_int_cycles):
RE.reaction(reaction_steps=10)
RE.reaction(steps=10)
system.integrator.run(steps=n_int_steps)
num_As.append(system.number_of_particles(type=1))
if i > 2 and i % 50 == 0:
Expand Down
4 changes: 2 additions & 2 deletions samples/reaction_ensemble_complex_reaction.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,10 +100,10 @@
RE.set_non_interacting_type(type=max(types) + 1)

# warmup
RE.reaction(reaction_steps=200)
RE.reaction(steps=200)

for i in range(200):
RE.reaction(reaction_steps=10)
RE.reaction(steps=10)
for _type in types:
numbers[_type].append(system.number_of_particles(type=_type))

Expand Down
2 changes: 1 addition & 1 deletion samples/reaction_methods.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@


for i in range(10000):
RE.reaction(reaction_steps=1)
RE.reaction(steps=1)
if i % 100 == 0:
print(f"HA {system.number_of_particles(type=types['HA'])}",
f"A- {system.number_of_particles(type=types['A-'])}",
Expand Down
6 changes: 3 additions & 3 deletions src/python/espressomd/reaction_methods.py
Original file line number Diff line number Diff line change
Expand Up @@ -407,19 +407,19 @@ def _rebuild_reaction_cache(self):
"""
self._reactions_cache = [x for x in self.reactions]

def reaction(self, reaction_steps):
def reaction(self, steps):
"""
Performs randomly selected reactions.
Parameters
----------
reaction_steps : :obj:`int`, optional
steps : :obj:`int`, optional
The number of reactions to be performed at once, defaults to 1.
"""
self.call_method("setup_bookkeeping_of_empty_pids")
E_pot = self.call_method("potential_energy")
for _ in range(reaction_steps):
for _ in range(steps):
reaction_id = self.call_method("get_random_reaction_index")
E_pot = self.generic_oneway_reaction(reaction_id, E_pot)

Expand Down
4 changes: 2 additions & 2 deletions testsuite/python/constant_pH.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,12 +64,12 @@ def test_ideal_alpha(self):
default_charges=charges_dict)

# equilibration
RE.reaction(reaction_steps=800)
RE.reaction(steps=800)

# sampling
alphas = []
for _ in range(80):
RE.reaction(reaction_steps=15)
RE.reaction(steps=15)
num_H = system.number_of_particles(type=types["H+"])
num_HA = system.number_of_particles(type=types["HA"])
num_A = system.number_of_particles(type=types["A-"])
Expand Down
4 changes: 2 additions & 2 deletions testsuite/python/constant_pH_stats.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,14 +80,14 @@ def test_ideal_titration_curve(self):

# chemical warmup - get close to chemical equilibrium before we start
# sampling
RE.reaction(reaction_steps=40 * N0)
RE.reaction(steps=40 * N0)

average_NH = 0.0
average_NHA = 0.0
average_NA = 0.0
num_samples = 1000
for _ in range(num_samples):
RE.reaction(reaction_steps=10)
RE.reaction(steps=10)
average_NH += system.number_of_particles(type=types["H+"])
average_NHA += system.number_of_particles(type=types["HA"])
average_NA += system.number_of_particles(type=types["A-"])
Expand Down
2 changes: 1 addition & 1 deletion testsuite/python/reaction_bookkeeping.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ def setUpClass(cls):

def test_reaction_bookeeping(self):
self.widom.calculate_particle_insertion_potential_energy(reaction_id=0)
self.cph.reaction(reaction_steps=100)
self.cph.reaction(steps=100)

# Measure the chemical potential
for _ in range(50):
Expand Down
4 changes: 2 additions & 2 deletions testsuite/python/reaction_complex.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,11 +84,11 @@ def test_equilibrium_concentrations(self):
RE.set_non_interacting_type(type=max(types) + 1)

# warmup
RE.reaction(reaction_steps=50)
RE.reaction(steps=50)

numbers = {type_A: [], type_B: [], type_C: [], type_D: [], type_E: []}
for _ in range(40):
RE.reaction(reaction_steps=6)
RE.reaction(steps=6)
for key in types:
numbers[key].append(self.system.number_of_particles(type=key))

Expand Down
4 changes: 2 additions & 2 deletions testsuite/python/reaction_ensemble.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,14 +97,14 @@ def test_ideal_titration_curve(self):

# chemical warmup - get close to chemical equilibrium before we start
# sampling
RE.reaction(reaction_steps=5 * N0)
RE.reaction(steps=5 * N0)

average_NH = 0.0
average_NHA = 0.0
average_NA = 0.0
num_samples = 300
for _ in range(num_samples):
RE.reaction(reaction_steps=10)
RE.reaction(steps=10)
average_NH += system.number_of_particles(type=types["H+"])
average_NHA += system.number_of_particles(type=types["HA"])
average_NA += system.number_of_particles(type=types["A-"])
Expand Down

0 comments on commit 881d214

Please sign in to comment.