Skip to content

Commit ac66598

Browse files
committed
cleaned free sampling, added ref
1 parent b5c8ca9 commit ac66598

3 files changed

Lines changed: 64 additions & 43 deletions

File tree

files/tutorial7/free-sampling.lmp

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
2+
variable sigma equal 3.405
3+
variable epsilon equal 0.238
4+
variable U0 equal 1.5*${epsilon}
5+
variable dlt equal 1.0
6+
variable x0 equal 10.0
7+
8+
units real
9+
atom_style atomic
10+
pair_style lj/cut 3.822
11+
pair_modify shift yes
12+
boundary p p p
13+

journal-article.bib

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -747,6 +747,17 @@ @article{mills1955remeasurement
747747
publisher={ACS Publications}
748748
}
749749

750+
@article{hayatifar2024probing,
751+
title={Probing atomic-scale processes at the ferrihydrite-water interface with reactive molecular dynamics},
752+
author={Hayatifar, Ardalan and Gravelle, Simon and Moreno, Beatriz D and Schoepfer, Valerie A and Lindsay, Matthew BJ},
753+
journal={Geochemical Transactions},
754+
volume={25},
755+
number={1},
756+
pages={10},
757+
year={2024},
758+
publisher={Springer}
759+
}
760+
750761
@article{della1992molecular,
751762
title={Molecular dynamics simulation of silica liquid and glass},
752763
author={Della Valle, Raffaele Guido and Andersen, Hans C},

lammps-tutorials.tex

Lines changed: 40 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -3547,8 +3547,8 @@ \subsection{Tutorial 7: Free energy calculation}
35473547
area in the middle of the simulation box without needing to simulate additional atoms.
35483548
The procedure is valid for more complex systems and can be adapted to many other
35493549
situations, such as measuring adsorption barriers near an interface or calculating
3550-
translocation barriers through a membrane
3551-
\cite{wilson1997adsorption, makarov2009computer, gravelle2021adsorption, loche2022molecular}.
3550+
translocation barriers through a membrane \cite{wilson1997adsorption, makarov2009computer,
3551+
gravelle2021adsorption, loche2022molecular, hayatifar2024probing}.
35523552

35533553
\subsubsection{Method 1: Free sampling}
35543554
The most direct way to calculate a free energy profile is to extract the partition
@@ -3561,7 +3561,7 @@ \subsubsection{Method 1: Free sampling}
35613561
where $\Delta G$ is the free energy difference, $R$ is the gas constant, $T$
35623562
is the temperature, $p$ is the pressure, and $p_0$ is a reference pressure.
35633563
As an illustration, let us apply this method to a simple configuration
3564-
that consists of a few particles diffusing in a box in the presence of a
3564+
that consists of a particles in a box in the presence of a
35653565
position-dependent repulsive force that makes the center of the box a less
35663566
favorable area to explore.
35673567

@@ -3574,8 +3574,8 @@ \subsubsection{Method 1: Free sampling}
35743574
variable sigma equal 3.405
35753575
variable epsilon equal 0.238
35763576
variable U0 equal 1.5*${epsilon}
3577-
variable dlt equal 0.5
3578-
variable x0 equal 5.0
3577+
variable dlt equal 1.0
3578+
variable x0 equal 10.0
35793579

35803580
units real
35813581
atom_style atomic
@@ -3599,7 +3599,7 @@ \subsubsection{Method 1: Free sampling}
35993599
Let us define the simulation box and randomly add atoms by addying the
36003600
following lines to \flecmd{free-energy.lmp}:
36013601
\begin{lstlisting}
3602-
region myreg block -25 25 -5 5 -25 25
3602+
region myreg block -50 50 -15 15 -50 50
36033603
create_box 1 myreg
36043604
create_atoms 1 random 200 34134 myreg overlap 3 maxtry 50
36053605

@@ -3634,7 +3634,7 @@ \subsubsection{Method 1: Free sampling}
36343634
\includegraphics[width=\linewidth]{US-potential}
36353635
\caption{Potential $U$ given in Eq.\,\eqref{eq:U} (a) and force $F$ given in
36363636
Eq.\,\eqref{eq:F} (b) as a function of the coordinate $x$. Here,
3637-
$U_0 = 0.36~\text{kcal/mol}$, $\delta = 0.5~\mathrm{\AA{}}$, and $x_0 = 5~\mathrm{\AA{}}$.}
3637+
$U_0 = 0.36~\text{kcal/mol}$, $\delta = 1.0~\mathrm{\AA{}}$, and $x_0 = 10~\mathrm{\AA{}}$.}
36383638
\label{fig:potential}
36393639
\end{figure}
36403640

@@ -3651,15 +3651,16 @@ \subsubsection{Method 1: Free sampling}
36513651
Next, we combine the \lmpcmd{fix nve} with a \lmpcmd{fix langevin} thermostat:
36523652
\begin{lstlisting}
36533653
fix mynve all nve
3654-
fix mylgv all langevin 119.8 119.8 50 30917
3654+
fix mylgv all langevin 119.8 119.8 500 30917
36553655
\end{lstlisting}
36563656
When combining these two commands, the MD simulation operates
36573657
in the NVT ensemble, maintaining a constant number of
36583658
atoms $N$, constant volume $V$, and a temperature $T$ that
36593659
fluctuates around a target value.
3660+
% SG: may be discuss the choice of constant "500" --> chosen for a relatiely weak coupling with thermostat (add a box?)
36603661

36613662
To ensure that the equilibration time is sufficient, we will track the evolution of
3662-
the number of atoms in the central (energetically unfavorable) region,
3663+
the number of atoms in the central -- energetically unfavorable -- region,
36633664
referred to as \lmpcmd{mymes}, using the \lmpcmd{n\_center} variable:
36643665
\begin{lstlisting}
36653666
region mymes block -${x0} ${x0} INF INF INF INF
@@ -3668,41 +3669,44 @@ \subsubsection{Method 1: Free sampling}
36683669
thermo 10000
36693670

36703671
dump viz all image 50000 myimage-*.ppm type type &
3671-
shiny 0.1 box yes 0.01 view 180 90 zoom 7 size 1600 400
3672-
dump_modify viz backcolor white acolor 1 cyan adiam 1 1 &
3673-
boxcolor black
3672+
shiny 0.1 box yes 0.01 view 180 90 zoom 6 &
3673+
size 1600 500 fsaa yes
3674+
dump_modify viz backcolor white acolor 1 cyan &
3675+
adiam 1 3 boxcolor black
36743676
\end{lstlisting}
3675-
A \lmpcmd{dump image} command was added for system visualization.
3677+
A \lmpcmd{dump image} command was also added for system visualization.
36763678

3677-
Finally, let us perform an equilibration of 500000 steps
3678-
in total, using a timestep of $2\,\text{fs}$ (i.e.~a total duration of $1\,\text{ns}$):
3679+
Finally, let us perform an equilibration of 50000 steps,
3680+
using a timestep of $2\,\text{fs}$, corresponding to a total duration of $100\,\text{ps}$:
36793681
\begin{lstlisting}
36803682
timestep 2.0
3681-
run 500000
3683+
run 50000
36823684
\end{lstlisting}
3683-
Run the simulation with LAMMPS. The number of atoms in the
3685+
Run the simulation with LAMMPS. The number of atoms in the
36843686
central region, $n_\mathrm{center}$, reaches
3685-
its equilibrium value after approximately $500\,\text{ps}$
3687+
its equilibrium value after approximately $40\,\text{ps}$
36863688
(Fig.\,\ref{fig:US-density-evolution}). A snapshot of the
36873689
equilibrated system is shown in Fig.\,\ref{fig:US-system-unbiased}.
36883690

36893691
\paragraph{Run and data acquisition}
36903692

36913693
Once the system is equilibrated, we will record the density profile of
3692-
the atoms along the $x$ axis using the \lmpcmd{ave/chunk} command. A total
3693-
of 10 density profiles will be printed. Add the following line to \flecmd{free-energy.lmp}:
3694+
the atoms along the $x$ axis using the \lmpcmd{ave/chunk} command.
3695+
Add the following line to \flecmd{free-energy.lmp}:
36943696
\begin{lstlisting}
36953697
reset_timestep 0
36963698

3697-
compute cc1 all chunk/atom bin/1d x 0.0 1.0
3698-
fix myac all ave/chunk 10 400000 4000000 &
3699+
thermo 200000
3700+
3701+
compute cc1 all chunk/atom bin/1d x 0.0 2.0
3702+
fix myac all ave/chunk 100 20000 2000000 &
36993703
cc1 density/number file free-sampling.dat
37003704

3701-
run 4000000
3705+
run 2000000
37023706
\end{lstlisting}
37033707
The step count is reset to 0 using \lmpcmd{reset\_timestep} to synchronize it
3704-
with the output times of \lmpcmd{fix density/number}. Increase the
3705-
duration of the last run to obtain a better-resolved density profile.
3708+
with the output times of \lmpcmd{fix density/number}. Run the simulation using
3709+
LAMMPS.
37063710

