pele-python/pele — pull request #108 by js850 (2014-12-05 16:17:46+00:00)
Title: cell lists use simple loops over atom pairs with a callback function to an accumulator

This was built on top of #101

The iteration over atom pairs in the cell lists is now are now implemented via a simple loop structure with a callback function to an accumulator. Similar to the pseudo-code

``` c++
class EnergyAccumulator {
energy = 0

def add_atom_pair(i, j) {
energy += pair_interaction(i, j)
}
}
// similar for EnergyGradientAccumulator, etc.

template
class CellListsLooper {
accumulator_type accumulator;
void loop_over_atom_pairs() {
for icell, jcell in cell_neighbors:
for i in icell:
for j in jcell:
accumulator.add_atom_pair(i, j)
}
}
```

This unfortunately removes the iterator concept from the cell lists, which makes it slightly more cumbersome to use. The upside is that the code is very simple. And we don't have to store the list of atom pairs.

timing
---------
Running `pele/cpp_tests/benchmarks/bench_cell_lists.cpp` (a minimization of 1600 LJ atoms with cutoff of 2 in a box of size 17)

1. constructing then iterating over a vector of atom pairs. 15.02
2. Proper iterator implementation 15.44
3. This accumulator implementation 13.29

So this implementation is slightly faster, but they're all pretty similar.

only this or #101 should be merged, not both.