[MMTK] external fields

Konrad Hinsen research at khinsen.fastmail.net
Wed Aug 28 07:30:54 UTC 2013

--On 27 août 2013 14:33:11 -0700 Richard Graham <richard at rdg.cc> wrote:

> I am intending to add an external trapping field to a universe, so
> basically I need to be able to write a function to calculate a
> force/charge vector as a function of position. Seems like that should
> not be to difficult..
> I would appreciate if anyone could point me in the right direction.

MMTK has no built-in force field term for external fields, but MMTK was 
designed to make it easy to add new force field terms.

The best starting point for your problem is the "ElectricField" example, 
which is in the MMTK source code distribution 
(Examples/Forcefields/ElectricField). There are three implementations 
(Python, Cython, C), which are equivalent in effect but differ in 
convenience of coding and in performance. You should probably start with 
the Python version, which is the most straightforward one. If you need 
better performance, move on to the Cython version. The C version is of 
interest only if you want to integrate existing C code into an MMTK force 
field, and even then I'd rather use Cython nowadays.


More information about the mmtk mailing list