hybrid monte carlo and cp2k

421 views
Skip to first unread message

Alin Marin Elena

unread,
Jun 21, 2011, 12:56:58 PM6/21/11
to cp...@googlegroups.com
Hi,

I try to use the hybrid monte-carlo from cp2k...
I have found the hmc.inp from tests.
Is there any reference, specific to the cp2k implementation, about HMC where I
can read the details?

regards,
Alin
--
Without Questions there are no Answers!
_____________________________________________________________________
Alin Marin ELENA
Advanced Molecular Simulation Research Laboratory
School of Physics, University College Dublin
----
Ardionsamblú Móilíneach Saotharlann Taighde
Scoil na Fisice, An Coláiste Ollscoile, Baile Átha Cliath

-----------------------------------------------------------------------------------
http://alin.elenaworld.net
______________________________________________________________________

signature.asc

Matt McGrath

unread,
Jun 22, 2011, 1:02:00 AM6/22/11
to cp2k
Hi Alin.

Good question. HMC is something I've just recently implemented. I've
tested it to make sure it samples correctly, but I've noticed too that
it's not the easiest to use, unless you happen to be the person who
wrote the MC routines (and even then, new issues pop up sometimes).

In theory, if you want to sample in the canonical ensemble, hmc.inp
has everything you should need. You can ignore all the MC part except
for TEMPERATURE and NSTEPS, which should be self-explanatory. The MD
part is a simulation in the microcanonical ensemble, and the
temperature should be set to the same value as the MC. You can choose
the number of MD steps you want to run in each mini-trajectory, and
then adjust the timestep so that your acceptance ratio (given in the
input.inp.moves file on the line HMC) is about 0.7. Weber et al, J
Chem Phys (2010), 204509 is a recent article that talks a little about
this.

If you use just the canonical ensemble, you can delete the TOPOLOGY
section (this is required by all other MC simulations, for reasons
that displacements have to be defined for every molecule type). This
makes things much easier. However (and this is a problem that came up
just two days ago), this means you can't do a restart. So every time
a simulation dies (due to walltime, for example), you'd need to copy
the coordinates from mc_restart_1 into the input file. The step
number would always reset, too. Not nice, but doable. So, if your
system is a relatively simple molecular system, I can probably walk
you through what needs to be done. The only changes you'll need to
make are those mentioned above. If you want to use restart, then you
have to make psf files for each molecule type and specify them in the
MOL_SET section (some of the other input files has what's needed for
multiple molecule types, although there are always caveats). This
could be simple, or it could be complex, depending on your system.

Basically, the MC routines were mostly written several years ago, and
since then CP2K has changed. I am starting to look at the routines so
that I can change them to be much more up-to-date with the rest of the
code (the biggest problem is changing the number of molecules in a
force environment....as far as I know, there still isn't a subroutine
to do this, and I don't feel confident with the FIST/QS sections of
the code to do it myself...yet). Once this happens, all the MC
routines will probably get a massive make-over to make them more
useable (more like the rest of CP2K), including proper print keys and
restart files.

I hope that you do try it, because I'd like the feedback.

Cheers, Matt
>  signature.asc
> < 1KViewDownload

Alin Marin Elena

unread,
Jun 23, 2011, 6:19:10 AM6/23/11
to cp...@googlegroups.com
Hi Matt,

Thank you very much for you fast and detailed answer.
I read the HMC part from the paper that you suggested, thank you, it made some
things clearer on what is implemented in cp2k...

> Good question. HMC is something I've just recently implemented. I've
> tested it to make sure it samples correctly, but I've noticed too that
> it's not the easiest to use, unless you happen to be the person who
> wrote the MC routines (and even then, new issues pop up sometimes).

they are not so bad... I just want to be sure that I do not miss things that
can bite me later.

Is there any pilot study you can point me to for the 0.7 acceptance rate for
the HMC? I know that the MC schemes efficiency tends to be connected with the
acceptance rate.

What I want to sample is indeed a canonical ensemble. The MD part will be DFT,
so now you may understand my worry on efficiency.
My system is simple, 23 atoms I do not care about the molecules, so I created
a topology file that puts all of them in one "macro-molecule". I attached my
input files, so any feedback is much appreciated...


