[MMTK] creating new ForceField

konrad.hinsen at cea.fr konrad.hinsen at cea.fr
Thu May 18 09:29:27 CEST 2006


On 17.05.2006, at 21:37, Andrey Khavryuchenko wrote:

> I'm trying to create new force field using PyQuante package.
>
> As far as I've got from reading docs and source code, I have to define
> 'evaluatorTerms' in the class, derived from ForceField.  However,  
> there's
> no documentation on this method.
>
> Studying the source code and provided examples show that this  
> method has to return a list of evaluators.

Right.

> But my code never ever reaches the evaluator....

What did you do to use your force field?

> def py_evaluator():
>     print 'here'
>     return
>
> class RhfForceField(ForceField.ForceField):
>     def __init__(self):
>         ForceField.ForceField('Restricted Hartree Fock')
>         return
>
>     def evaluatorTerms(self, universe, subset1, subset2, global_data):
>         return [py_evaluator]

That's basically what you need to do. However, the low-level  
evaluator must have a C interface, a Python fonction won't do.

I suggest you look at a recent development release (2.5.x) for two  
simple examples. They are in Examples/Forcefield/ElectricField and  
Examples/Forcefield/HarmonicOscillator, or here on the Web:

http://sourcesup.cru.fr/cgi/viewcvs.cgi/branches/development/Examples/ 
Forcefield/?root=mmtk

Each example is provided in three versions: a C implementation, a  
Pyrex implementation, and a Python implementation. The Python  
implementation would be the ideal starting point for your project.  
Note however that there is a yet unresolved problem with it: when  
called from a minimizer or integrator, evaluators implemented in  
Python tend to crash on at least some platforms and some Python  
versions. I have no idea what causes these crashes, nor enough time  
at the moment to investigate much.

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





More information about the mmtk mailing list