pele-python/pele — pull request #59 by smcantab (2014-08-08 09:40:06+00:00)
Title: Inverse power potential

Implemented an inverse power potential to simulate systems of (polydisperse) soft spheres. This includes for example Hookean interactions (pow=2) and Hertzian interaction (pow=2.5).

This implementation is using STL pow for all exponents. Performance wise this may not be the fastest possible implementation, for instance using exp(pow*log) could be faster (twice as fast according to some blogs). Another possibility is to make the power a template parameter and then write template specialisations for the most common exponents, this however makes the interface with python ugly because cython does not deal well with template integer/double parameter yet.

So in the interest of simplicity I would keep the implementation as is for now, maybe we should consider a function that calls exp(pow*log) though, this should be carefully benchmarked though as my guess is that the improvement is going to be marginal and will depend on the architecture (how well pow, exp and log can be optimized on a given architecture).

If you have any experience with pow please suggest any better solution.