NNFinder

class NNFinder

Nearest Neighbor Finder that constructs a full nearest neighbor list for every atom in a structure, using:

  • a binned (linked-cell) approach if every cell dimension ≥ cutoff,

  • a naive approach otherwise (fallback).

The cutoff is from context(“RCUTMAX”).

Public Functions

void num_shifts(const Structure &st, int N[3], double cutoff) const

Compute ±N to consider for image shifts.

void deduplicate(const Structure &st, std::shared_ptr<NNTable> tbl) const

Remove duplicates from the neighbor list.

void calc_naive(const Structure &st, std::shared_ptr<NNTable> tbl, double cutoff) const

Naive approach to build neighbor lists.

void calc_binned(const Structure &st, std::shared_ptr<NNTable> tbl, double cutoff) const

Binning-based approach. If any dimension < cutoff, fallback to naive.

NNFinder() = default

Construct with cutoff from context(“RCUTMAX”).

NNTablePtr build(Structure &st, double cutoff) const

Build nearest neighbors for all atoms in one Structure. Uses binned approach if possible, else naive fallback.

NNTablePtr build(Structure &st, const core::Context &context) const

Build nearest neighbors for all atoms in one Structure. Uses context(“RCUTMAX”) to determine the cutoff.

Parameters:
  • stStructure to build neighbors for.

  • context – Context to get the cutoff from.

void calc(Structure &st, double cutoff) const

Build nearest neighbors for all atoms in one Structure. Uses binned approach if possible, else naive fallback.

Parameters:
  • stStructure to build neighbors for.

  • cutoff – Cutoff distance for neighbor search.

void calc(Structure &st, const core::Context &context) const

Build nearest neighbors for all atoms in one Structure. Uses binned approach if possible, else naive fallback.

Parameters:
  • stStructure to build neighbors for.

  • cutoff – Cutoff distance for neighbor search.

void calc(StructureDB &stdb, double cutoff) const

Build nearest neighbors for each structure in a DB.

void calc(StructureDB &stdb, const core::Context &context) const

Build nearest neighbors for each structure in a DB. Uses context(“RCUTMAX”) to determine the cutoff.

Parameters:
  • stdbStructureDB to build neighbors for.

  • context – Context to get the cutoff from.

Public Static Functions

static bool check_box(const Structure &st, double cutoff)

Return false if any cell dimension < cutoff => fallback to naive.