[MMTK] external fields

Konrad Hinsen research at khinsen.fastmail.net
Fri Aug 30 11:09:28 UTC 2013

Richard Graham writes:

 > By my understanding, basically what I need to do is write a new
 > forcefield representing my trapping potential. I will add this to one of
 > the built in force fields and do a molecular dynamics simulation.


 > The force field is something with an evaluatorTerms method that
 > returns something with an evaluate method. This method will need to

True but there are more conditions. For example, a force field must be
a subclass of MMTK.ForceFields.ForceField. That's why it's best to
start from a working force field and modify it.

 > go through everything in the given universe and work out the force
 > based on its position. This then somehow goes in the results dict.

It's not a dictionary, it's a list of Python objects that represent
the computational routines.

The idea behind decomposing the energy evaluation into two steps
(ForceField.evaluatorTerms() and EnergyTerm.evaluate()) is that the
first step needs to be done only once for a universe, whereas the
second one needs to be redone for each configuration. Obviously you
want to do as much of the work as possible in the first step.

For writing a new force field term, I suggest starting by thinking
about what information it depends on and how you would like to provide
it.  What is trapped by your force field? Any atom? A specific atom?
The center of mass of a group of atoms? Next, what is the trap defined
by? A fixed point in space? Another atom or group of atoms? Finally,
what is the functional form of the interaction, which parameters enter
into it, and where do they come from?

Any information other than the universe must be a parameter to your
force field class. Its energyTerms() method should then combine this
information with whatever information you need from the universe,
and package all that in a convenient way for the final step, the
energy evaluator.

 > Do you have any standard interface for the integrator 'actions' objects?

Yes, but it's not really documented. The best starting point is the Cython
module MMTK_trajectory_action.

Note that these actions are completely unrelated to force field
terms. There is no communication between the two, except they both
have access to the current configuration.

 > I noticed that when creating an atom, it seems to get an average mass of
 > all the isotopes. If seems like it would be better for the atom to have
 > a randomly selected isotope weighted by the natural abundances when created.

In theory, that looks like a good approach. In practice, it makes
simulations non-reproducible because all results will vary slightly at
each run due to the different masses. It then becomes rather difficult
to test and debug simulation code.

Note that you can change the mass of each atom after it has been created,
so if you want randomly drawn masses, you can do that.

Konrad Hinsen
Centre de Biophysique Moléculaire, CNRS Orléans
Synchrotron Soleil - Division Expériences
Saint Aubin - BP 48
91192 Gif sur Yvette Cedex, France
Tel. +33-1 69 35 97 15
E-Mail: research AT khinsen DOT fastmail DOT net
ORCID: http://orcid.org/0000-0003-0330-9428
Twitter: @khinsen

More information about the mmtk mailing list