Now what I try to do... I try to use a metadynamics run with CV and forces
coming from DFT.
The acceptance hamiltonian is the one coming from the all system (atoms+CVs)
but the trajectories for MD are evolved using only the physical forces.

I was wondering if that is possible to do it in the current state of cp2k or
should I define my own type of dynamics?

hmc.tar.bz2
signature.asc

Matt McGrath

unread,
Jun 24, 2011, 2:15:31 AM6/24/11
to cp2k
Hi Alin.

On Jun 23, 7:19 pm, Alin Marin Elena <alinm.el...@gmail.com> wrote:
> Hi Matt,
>
> Thank you very much for you fast and detailed answer.
> I read the HMC part from the paper that you suggested, thank you, it made some
> things clearer on what is implemented in cp2k...
>
> > Good question.  HMC is something I've just recently implemented.  I've
> > tested it to make sure it samples correctly, but I've noticed too that
> > it's not the easiest to use, unless you happen to be the person who
> > wrote the MC routines (and even then, new issues pop up sometimes).
>
> they are not so bad... I just want to be sure that I do not miss things that
> can bite me later.
>
> Is there any pilot study you can point me to for the 0.7 acceptance rate for
> the HMC? I know that the MC schemes efficiency tends to be connected with the
> acceptance rate.

Unfortunately, I can't find any studies that say that. It just seems
to be what is currently used in the literature. You're right,
acceptance ratio really impacts your sampling. The conventional
wisdom in the field is to aim for 50% for moves involving the
Metropolis acceptance ratio, 50% for volume moves (though 30-40 is
good for equilibration), and various guidelines for other move types,
although even these are not set in stone (I've seen arguments for
lower acceptance ratios in translations/rotations, for example, even
as low as 25%). In the end, all you can do is monitor your system and
see when it's equilibrated (according to density, energy, or
whatever). On the plus side, a bad acceptance ratio doesn't lead to
the wrong answer...it just might make you get there slower.

>
> What I want to sample is indeed a canonical ensemble. The MD part will be DFT,
> so now you may understand my worry on efficiency.
> My system is simple, 23 atoms I do not care about the molecules, so I created
> a topology file that puts all of them in one "macro-molecule". I attached my
> input files, so any feedback is much appreciated...
>

I took a look at your input file, and I can't see any obvious
problems. I am, however, not the ideal person to comment on the DFT
parameters (I generally rely on other smart people for that :) ). I
have had it recommended to me to use FULL_ALL as the preconditioner
and PS 3 to speed up the MD part, although the first calculation in
any sequence is always going to take more time if the HMC move was
rejected.

> Now what I try to do... I try to use a metadynamics run with CV and forces
> coming from DFT.
> The acceptance hamiltonian is the one coming from the all system (atoms+CVs)
> but the trajectories for MD are evolved using only the physical forces.
>
> I was wondering if that is possible to do it in the current state of cp2k or
> should I define my own type of dynamics?

I'm not seeing how that could work at the moment, theoretically or
practically. It would take some time for me to understand
metadynamics (coincidentally, I am just starting a metadynamics
project), so I'm guessing that it's nothing that will happen soon
(bigger priority is to clean up the MC routines). Is there a big
reason why you want to do this over regular MD with meta? I'm not
seeing the advantage, honestly, and I don't see how you would include
metadynamics when your MD run is just a regular NVE (if I'm
understanding you correctly).

Cheers, Matt

>
> regards,
> Alin
> --
>  Without Questions there are no Answers!
>  _____________________________________________________________________
>   Alin Marin ELENA
>   Advanced Molecular Simulation Research Laboratory
>   School of Physics, University College Dublin
>   ----
>   Ardionsamblú Móilíneach Saotharlann Taighde
>   Scoil na Fisice, An Coláiste Ollscoile, Baile Átha Cliath
>
>   --------------------------------------------------------------------------- --------
>  http://alin.elenaworld.net
>   ______________________________________________________________________
>
>  hmc.tar.bz2
> 319KViewDownload
>
>  signature.asc
> < 1KViewDownload

Alin Marin Elena

unread,
Jun 28, 2011, 3:49:16 AM6/28/11
to cp...@googlegroups.com

Hi Matt,

 

Thank you very much for you answer and for your tips on both HMC and the input file.

 

