Skip to content

Implement and test sorted neighbor list #96

@singraber

Description

@singraber

In #77 it turned out to be beneficial to introduce a sorted neighbor list (large cutoff required for real-space part of Ewald summation).

Such a sorted neighbor list could be useful also for SF calculation when different cutoff radii are used. Maybe it would help to create a per-atom map of "neighbor cutoffs" corresponding to different cutoff radii, e.g.

struct Atom
{
    map<double, size_t> neighborCutoffs;
}

Then, during SF setup we initialize the required cutoffs:

neighborCutoffs[sf->getRc()] = 0;

When the neighbor list is sorted, we have to loop over it and determine the neighbor cutoffs for all radii:

// Prepare list of desired cutoffs.
vector<double> cutoffs;
for (auto const& nc : neighborCutoffs) cutoffs.push_back(nc.first);

// Loop over neighbors.
size_t ic = 0;
for (size_t in = 0; in < neighbors.size(); ++in)
{
    Neighbor const& n = neighbors.at(in);
    // If neighbor distance is higher than current "desired cutoff" then add neighbor cutoff.
    // Attention: a step in the neighbor list could jump over multiple cutoffs => need while loop.
    while (n.d > cutoffs.at(ic) && ic < cutoffs.size())
    {
        neighborCutoffs.at(cutoffs.at(ic)) = in;
        ic++;
    }
    if (ic >= cutoffs.size()) break; // All neighbor cutoffs already found.
}

Finally, in the SFs calculate() function we have to replace size_t numNeighbors = atom.numNeighbors; by

size_t numNeighbors = atom.neighborCutoffs.at(rc);

Note: This will not be very useful for SFs with identical cutoff radius (traditional BP), but could increase speed for polynomial SFs.

Metadata

Metadata

Assignees

Labels

coreTouches the libnnp core libraryenhancementNew feature or request

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions