-
Notifications
You must be signed in to change notification settings - Fork 189
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add tutorial on GCMC #4670
Add tutorial on GCMC #4670
Conversation
Check out this pull request on See visual diffs & provide feedback on Jupyter Notebooks. Powered by ReviewNB |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a very well written tutorial. I have a bunch of minor comments, the only thing major is that after the last plot, the physics should be discussed in more detail to interpret the main result.
Otherwise: Thanks a lot, well done
"source": [ | ||
"## Grand-Canonical Ensemble\n", | ||
"The case of changing particle numbers is best described by the grand canonical ensemble <a href='#[1]'>[1]</a>.\n", | ||
"In the grand canonical ensemble, the volume $V$, the temperature $T$ and the chemical potentials $\\mu_i$ of the exchangeable species $i$ rather than the particle numbers $N_i$ are fixed.The chemical potentials $\\mu_i$correspond to the free energy cost of adding a particle of type $i$ while keeping everything else fixed:\n", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
missing space in last sentence
"The grand canonical ensemble is thus also referred to as the $(\\mu, V, T)$-ensemble.\n", | ||
"In the grand canonical ensemble, the probability for the system to contain $N_i$ particles of type $i$, i.e. a total of $N=\\sum_{i=1}^{N_\\mathrm{s}}N_i$ and to be in a specific microstate $\\xi\\in\\Gamma_{N}$ is given by the probability distribution\n", | ||
"\\begin{align}\n", | ||
"p^\\mathrm{G}\\left(\\left\\{N_i\\right\\},\\xi\\right) = \\frac{\\exp\\left(-\\beta \\left(H(\\xi)-\\sum_{i=1}^{N_\\mathrm{s}}\\mu_iN_i\\right)\\right)}{Z^\\mathrm{G}h^{3N}\\prod_{i=1}^{N_\\mathrm{s}} N_i!}. \\quad \\tag{1}\n", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
define N_s
"\\end{align}\n", | ||
"Here, $H$ denotes the Hamiltonian of the system with $N_i$ particles of type $i$ and $Z^\\mathrm{G}$ is the grand-canonical partition function which is given by\n", | ||
"\\begin{align}\n", | ||
"Z^\\mathrm{G}\\left(\\left\\{\\mu_i\\right\\},V,T\\right) = \\sum_{N_1=0}^{\\infty}...\\sum_{N_\\mathrm{s}=0}^{\\infty}Z\\left(\\left\\{N_i\\right\\},V,T\\right)\\exp\\left(\\beta \\sum_{i=1}^{N_\\mathrm{s}}\\mu_iN_i\\right).\n", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
define Z
"\\mu_i^{\\mathrm{sys}} = \\mu_i^{\\mathrm{res}}.\n", | ||
"\\end{equation}\n", | ||
"This condition is referred to as a chemical equilibrium between the two phases and is equivalent to a minimization of the free energy of the total system (system + reservoir).\n", | ||
"In the case where one requires electroneutrality of the phases, due to the additional constraint, the electrochemical potential $\\overline{\\mu}_i=\\mu_i+z_ie\\psi$ rather than the chemical potential has to be equal." |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
define z, e, psi
"\\frac{P_{i\\rightarrow j}^\\mathrm{acc}}{P_{j\\rightarrow i}^\\mathrm{acc}} = \\frac{p_j^\\mathrm{eq}}{p_i^\\mathrm{eq}}. \n", | ||
"\\quad \\tag{6}\n", | ||
"\\end{align}\n", | ||
"It is easy to see that the acceptance probability \n", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
avoid such phrases to not discourage beginners
"name": "stderr", | ||
"output_type": "stream", | ||
"text": [ | ||
"100%|██████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 50/50 [00:04<00:00, 11.72it/s]" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove output from tutorial before commiting/pushing
" K_XX =salt_concentration ** 2 * np.exp(excess_chemical_potential_monovalent_pairs_in_bulk(salt_concentration))\n", | ||
" RE.change_reaction_constant(gamma= K_XX,reaction_id = 0)\n", | ||
" for i in tqdm(range(warmup_loops),bar_format='{l_bar}{bar:60}{r_bar}{bar:-60b}'):\n", | ||
" system.integrator.run(1000)\n", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe give these numbers as predefined variables
}, | ||
"source": [ | ||
"**Exercise**\n", | ||
"* Plot the universal partition coeffiecients obtained by measuring the partition coefficient $\\xi_-$ and $\\xi_+$ in the simulation against $c_{\\mathrm{M}^-}/(2c_{\\mathrm{salt}}^{\\mathrm{res}})$\n", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not sure plotting is a meaningful exercise
"source": [ | ||
"**Exercise**\n", | ||
"* Plot the universal partition coeffiecients obtained by measuring the partition coefficient $\\xi_-$ and $\\xi_+$ in the simulation against $c_{\\mathrm{M}^-}/(2c_{\\mathrm{salt}}^{\\mathrm{res}})$\n", | ||
"* Interpret the deviation of the simulation results from the ideal prediction." |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
there should definitely be a solution to this question
"<figcaption>Fig. 1: Schematic representation of the considered two phase setup.</figcaption>\n", | ||
"</center>\n", | ||
"</figure>\n", | ||
"Here we want to investigate a polyelectrolyte solution that is coupled to a reservoir containing a monovalent salt, as shown schematically in figure 1. The small salt ions (X$^+$ and X$^-$) can be exchanged between the two phases while the polyelectrolyte is confined to the system. Experimentally such a setup could be realized by seperating the two phases with a semi-permeable membrane. Similiar setups also occur in the study of polyelectrolyte hydrogels.\n", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe add a sentence on the relevance/usefulness of this system
Thank you for your review and your annotations. I have now worked in your annotations and added an interpretation of the final plot. In addition I have changed the sample sizes a bit to speed up the runtimes. |
Looks really nice now, thanks for the work you put in. |
|
Reduce sampling times. Improve testing. Redesign plots.
Fixes #4575
Description of changes: