n2p2 - A neural network potential package
nnp::Atom::Neighbor Struct Reference

Struct to store information on neighbor atoms. More...

#include <Atom.h>

Collaboration diagram for nnp::Atom::Neighbor:

Public Member Functions

 Neighbor ()
 Neighbor constructor, initialize to zero. More...
 
bool operator== (Neighbor const &rhs) const
 Overload == operator. More...
 
bool operator!= (Neighbor const &rhs) const
 Overload != operator. More...
 
bool operator< (Neighbor const &rhs) const
 Overload < operator. More...
 
bool operator> (Neighbor const &rhs) const
 Overload > operator. More...
 
bool operator<= (Neighbor const &rhs) const
 Overload <= operator. More...
 
bool operator>= (Neighbor const &rhs) const
 Overload >= operator. More...
 
std::vector< std::string > info () const
 Get atom information as a vector of strings. More...
 

Public Attributes

std::size_t index
 Index of neighbor atom. More...
 
int64_t tag
 Tag of neighbor atom. More...
 
std::size_t element
 Element index of neighbor atom. More...
 
double d
 Distance to neighbor atom. More...
 
Vec3D dr
 Distance vector to neighbor atom. More...
 
std::vector< double > cache
 Symmetry function cache (e.g. for cutoffs, compact functions). More...
 
std::vector< Vec3DdGdr
 Derivatives of symmetry functions with respect to neighbor coordinates. More...
 

Detailed Description

Struct to store information on neighbor atoms.

Definition at line 35 of file Atom.h.

Constructor & Destructor Documentation

◆ Neighbor()

Atom::Neighbor::Neighbor ( )

Neighbor constructor, initialize to zero.

Definition at line 586 of file Atom.cpp.

586 : index (0 ),
587 tag (0 ),
588 element (0 ),
589 d (0.0 )
590{
591}
std::size_t index
Index of neighbor atom.
Definition: Atom.h:38
std::size_t element
Element index of neighbor atom.
Definition: Atom.h:42
double d
Distance to neighbor atom.
Definition: Atom.h:44
int64_t tag
Tag of neighbor atom.
Definition: Atom.h:40

Member Function Documentation

◆ operator==()

bool Atom::Neighbor::operator== ( Atom::Neighbor const &  rhs) const

Overload == operator.

Definition at line 593 of file Atom.cpp.

594{
595 if (element != rhs.element) return false;
596 if (d != rhs.d ) return false;
597 return true;
598}

References d, d, element, and nnp::Atom::element.

◆ operator!=()

bool nnp::Atom::Neighbor::operator!= ( Atom::Neighbor const &  rhs) const
inline

Overload != operator.

Definition at line 337 of file Atom.h.

338{
339 return !((*this) == rhs);
340}

◆ operator<()

bool Atom::Neighbor::operator< ( Atom::Neighbor const &  rhs) const

Overload < operator.

Definition at line 600 of file Atom.cpp.

601{
602 // sorting according to elements deactivated
603 // TODO: resolve this issue for nnp-sfclust
604 // TODO: this breaks pynnp CI tests in test_Neighbor.py
605 //if (element < rhs.element) return true;
606 //else if (element > rhs.element) return false;
607 if (d < rhs.d ) return true;
608 else if (d > rhs.d ) return false;
609 return false;
610}

References d, and d.

◆ operator>()

bool nnp::Atom::Neighbor::operator> ( Atom::Neighbor const &  rhs) const
inline

Overload > operator.

Definition at line 342 of file Atom.h.

343{
344 return rhs < (*this);
345}

◆ operator<=()

bool nnp::Atom::Neighbor::operator<= ( Atom::Neighbor const &  rhs) const
inline

Overload <= operator.

Definition at line 347 of file Atom.h.

348{
349 return !((*this) > rhs);
350}

◆ operator>=()

bool nnp::Atom::Neighbor::operator>= ( Atom::Neighbor const &  rhs) const
inline

Overload >= operator.

Definition at line 352 of file Atom.h.

353{
354 return !((*this) < rhs);
355}

◆ info()

vector< string > Atom::Neighbor::info ( ) const

Get atom information as a vector of strings.

Returns
Lines with atom information.

Definition at line 612 of file Atom.cpp.

613{
614 vector<string> v;
615
616 v.push_back(strpr("********************************\n"));
617 v.push_back(strpr("NEIGHBOR \n"));
618 v.push_back(strpr("********************************\n"));
619 v.push_back(strpr("index : %d\n", index));
620 v.push_back(strpr("tag : %" PRId64 "\n", tag));
621 v.push_back(strpr("element : %d\n", element));
622 v.push_back(strpr("d : %16.8E\n", d));
623 v.push_back(strpr("dr : %16.8E %16.8E %16.8E\n", dr[0], dr[1], dr[2]));
624 v.push_back(strpr("--------------------------------\n"));
625#ifndef N2P2_NO_SF_CACHE
626 v.push_back(strpr("cache [*] : %d\n", cache.size()));
627 v.push_back(strpr("--------------------------------\n"));
628 for (size_t i = 0; i < cache.size(); ++i)
629 {
630 v.push_back(strpr("%29d : %16.8E\n", i, cache.at(i)));
631 }
632 v.push_back(strpr("--------------------------------\n"));
633 v.push_back(strpr("--------------------------------\n"));
634#endif
635 v.push_back(strpr("dGdr [*] : %d\n", dGdr.size()));
636 v.push_back(strpr("--------------------------------\n"));
637 for (size_t i = 0; i < dGdr.size(); ++i)
638 {
639 v.push_back(strpr("%29d : %16.8E %16.8E %16.8E\n", i, dGdr.at(i)[0], dGdr.at(i)[1], dGdr.at(i)[2]));
640 }
641 v.push_back(strpr("--------------------------------\n"));
642 v.push_back(strpr("********************************\n"));
643
644 return v;
645}
string strpr(const char *format,...)
String version of printf function.
Definition: utility.cpp:90
std::vector< double > cache
Symmetry function cache (e.g. for cutoffs, compact functions).
Definition: Atom.h:49
Vec3D dr
Distance vector to neighbor atom.
Definition: Atom.h:46
std::vector< Vec3D > dGdr
Derivatives of symmetry functions with respect to neighbor coordinates.
Definition: Atom.h:60

References d, nnp::Atom::dGdr, nnp::Atom::element, nnp::Atom::index, nnp::strpr(), and nnp::Atom::tag.

Here is the call graph for this function:

Member Data Documentation

◆ index

std::size_t nnp::Atom::Neighbor::index

Index of neighbor atom.

Definition at line 38 of file Atom.h.

Referenced by nnp::InterfaceLammps::addNeighbor(), nnp::Mode::calculateForces(), and nnp::InterfaceLammps::getForces().

◆ tag

int64_t nnp::Atom::Neighbor::tag

Tag of neighbor atom.

Definition at line 40 of file Atom.h.

Referenced by nnp::InterfaceLammps::addNeighbor(), and nnp::Atom::calculateDChidr().

◆ element

◆ d

◆ dr

◆ cache

◆ dGdr


The documentation for this struct was generated from the following files: