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.    
ops, I started writing this on my laptop where I haven't set eclipse to use
spaces instead of tabs, do you have a script to convert it? (like you did
for everything else)


On Fri, Aug 8, 2014 at 11:21 AM, Jacob Stevenson <notifications@github.com>
wrote:

> In source/pele/inversepower.h:
>
> > +        double E;
> > +        double r0 = _radii[atomi] + _radii[atomj]; //sum of the hard core radii
> > +        double r = std::sqrt(r2);
> > +        if (r >= r0)
> > +            E = 0.;
> > +        else
> > +        	E = std::pow((1 -r/r0), _pow) * _eps/_pow;
> > +
> > +        return E;
> > +    }
> > +
> > +    /* calculate energy and gradient from distance squared, gradient is in -(dv/drij)/|rij| */
> > +    double energy_gradient(double r2, double *gij, size_t atomi, size_t atomj) const
> > +    {
> > +    	double E;
> > +		double r0 = _radii[atomi] + _radii[atomj]; //sum of the hard core radii
>
> something is wrong with formatting. Did you use tabs?
>
> —
> Reply to this email directly or view it on GitHub
> <https://github.com/pele-python/pele/pull/59/files#r15986243>.
>