dftlibs / numgrid

Numerical integration grid for molecules.
Mozilla Public License 2.0
47 stars 14 forks source link

[Feature/Discussion] API redesign #16

Closed bast closed 6 years ago

bast commented 7 years ago

For my reference saving here @robertodr 's good suggestions.

Interface tech

Memory handling

Grid Generation/Storage

The angular grid can be generated once and stored, alongside the complete grid, i.e. the tensor product angular x radial. It might give extra flexibility to also store the radial grids atom-by-atom, sorted in the order they were read in. This might be helpful to batch points, without sorting them after grid generation. I would introduce two new data types: AngularGrid (or just call it LebedevLaikov, since I don't see any reason to use any other angular scheme) and RadialGrid, as wrappers to common grid operations on the two independent degrees of freedom. A third data type Grid (top-level API) will be made available, together with a gridTensorProduct function accepting one AngularGrid and one RadialGrid. Note that introducing RadialGrid might give extra flexibility in implementing schemes other than the Lindh-Malmqvist-Gagliardi currently in place.

Lazy Grid Generation

So, since the grid is a tensor product of two lower dimensional grids, one could generate and store in memory the angular portion, while generating the radial grid and total grid on-the-fly when a certain atom is requested. In principle, one could pre-calculate the radial grids on all atoms and compute the tensors products on-the-fly.

bast commented 6 years ago

New API is live - did not go for pybind11 yet although I like it a lot. Might do that in future. Grid generation is now lazy (in the sense that it is per-atom) and really simple.