here is what I have to do with hybrid MC. I have to run simulations "à la"

metadynamics (the technique I am going to use is Temperature Accelered Monte Carlo, TAMC -- G Ciccotti, S Meloni, Physical Chemistry Chemical Physics, 353, 1-15, (2011)) in which I deal with an extended system composed of the atoms + a set of collective variables. These two subset are coupled by a suitable potential. In TAMC, similarly than in metadynamics, these two subset are evolved together but the inertia of the collective variables, or other parameters controlling the timescale of the dynamics (e.g. the parameters of the thermostat), are selected such that the atoms are faster than the collective variables (adiabatic condition). At a variance with metadynamics, I use two thermostats at different temperatures for the atoms and the collective variables (it is the high temperature on the collective variables that allow to overcome the free energy barriers possibly present in the system). It can be demonstrated that the dynamical system described above samples the "marginal" probability density function that the collective variables assume a given value, and from this I can reconstruct the free energy of the system along these collective variables. in metadynamics (and Temperature Accelerated Molecular Dynamics, driven Adiabatic Free Energy Dynamics, etc.) the above sampling is performed running MD on both the atoms and the collective variables. However, if the collective variables are not analytical I cannot compute the force on the atoms coming from the "coupling potential" associated to them. This can be solved replacing MD for the evolution of the atoms with MC (in metadynamics and similar techniques we use MD only to sample the probability density function of the considered ensemble and so we can safely replace it with any sampling technique). My problem is that I need to do this by ab initio simulations (there are bonds broken and formed in the process I am investigating) and in this case the standard MC is quite inefficient: I move one atom and have to perform an SCF cycle (...it will converge faster BUT NOT N times faster, where N is the number of atoms in the sample). So, I intend to use hybrid MC, which moves all the atom together,  to improve the efficiency. This is what I need to do and why I have to combine HMC with quickstep.

 

From my reading of the code I think I will have to add a new run mode to cater for my needs... am I right?

 

regards,

Alin

signature.asc

Matt McGrath

unread,
Jun 29, 2011, 2:57:32 AM6/29/11
to cp2k
Hello Alin.

Ah, I am starting to see now. I agree with the thoughts on HMC; this
is actually why I put it into CP2K. Previously, I used pre-biasing
with an approximate potential to make MC more efficient (you can see
any of my papers about first principles Monte Carlo on water and
hydrogen fluoride for the details). That worked somewhat, but I was
hoping HMC would be better (doesn't seem like it is, according to some
constant pressure simulations we've run, which surprises me...maybe
because the pre-biasing potential is "free" compared to the QS
calculation and the displacements are larger...on a per QS calculation
basis, there doesn't seem to be a significant speedup at the the
moment, although the MD energy calculations can be made less expensive
with various extrapolation techniques).

As for this calculation, it seems quite interesting. From that paper,
it appears almost like you're doing a reverse HMC; using an MC run to
sample part of an MD run, instead of the other way around. Since this
is a free energy technique with MD as the driver, I think it would be
better to treat it like metadynamics, and create a section in
&FREE_ENERGY for it. Ideally, at least. In principle, because it
seems like an MD run that calls MC which calls MD again, maybe it
would be more useful (and faster to have working) if you have your own
MD code and just treat HMC as a library call? Have you considered
this at all? I would hesitate to add another RUN_TYPE option, since
it seems like the basic elements (MD and MC) are already in CP2K as
high level options.

Cheers, Matt
> > > ---- --------http://alin.elenaworld.net
> > >   ______________________________________________________________________
>
> > >  hmc.tar.bz2
> > > 319KViewDownload
>
> > >  signature.asc
> > > < 1KViewDownload
>
> --
>  Without Questions there are no Answers!
>  _____________________________________________________________________
>   Alin Marin ELENA
>   Advanced Molecular Simulation Research Laboratory
>   School of Physics, University College Dublin
>   ----
>   Ardionsamblú Móilíneach Saotharlann Taighde
>   Scoil na Fisice, An Coláiste Ollscoile, Baile Átha Cliath
>
>   --------------------------------------------------------------------------- --------
>  http://alin.elenaworld.net
>   ______________________________________________________________________
>
>  signature.asc
> < 1KViewDownload
Reply all
Reply to author
Forward
0 new messages