[MMTK] Monte Carlo simulation

konrad.hinsen at laposte.net konrad.hinsen at laposte.net
Thu Feb 24 20:45:27 CET 2005

On 24.02.2005, at 19:53, Shirley Siu wrote:

> it. I read the example "backbone.py", but I am not quite sure about  
> this
> line in the loop:
>  conf = conf + gaussian(0., 0.5)*modes[j]
> 1. generate a random value using gaussian()
> 2. scale all the modes with different random value
> 3. add up all the changes


> in this case, the new configuration is a multiple changes of the  
> original
> configuration. (not sure if i am correct?) however, if I only want to  
> make

This script is not about changes at all, in the sense of e.g.  
Metropolis sampling. It is a random configuration generator. At every  
step, it creates a new configuration that is independent of the  
previous ones.

> one change in the configuration (change one bond, e.g.), what is the
> proper way of doing it?

If you want to change internal coordinates, use the new module  
MMTK.InternalCoordinates (in the 2.5.x series). However, you should be  
aware that those operations are rather slow (compared to changes in  
Cartesian coordinates) because they try to maintain the molecule at the  
same place and in the same orientation. You might be able to do  
something faster but specific to your application.

Note also that individual changes in internal coordinates are  
reasonable steps (in terms of efficiency) only for very small  
molecules. There has been some discussion in the literature about  
choosing steps in Monte-Carlo procedures for macromolecules.

> Another question, this is not related to MMTK, but I hope somebody here
> may help too: I get this error when calculate p=Numeric.exp(-B*deltaE)
>    "OverflowError: math range error"
> Any idea of how to deal with it?

This is a feature that Python inherits from the C Math library. On some  
systems, underflows are considered errors, on others not.

I have seen this behaviour under AIX and Linux, and in both cases the  
solution is to link the Python interpreter with the ieee math library.  
That will automatically take care of add-on modules as well. There are  
many ways to do this, the choice depends mostly on your familiarity  
with the Python build procedure.

My standard procedure is to build Python from the source code, then  
edit "Makefile" to add "-lieee" to the macro "LIBM", erase the  
executable "python" and type "make" again. Another solution is to pick  
the last command from the make protocol (the one that produces the  
Python interpreter) and copy-paste it into a terminal window, then add  
"-lieee" after "-lm" and execute it. I am sure there is also an elegant  
and official way by editing the autoconf files, but I am not ambitious  
enough to look into that!

Konrad Hinsen
Laboratoire Leon Brillouin, CEA Saclay,
91191 Gif-sur-Yvette Cedex, France
Tel.: +33-1 69 08 79 25
Fax: +33-1 69 08 82 61
E-Mail: khinsen at cea.fr

More information about the mmtk mailing list