Skip to content

Commit

Permalink
Edit and format tutorials
Browse files Browse the repository at this point in the history
  • Loading branch information
jngrad committed Aug 23, 2024
1 parent cfa136a commit efacee2
Show file tree
Hide file tree
Showing 7 changed files with 69 additions and 60 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 @@ -745,15 +745,15 @@
"id": "cd417295-bab3-46a5-a574-fc60d06371a5",
"metadata": {},
"source": [
"We will initialize the zndraw visualizer to visualize the simulation for increasing pH value:"
"We will initialize ZnDraw to visualize the simulation for increasing pH values:"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "04dd303c",
"metadata": {
"scrolled": true
"scrolled": false
},
"outputs": [],
"source": [
Expand Down
7 changes: 4 additions & 3 deletions doc/tutorials/electrodes/electrodes_part2.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -1010,7 +1010,7 @@
"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.\n",
"We will use the ZnDraw visualizer to visualize our system:"
"We will use ZnDraw to visualize our system:"
]
},
{
Expand All @@ -1033,8 +1033,9 @@
"vis = espressomd.zn.Visualizer(system, colors=color, radii=radii)\n",
"#vis.draw_constraints([floor, ceiling])\n",
"\n",
"#note: The system displayed is the enlarged system as you can see the ELG-GAP along the nonperiodic direction. The particles are only in the smaller subsystem.\n",
"#note: The particles are shown bigger for visualization purpose."
"# 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."
]
},
{
Expand Down
74 changes: 35 additions & 39 deletions doc/tutorials/ferrofluid/ferrofluid_part1.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -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)"
]
},
{
Expand Down Expand Up @@ -54,10 +52,8 @@
"metadata": {},
"source": [
"<a id='fig_1'></a><figure>\n",
"<img src=\"figures/Electro-Steric_Stabilization.jpg\" style=\"float: center; width: 49%\">\n",
"<center>\n",
"<figcaption>Figure 1: Schematic representation of electrostatically stabilization (picture top) and steric stabilization (picture bottom) <a href='#[3]'>[3]</a></figcaption>\n",
"</center>\n",
"<img src=\"figures/Electro-Steric_Stabilization.jpg\" style=\"display: block; margin-left: auto; margin-right: auto; width: 50%; max-width: 350px;\">\n",
"<center><figcaption>Figure 1: Schematic representation of electrostatically stabilization (picture top) and steric stabilization (picture bottom) <a href='#[3]'>[3]</a></figcaption></center>\n",
"</figure>"
]
},
Expand All @@ -67,10 +63,8 @@
"metadata": {},
"source": [
"<a id='fig_2'></a><figure>\n",
"<img src='figures/Ferrofluid_Magnet_under_glass_edit.jpg' alt='ferrofluid on glass plate under which a strong magnet is placed' style='width: 600px;'/>\n",
"<center>\n",
"<figcaption>Figure 2: Real Ferrofluid exposed to an external magnetic field (neodymium magnet) <a href='#[4]'>[4]</a></figcaption>\n",
"</center>\n",
"<img src='figures/Ferrofluid_Magnet_under_glass_edit.jpg' alt='ferrofluid on glass plate under which a strong magnet is placed' style='display: block; margin-left: auto; margin-right: auto; width: 80%; max-width: 600px;'/>\n",
"<center><figcaption>Figure 2: Real ferrofluid exposed to an external magnetic field (neodymium magnet) <a href='#[4]'>[4]</a></figcaption></center>\n",
"</figure>"
]
},
Expand All @@ -79,7 +73,7 @@
"id": "095339c1",
"metadata": {},
"source": [
"## The Model"
"## The model"
]
},
{
Expand Down Expand Up @@ -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 <a href='#fig_4'>figure 4</a>) 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 <a href='#fig_3'>figure 3</a>) 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",
Expand All @@ -143,11 +137,9 @@
"id": "62b95d9c",
"metadata": {},
"source": [
"<a id='fig_4'></a><figure>\n",
"<img src='figures/headtotailconf.png' alt='schematic representation of head to tail configuration' style='width: 200px;'/>\n",
"<center>\n",
"<figcaption>Figure 4: Schematic representation of the head-to-tail configuration of two magnetic particles at close contact.</figcaption>\n",
"</center>\n",
"<a id='fig_3'></a><figure>\n",
"<img src='figures/headtotailconf.png' alt='schematic representation of head to tail configuration' style='display: block; margin-left: auto; margin-right: auto; max-width: 200px;'/>\n",
"<center><figcaption>Figure 3: Schematic representation of the head-to-tail configuration of two magnetic particles at close contact.</figcaption></center>\n",
"</figure>"
]
},
Expand Down Expand Up @@ -182,7 +174,7 @@
"id": "b6d5a65e",
"metadata": {},
"source": [
"## Compiling ESPResSo for this Tutorial"
"## Compiling ESPResSo for this tutorial"
]
},
{
Expand Down Expand Up @@ -218,7 +210,7 @@
"id": "a0bffbeb",
"metadata": {},
"source": [
"## A Monolayer-Ferrofluid System in ESPResSo"
"## A monolayer-ferrofluid system in ESPResSo"
]
},
{
Expand Down Expand Up @@ -324,7 +316,8 @@
"id": "136aa645",
"metadata": {},
"source": [
"## Exercise:\n",
"**Exercise:**\n",
"\n",
"How large does `BOX_SIZE` have to be for a system of `N_PART` particles with a volume (area) fraction `PHI`?\n",
"Define `BOX_SIZE`."
]
Expand Down Expand Up @@ -384,7 +377,8 @@
"outputs": [],
"source": [
"# Lennard-Jones interaction\n",
"system.non_bonded_inter[0, 0].lennard_jones.set_params(epsilon=LJ_EPSILON, sigma=LJ_SIGMA, cutoff=LJ_CUT, shift=\"auto\")"
"system.non_bonded_inter[0, 0].lennard_jones.set_params(\n",
" epsilon=LJ_EPSILON, sigma=LJ_SIGMA, cutoff=LJ_CUT, shift=\"auto\")"
]
},
{
Expand All @@ -394,7 +388,7 @@
"source": [
"Now we generate random positions and orientations of the particles and their dipole moments. \n",
"\n",
"**Hint:**\n",
"Hint:\n",
"It should be noted that we seed the random number generator of numpy. Thus the initial configuration of our system is the same every time this script will be executed. You can change it to another one to simulate with a different initial configuration."
]
},
Expand All @@ -403,9 +397,11 @@
"id": "c49729f7",
"metadata": {},
"source": [
"## Exercise:\n",
"**Exercise:**\n",
"\n",
"How does one set up randomly oriented dipole moments?\n",
"*Hint*: Think of the way that different methods could introduce a bias in the distribution of the orientations.\n",
"\n",
"Hint: Think of the way that different methods could introduce a bias in the distribution of the orientations.\n",
"\n",
"Create a variable `dip` as a `N_PART x 3` numpy array, which contains the randomly distributed dipole moments."
]
Expand Down Expand Up @@ -523,7 +519,7 @@
"For the simulation of our system we choose the velocity Verlet integrator.\n",
"After that we set up the thermostat which is, in our case, a Langevin thermostat to simulate in an NVT ensemble.\n",
"\n",
"**Hint:**\n",
"Hint:\n",
"It should be noted that we seed the Langevin thermostat, thus the time evolution of the system is partly predefined.\n",
"Partly because of the numeric accuracy and the automatic tuning algorithms of Dipolar P3M and DLC where the resulting parameters are slightly different every time.\n",
"You can change the seed to get a guaranteed different time evolution."
Expand Down Expand Up @@ -562,7 +558,7 @@
"execution_count": null,
"id": "fd12b1f6",
"metadata": {
"scrolled": true
"scrolled": false
},
"outputs": [],
"source": [
Expand Down Expand Up @@ -592,7 +588,7 @@
"execution_count": null,
"id": "95c4a8b6",
"metadata": {
"scrolled": true
"scrolled": false
},
"outputs": [],
"source": [
Expand All @@ -608,7 +604,7 @@
"id": "a6c4c46b",
"metadata": {},
"source": [
"## Sampling and cluster analysis"
"### Sampling and cluster analysis"
]
},
{
Expand All @@ -617,7 +613,7 @@
"metadata": {},
"source": [
"To quantify the number of clusters and their respective sizes, we now want to perform a cluster analysis.\n",
"For that we can use ESPREsSo's [cluster analysis class](https://espressomd.github.io/doc/analysis.html?highlight=cluster%20analysis#cluster-analysis).\n",
"For that we can use ESPResSo's [cluster analysis class](https://espressomd.github.io/doc/analysis.html#cluster-analysis).\n",
"The system will be sampled over 100 loops."
]
},
Expand All @@ -636,7 +632,7 @@
"id": "2f6d201a",
"metadata": {},
"source": [
"## Exercise:\n",
"**Exercise:**\n",
"\n",
"Setup a cluster analysis object (`ClusterStructure` class) and assign its instance to the variable `cluster_structure`.\n",
"As criterion for the cluster analysis use a distance criterion where particles are assumed to be\n",
Expand Down Expand Up @@ -717,7 +713,7 @@
"id": "98b99dd6",
"metadata": {},
"source": [
"## Exercise:\n",
"**Exercise:**\n",
"\n",
"Write an integration loop which runs a cluster analysis on the system, saving the number of clusters `n_clusters` and the size distribution `cluster_sizes`.\n",
"Take the following as a starting point:\n",
Expand Down Expand Up @@ -803,7 +799,7 @@
"id": "4c0828ea",
"metadata": {},
"source": [
"## Cluster distribution"
"### Cluster distribution"
]
},
{
Expand All @@ -819,12 +815,12 @@
"id": "1c6be57c",
"metadata": {},
"source": [
"## Exercise:\n",
"**Exercise:**\n",
"\n",
"Use `numpy` to calculate a histogram of the cluster sizes and assign it to the variable `size_dist`.\n",
"Take only clusters up to a size of 19 particles into account.\n",
"\n",
"*Hint*: In order not to count clusters with size 20 or more, one may include an additional bin containing these.\n",
"Hint: In order not to count clusters with size 20 or more, one may include an additional bin containing these.\n",
"The reason for that is that `numpy` defines the histogram bins as half-open intervals with the open border at the upper bin edge.\n",
"Consequently clusters of larger sizes are attributed to the last bin.\n",
"By not using the last bin in the plot below, these clusters can effectively be neglected."
Expand Down
22 changes: 12 additions & 10 deletions doc/tutorials/ferrofluid/ferrofluid_part2.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,8 @@
"pos = box_size * np.hstack((np.random.random((N_PART, 2)), np.zeros((N_PART, 1))))\n",
"\n",
"# Add particles\n",
"particles = system.part.add(pos=pos, rotation=N_PART * [(True, True, True)], dip=dip, fix=N_PART * [(False, False, True)])\n",
"particles = system.part.add(pos=pos, rotation=N_PART * [(True, True, True)],\n",
" dip=dip, fix=N_PART * [(False, False, True)])\n",
"\n",
"# Remove overlap between particles by means of the steepest descent method\n",
"MASS = 1.0\n",
Expand Down Expand Up @@ -270,7 +271,7 @@
"execution_count": null,
"id": "7750295c",
"metadata": {
"scrolled": true
"scrolled": false
},
"outputs": [],
"source": [
Expand Down Expand Up @@ -471,7 +472,8 @@
"pos = box_size * np.hstack((np.random.random((N_PART, 2)), np.zeros((N_PART, 1))))\n",
"\n",
"# Add particles\n",
"particles = system.part.add(pos=pos, rotation=N_PART * [(True, True, True)], dip=dip, fix=N_PART * [(False, False, True)])\n",
"particles = system.part.add(pos=pos, rotation=N_PART * [(True, True, True)],\n",
" dip=dip, fix=N_PART * [(False, False, True)])\n",
"\n",
"# Remove overlap between particles by means of the steepest descent method\n",
"system.integrator.set_steepest_descent(f_max=0, gamma=0.1, max_displacement=0.05)\n",
Expand Down Expand Up @@ -803,7 +805,7 @@
"outputs": [],
"source": [
"def dL_dB(alpha):\n",
" return (1. / (alpha**2.) - 1. / ((np.sinh(alpha))**2.)) * dipm / (KT)"
" return (1. / (alpha**2) - 1. / np.sinh(alpha)**2) * dipm / (KT)"
]
},
{
Expand Down Expand Up @@ -884,8 +886,8 @@
"plt.xlabel(r'$\\alpha$', fontsize=20)\n",
"plt.ylabel(r'$M^*$', fontsize=20)\n",
"plt.plot(x, L(x), label='Langevin function')\n",
"plt.plot(x, magnetization_approx_perp(x), label='q2D approximation $\\perp$')\n",
"plt.plot(x, magnetization_approx_para(x), label='q2D approximation $\\parallel$')\n",
"plt.plot(x, magnetization_approx_perp(x), label=r'q2D approximation $\\perp$')\n",
"plt.plot(x, magnetization_approx_para(x), label=r'q2D approximation $\\parallel$')\n",
"# < exercise >\n",
"plt.legend(fontsize=20)\n",
"plt.show()\n",
Expand All @@ -907,10 +909,10 @@
"plt.xlabel(r'$\\alpha$', fontsize=20)\n",
"plt.ylabel(r'$M^*$', fontsize=20)\n",
"plt.plot(x, L(x), label='Langevin function')\n",
"plt.plot(x, magnetization_approx_perp(x), label='q2D approximation $\\perp$')\n",
"plt.plot(x, magnetization_approx_para(x), label='q2D approximation $\\parallel$')\n",
"plt.plot(alphas, magnetization_perp / N_PART, 'o', label='simulation results $\\perp$')\n",
"plt.plot(alphas, magnetization_para / N_PART, 'o', label='simulation results $\\parallel$')\n",
"plt.plot(x, magnetization_approx_perp(x), label=r'q2D approximation $\\perp$')\n",
"plt.plot(x, magnetization_approx_para(x), label=r'q2D approximation $\\parallel$')\n",
"plt.plot(alphas, magnetization_perp / N_PART, 'o', label=r'simulation results $\\perp$')\n",
"plt.plot(alphas, magnetization_para / N_PART, 'o', label=r'simulation results $\\parallel$')\n",
"plt.legend(fontsize=20)\n",
"plt.show()"
]
Expand Down
8 changes: 4 additions & 4 deletions doc/tutorials/ferrofluid/ferrofluid_part3.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@
"execution_count": null,
"id": "89966f9b",
"metadata": {
"scrolled": true
"scrolled": false
},
"outputs": [],
"source": [
Expand Down Expand Up @@ -334,11 +334,11 @@
"execution_count": null,
"id": "bd24f8eb",
"metadata": {
"scrolled": true
"scrolled": false
},
"outputs": [],
"source": [
"# initialize array for hold the sampled dipole moments\n",
"# initialize array that will hold the sampled dipole moments\n",
"dipms = np.full((loops, 3), np.nan)\n",
"\n",
"# sample dipole moment\n",
Expand Down Expand Up @@ -542,7 +542,7 @@
"id": "395a4fc0-baaf-48d6-8b88-b8ba42408bfe",
"metadata": {},
"source": [
"Additionally, we will visualize the sampling of the magnetization curve using the ZnDraw visualizer. Note, that the magnetic field is increasing during the video."
"Additionally, we will visualize the sampling of the magnetization curve using ZnDraw. Note, that the magnetic field is increasing during the video."
]
},
{
Expand Down
2 changes: 1 addition & 1 deletion doc/tutorials/langevin_dynamics/langevin_dynamics.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@
"id": "933cea77-4bca-47a6-8a82-cc13d07ec673",
"metadata": {},
"source": [
"Now we can do the actual simulation where we simulate for different friction coefficients and sample our observables:"
"Now we can do the actual production run where we simulate for different friction coefficients and sample our observables:"
]
},
{
Expand Down
Loading

0 comments on commit efacee2

Please sign in to comment.