37073711
\begin{figure}
37083712
\centering
@@ -3717,44 +3721,37 @@ \subsubsection{Method 1: Free sampling}
37173721
\paragraph{Data analysis}
37183722

37193723
Once the simulation is complete, the density profile shows that the density in the center of the box is
3720-
about two orders of magnitude lower than inside the reservoir (Fig.\,\ref{fig:US-density}).
3724+
about two orders of magnitude lower than inside the reservoir (Fig.\,\ref{fig:US-density}\,a).
37213725
Next, we plot $-R T \ln(\rho/\rho_\mathrm{bulk})$ (i.e.~Eq.\,\eqref{eq:G} where
37223726
the pressure ratio $p/p_\mathrm{bulk}$ is replaced by the density ratio
37233727
$\rho/\rho_\mathrm{bulk}$, assuming the system behaves as an ideal gas) and compare it
3724-
with the imposed potential $U$ from Eq.\,\eqref{eq:U} (Fig.\,\ref{fig:US-FreeSampling}).
3725-
The reference density, $\rho_\text{bulk} = 0.0033~\text{\AA{}}^{-3}$,
3728+
with the imposed potential $U$ from Eq.\,\eqref{eq:U} (Fig.\,\ref{fig:US-density}\,b).
3729+
The reference density, $\rho_\text{bulk} = 0.0009~\text{\AA{}}^{-3}$,
37263730
was estimated by measuring the density of the reservoir from the raw density
3727-
profiles. The agreement between the MD results and the imposed energy profile
3728-
is reasonable, despite some noise in the central part, where fewer data points
3731+
profiles. The agreement between the MD results and the imposed energy profile
3732+
is excellent, despite some noise in the central part, where fewer data points
37293733
are available due to the repulsive potential.
37303734

37313735
\begin{figure}
37323736
\centering
37333737
\includegraphics[width=\linewidth]{US-system-unbiased}
37343738
\caption{Snapshot of the system. The density of atoms is lowest in the central
37353739
part of the box, \lmpcmd{mymes}, due to the additional force $F$. Here,
3736-
$U_0 = 0.36~\text{kcal/mol}$, $\delta = 0.5~\mathrm{\AA{}}$, and $x_0 = 5~\mathrm{\AA{}}$.}
3740+
$U_0 = 0.36~\text{kcal/mol}$, $\delta = 1.0~\mathrm{\AA{}}$, and $x_0 = 10~\mathrm{\AA{}}$.}
37373741
\label{fig:US-system-unbiased}
37383742
\end{figure}
37393743

37403744
\begin{figure}
37413745
\centering
37423746
\includegraphics[width=\linewidth]{US-density}
3743-
\caption{Fluid density $\rho$ along the $x$ direction. Here,
3744-
$U_0 = 0.36~\text{kcal/mol}$, $\delta = 0.5~\mathrm{\AA{}}$, $x_0 = 5~\mathrm{\AA{}}$,
3745-
and the reference density is $\rho_\text{bulk} = 0.0033~\text{\AA{}}^{-3}$.}
3747+
\caption{a) Fluid density $\rho$ along the $x$ direction.
3748+
b) Potential $U$ as a function of $x$ measured using free sampling (blue disks)
3749+
compared to the imposed potential given in Eq.\,\eqref{eq:U} (dark line).
3750+
Here, $U_0 = 0.36~\text{kcal/mol}$, $\delta = 1.0~\mathrm{\AA{}}$, $x_0 = 10~\mathrm{\AA{}}$,
3751+
and the measured reference density in the reservoir is $\rho_\text{bulk} = 0.0009~\text{\AA{}}^{-3}$.} % SG: check units of rho bulk
37463752
\label{fig:US-density}
37473753
\end{figure}
37483754

3749-
\begin{figure}
3750-
\centering
3751-
\includegraphics[width=\linewidth]{US-FreeSampling}
3752-
\caption{Potential $U$ as a function of $x$ measured using free sampling (blue disks)
3753-
compared to the imposed potential given in Eq.\,\eqref{eq:U} (dark line). Here,
3754-
$U_0 = 0.36~\text{kcal/mol}$, $\delta = 0.5~\mathrm{\AA{}}$, and $x_0 = 5~\mathrm{\AA{}}$.}
3755-
\label{fig:US-FreeSampling}
3756-
\end{figure}
3757-
37583755
\paragraph{The limits of free sampling}
37593756

37603757
Increasing the value of $U_0$ reduces the average number of atoms in the central

0 commit comments

Comments
 (0)