diff --git a/doc/tutorials/constant_pH/constant_pH.ipynb b/doc/tutorials/constant_pH/constant_pH.ipynb
index e147a6c3bb..0c52dde352 100644
--- a/doc/tutorials/constant_pH/constant_pH.ipynb
+++ b/doc/tutorials/constant_pH/constant_pH.ipynb
@@ -153,6 +153,7 @@
"import espressomd.electrostatics\n",
"import espressomd.reaction_methods\n",
"import espressomd.polymer\n",
+ "import espressomd.zn\n",
"from espressomd.interactions import HarmonicBond"
]
},
@@ -569,7 +570,7 @@
"\n",
"# add thermostat and short integration to let the system relax further\n",
"system.thermostat.set_langevin(kT=KT_REDUCED, gamma=1.0, seed=7)\n",
- "system.integrator.run(steps=1000)\n",
+ "system.integrator.run(1000)\n",
"\n",
"if USE_ELECTROSTATICS:\n",
" COULOMB_PREFACTOR=BJERRUM_LENGTH_REDUCED * KT_REDUCED\n",
@@ -739,6 +740,40 @@
"outputs": [],
"source": []
},
+ {
+ "cell_type": "markdown",
+ "id": "cd417295-bab3-46a5-a574-fc60d06371a5",
+ "metadata": {},
+ "source": [
+ "We will initialize ZnDraw to visualize the simulation for increasing pH values:"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "id": "04dd303c",
+ "metadata": {
+ "scrolled": false
+ },
+ "outputs": [],
+ "source": [
+ "color = {TYPES[\"HA\"]: \"#7fc454\", #green\n",
+ " TYPES[\"A\"]: \"#225204\", #dark green\n",
+ " TYPES[\"B\"]: \"#fca000\", #orange\n",
+ " TYPES[\"Na\"]: \"#ff0000\", #red\n",
+ " TYPES[\"Cl\"]: \"#030ffc\" #blue\n",
+ " }\n",
+ "radii = {TYPES[\"HA\"]: 2,\n",
+ " TYPES[\"A\"]: 2,\n",
+ " TYPES[\"B\"]: 2,\n",
+ " TYPES[\"Na\"]: 2,\n",
+ " TYPES[\"Cl\"]: 2\n",
+ " }\n",
+ "\n",
+ "vis = espressomd.zn.Visualizer(system, colors=color, radii=radii)\n",
+ "vis.update()"
+ ]
+ },
{
"cell_type": "markdown",
"id": "07daa583",
@@ -778,11 +813,14 @@
"outputs": [],
"source": [
"# SOLUTION CELL\n",
- "def perform_sampling(type_A, num_samples, num_As:np.ndarray, reaction_steps, \n",
+ "def perform_sampling(type_A, num_samples, num_As:np.ndarray, reaction_steps,\n",
" prob_integration=0.5, integration_steps=1000):\n",
" for i in range(num_samples):\n",
" if USE_WCA and np.random.random() < prob_integration:\n",
- " system.integrator.run(integration_steps)\n",
+ " for _ in range(integration_steps):\n",
+ " system.integrator.run(1)\n",
+ " global vis\n",
+ " vis.update()\n",
" # we should do at least one reaction attempt per reactive particle\n",
" RE.reaction(steps=reaction_steps)\n",
" num_As[i] = system.number_of_particles(type=type_A)"
diff --git a/doc/tutorials/electrodes/electrodes_part2.ipynb b/doc/tutorials/electrodes/electrodes_part2.ipynb
index 4cae3ebcd5..e7007c62e3 100644
--- a/doc/tutorials/electrodes/electrodes_part2.ipynb
+++ b/doc/tutorials/electrodes/electrodes_part2.ipynb
@@ -214,6 +214,7 @@
"import espressomd.observables\n",
"import espressomd.accumulators\n",
"import espressomd.shapes\n",
+ "import espressomd.zn\n",
"\n",
"espressomd.assert_features(['WCA', 'ELECTROSTATICS'])\n",
"rng = np.random.default_rng(42)\n",
@@ -476,20 +477,20 @@
"source": [
"# SOLUTION CELL\n",
"offset = LJ_SIGMA # avoid unfavorable overlap at close distance to the walls\n",
- "init_part_btw_z1 = offset \n",
+ "init_part_btw_z1 = offset\n",
"init_part_btw_z2 = box_l_z - offset\n",
- "ion_pos = np.empty((3), dtype=float)\n",
+ "ion_pos = np.empty((3,), dtype=float)\n",
"\n",
- "for i in range (N_IONPAIRS):\n",
- " ion_pos[0] = rng.random(1) * system.box_l[0]\n",
- " ion_pos[1] = rng.random(1) * system.box_l[1]\n",
- " ion_pos[2] = rng.random(1) * (init_part_btw_z2 - init_part_btw_z1) + init_part_btw_z1\n",
+ "for i in range(N_IONPAIRS):\n",
+ " ion_pos[0] = rng.random(1)[0] * system.box_l[0]\n",
+ " ion_pos[1] = rng.random(1)[0] * system.box_l[1]\n",
+ " ion_pos[2] = rng.random(1)[0] * (init_part_btw_z2 - init_part_btw_z1) + init_part_btw_z1\n",
" system.part.add(pos=ion_pos, type=types[\"Cation\"], q=charges[\"Cation\"])\n",
- " \n",
- "for i in range (N_IONPAIRS):\n",
- " ion_pos[0] = rng.random(1) * system.box_l[0]\n",
- " ion_pos[1] = rng.random(1) * system.box_l[1]\n",
- " ion_pos[2] = rng.random(1) * (init_part_btw_z2 - init_part_btw_z1) + init_part_btw_z1\n",
+ "\n",
+ "for i in range(N_IONPAIRS):\n",
+ " ion_pos[0] = rng.random(1)[0] * system.box_l[0]\n",
+ " ion_pos[1] = rng.random(1)[0] * system.box_l[1]\n",
+ " ion_pos[2] = rng.random(1)[0] * (init_part_btw_z2 - init_part_btw_z1) + init_part_btw_z1\n",
" system.part.add(pos=ion_pos, type=types[\"Anion\"], q=charges[\"Anion\"])"
]
},
@@ -1008,7 +1009,41 @@
"\n",
"With the above knowledge, we can now assess the \n",
"differential capacitance of the system, by changing the applied voltage\n",
- "difference and determining the corresponding surface charge density."
+ "difference and determining the corresponding surface charge density.\n",
+ "We will use ZnDraw to visualize our system:"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "id": "ef5d908f-a7f0-4845-9555-34822128c141",
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "color = {\n",
+ " types[\"Cation\"]: \"#ff0000\", #red\n",
+ " types[\"Anion\"]: \"#030ffc\" #blue\n",
+ " }\n",
+ " \n",
+ "radii = {\n",
+ " types[\"Cation\"]: LJ_SIGMA,\n",
+ " types[\"Anion\"]: LJ_SIGMA\n",
+ " }\n",
+ "\n",
+ "vis = espressomd.zn.Visualizer(system, colors=color, radii=radii)\n",
+ "#vis.draw_constraints([floor, ceiling])\n",
+ "\n",
+ "# note: you may need to zoom out since the ELC gap region takes a significant portion of\n",
+ "# the box along the non-periodic direction. The particles are only in the smaller subsystem.\n",
+ "# note: The particles are shown bigger for visualization purpose."
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "id": "21da58e8-e666-4d06-8538-a8d6af521148",
+ "metadata": {},
+ "source": [
+ "Do the sampling from high to low potential:"
]
},
{
@@ -1029,7 +1064,9 @@
"for potential_diff in tqdm.tqdm(np.linspace(MIN_PHI, MAX_PHI, N_PHI)[::-1]):\n",
" system.auto_update_accumulators.clear()\n",
" system.electrostatics.solver = setup_electrostatic_solver(potential_diff)\n",
- " system.integrator.run(N_SAMPLES_EQUIL_CAP * STEPS_PER_SAMPLE)\n",
+ " for i in range(N_SAMPLES_EQUIL_CAP * STEPS_PER_SAMPLE//50):\n",
+ " system.integrator.run(50)\n",
+ " vis.update()\n",
" sigmas = []\n",
"\n",
" for tm in range(N_SAMPLES_CAP):\n",
@@ -1039,7 +1076,9 @@
" system.auto_update_accumulators.clear()\n",
" system.auto_update_accumulators.add(density_accumulator_cation)\n",
" system.auto_update_accumulators.add(density_accumulator_anion)\n",
- " system.integrator.run(STEPS_PER_SAMPLE)\n",
+ " for j in range(int(STEPS_PER_SAMPLE/50)):\n",
+ " system.integrator.run(50)\n",
+ " vis.update()\n",
"\n",
" cation_profile_mean = density_accumulator_cation.mean()[0, 0, :]\n",
" anion_profile_mean = density_accumulator_anion.mean()[0, 0, :]\n",
diff --git a/doc/tutorials/ferrofluid/ferrofluid_part1.ipynb b/doc/tutorials/ferrofluid/ferrofluid_part1.ipynb
index d65111cce2..72d116a517 100644
--- a/doc/tutorials/ferrofluid/ferrofluid_part1.ipynb
+++ b/doc/tutorials/ferrofluid/ferrofluid_part1.ipynb
@@ -15,15 +15,13 @@
"source": [
"## Table of Contents\n",
"1. [Introduction](#Introduction)\n",
- "2. [The Model](#The-Model)\n",
+ "2. [The model](#The-model)\n",
"3. [Structure of this tutorial](#Structure-of-this-tutorial)\n",
- "4. [Compiling ESPResSo for this Tutorial](#Compiling-ESPResSo-for-this-Tutorial)\n",
- "5. [A Monolayer-Ferrofluid System in ESPResSo](#A-Monolayer-Ferrofluid-System-in-ESPResSo)\n",
+ "4. [Compiling ESPResSo for this tutorial](#Compiling-ESPResSo-for-this-tutorial)\n",
+ "5. [A monolayer-ferrofluid system in ESPResSo](#A-monolayer-ferrofluid-system-in-ESPResSo)\n",
" 1. [Setup](#Setup)\n",
- " 2. [Sampling](#Sampling)\n",
- " 3. [Sampling with animation](#Sampling-with-animation)\n",
- " 4. [Sampling without animation](#Sampling-without-animation)\n",
- " 5. [Cluster distribution](#Cluster-distribution)"
+ " 2. [Sampling and cluster analysis](#Sampling-and-cluster-analysis)\n",
+ " 3. [Cluster distribution](#Cluster-distribution)"
]
},
{
@@ -54,10 +52,8 @@
"metadata": {},
"source": [
""
]
},
@@ -67,10 +63,8 @@
"metadata": {},
"source": [
""
]
},
@@ -79,7 +73,7 @@
"id": "095339c1",
"metadata": {},
"source": [
- "## The Model"
+ "## The model"
]
},
{
@@ -124,7 +118,7 @@
" \\lambda = \\frac{\\tilde{u}_{\\text{DD}}}{u_T} = \\gamma \\frac{\\mu^2}{k_{\\text{B}}T\\sigma^3}\n",
"\\end{equation}\n",
"\n",
- "where $u_\\mathrm{T} = k_{\\text{B}}T$ is the thermal energy and $\\tilde{u}_{DD}$ is the absolute value of the dipole-dipole interaction energy at close contact (cc) and head-to-tail configuration (htt) (see figure 4) per particle, i.e. in formulas it reads\n",
+ "where $u_\\mathrm{T} = k_{\\text{B}}T$ is the thermal energy and $\\tilde{u}_{DD}$ is the absolute value of the dipole-dipole interaction energy at close contact (cc) and head-to-tail configuration (htt) (see figure 3) per particle, i.e. in formulas it reads\n",
"\n",
"\\begin{equation}\n",
" \\tilde{u}_{\\text{DD}} = \\frac{ \\left| u_{\\text{DD}}^{\\text{htt, cc}} \\right| }{2}\n",
@@ -143,11 +137,9 @@
"id": "62b95d9c",
"metadata": {},
"source": [
- "