n2p2 - A neural network potential package
nnp::SymGrp Class Referenceabstract

#include <SymGrp.h>

Inheritance diagram for nnp::SymGrp:
Collaboration diagram for nnp::SymGrp:

Public Member Functions

virtual ~SymGrp ()
 Virtual destructor. More...
 
virtual bool operator== (SymGrp const &rhs) const =0
 Overload == operator. More...
 
virtual bool operator< (SymGrp const &rhs) const =0
 Overload < operator. More...
 
bool operator!= (SymGrp const &rhs) const
 Overload != operator. More...
 
bool operator> (SymGrp const &rhs) const
 Overload > operator. More...
 
bool operator<= (SymGrp const &rhs) const
 Overload <= operator. More...
 
bool operator>= (SymGrp const &rhs) const
 Overload >= operator. More...
 
virtual bool addMember (SymFnc const *const symmetryFunction)=0
 Potentially add a member to group. More...
 
virtual void sortMembers ()=0
 Sort member symmetry functions. More...
 
virtual void setScalingFactors ()=0
 Fill scalingFactors with values from member symmetry functions. More...
 
virtual void calculate (Atom &atom, bool const derivatives) const =0
 Calculate all symmetry functions of this group for one atom. More...
 
virtual std::vector< std::string > parameterLines () const =0
 Give symmetry function group parameters on multiple lines. More...
 
void setIndex (std::size_t index)
 Set private index member variable. More...
 
std::size_t getIndex () const
 Get private index member variable. More...
 
std::size_t getType () const
 Get private type member variable. More...
 
std::size_t getEc () const
 Get private ec member variable. More...
 

Protected Types

typedef std::map< std::string, std::pair< std::string, std::string > > PrintFormat
 
typedef std::vector< std::string > PrintOrder
 

Protected Member Functions

 SymGrp (std::size_t type, ElementMap const &elementMap)
 Constructor, sets type. More...
 
std::string getPrintFormatCommon () const
 Get common parameter line format string. More...
 
std::string getPrintFormatMember () const
 Get member parameter line format string. More...
 

Static Protected Member Functions

static PrintFormat const initializePrintFormat ()
 Initialize static print format map for all possible parameters. More...
 
static PrintOrder const initializePrintOrder ()
 Initialize static print order vector for all possible parameters. More...
 

Protected Attributes

std::size_t type
 Symmetry function type. More...
 
ElementMap elementMap
 Copy of element map. More...
 
std::size_t index
 Symmetry function group index. More...
 
std::size_t ec
 Element index of center atom (common feature). More...
 
double convLength
 Data set normalization length conversion factor. More...
 
std::vector< size_t > memberIndex
 Vector containing indices of all member symmetry functions. More...
 
std::vector< double > scalingFactors
 Scaling factors of all member symmetry functions. More...
 
std::set< std::string > parametersCommon
 Set of common parameters IDs. More...
 
std::set< std::string > parametersMember
 Set of common parameters IDs. More...
 
std::vector< std::vector< std::size_t > > memberIndexPerElement
 Vector containing per-element indices of all member symmetry functions. More...
 

Static Protected Attributes

static PrintFormat const printFormat = initializePrintFormat()
 Map of parameter format strings and empty strings. More...
 
static PrintOrder const printOrder = initializePrintOrder()
 Vector of parameters in order of printing. More...
 

Detailed Description

Definition at line 32 of file SymGrp.h.

Member Typedef Documentation

◆ PrintFormat

typedef std::map<std::string, std::pair<std::string, std::string> > nnp::SymGrp::PrintFormat
protected

Definition at line 103 of file SymGrp.h.

◆ PrintOrder

typedef std::vector<std::string> nnp::SymGrp::PrintOrder
protected

Definition at line 104 of file SymGrp.h.

Constructor & Destructor Documentation

◆ ~SymGrp()

virtual nnp::SymGrp::~SymGrp ( )
inlinevirtual

Virtual destructor.

Definition at line 37 of file SymGrp.h.

37{};

◆ SymGrp()

SymGrp::SymGrp ( std::size_t  type,
ElementMap const &  elementMap 
)
protected

Constructor, sets type.

Parameters
[in]typeType of symmetry functions grouped.
[in]elementMapElement Map used.

Definition at line 27 of file SymGrp.cpp.

27 :
28 type (type ),
30 index (0 ),
31 ec (0 ),
32 convLength (1.0 )
33{
34 // Add standard common parameter IDs to set.
35 parametersCommon.insert("index");
36 parametersCommon.insert("type");
37 parametersCommon.insert("ec");
38
39 // Add standard member parameter IDs to set.
40 parametersMember.insert("lineNumber");
41 parametersMember.insert("mindex");
42 parametersMember.insert("sfindex");
43}
std::size_t type
Symmetry function type.
Definition: SymGrp.h:106
std::size_t index
Symmetry function group index.
Definition: SymGrp.h:110
std::size_t ec
Element index of center atom (common feature).
Definition: SymGrp.h:112
double convLength
Data set normalization length conversion factor.
Definition: SymGrp.h:114
std::set< std::string > parametersCommon
Set of common parameters IDs.
Definition: SymGrp.h:120
ElementMap elementMap
Copy of element map.
Definition: SymGrp.h:108
std::set< std::string > parametersMember
Set of common parameters IDs.
Definition: SymGrp.h:122

References parametersCommon, and parametersMember.

Member Function Documentation

◆ operator==()

◆ operator<()

◆ operator!=()

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

Overload != operator.

Definition at line 158 of file SymGrp.h.

159{
160 return !((*this) == rhs);
161}

◆ operator>()

bool nnp::SymGrp::operator> ( SymGrp const &  rhs) const
inline

Overload > operator.

Definition at line 163 of file SymGrp.h.

164{
165 return rhs < (*this);
166}

◆ operator<=()

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

Overload <= operator.

Definition at line 168 of file SymGrp.h.

169{
170 return !((*this) > rhs);
171}

◆ operator>=()

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

Overload >= operator.

Definition at line 173 of file SymGrp.h.

174{
175 return !((*this) < rhs);
176}

◆ addMember()

virtual bool nnp::SymGrp::addMember ( SymFnc const *const  symmetryFunction)
pure virtual

Potentially add a member to group.

Parameters
[in]symmetryFunctionCandidate symmetry function.
Returns
If addition was successful.

If symmetry function is compatible with common feature list its pointer will be added to the members vector.

Implemented in nnp::SymGrpCompAngn, nnp::SymGrpCompAngnWeighted, nnp::SymGrpCompAngw, nnp::SymGrpCompAngwWeighted, nnp::SymGrpCompRad, nnp::SymGrpCompRadWeighted, nnp::SymGrpExpAngn, nnp::SymGrpExpAngnWeighted, nnp::SymGrpExpAngw, nnp::SymGrpExpRad, and nnp::SymGrpExpRadWeighted.

◆ sortMembers()

virtual void nnp::SymGrp::sortMembers ( )
pure virtual

◆ setScalingFactors()

virtual void nnp::SymGrp::setScalingFactors ( )
pure virtual

◆ calculate()

virtual void nnp::SymGrp::calculate ( Atom atom,
bool const  derivatives 
) const
pure virtual

Calculate all symmetry functions of this group for one atom.

Parameters
[in,out]atomAtom for which symmetry functions are caluclated.
[in]derivativesIf also symmetry function derivatives will be calculated and saved.

Implemented in nnp::SymGrpCompAngn, nnp::SymGrpCompAngnWeighted, nnp::SymGrpCompAngw, nnp::SymGrpCompAngwWeighted, nnp::SymGrpCompRad, nnp::SymGrpCompRadWeighted, nnp::SymGrpExpAngn, nnp::SymGrpExpAngnWeighted, nnp::SymGrpExpAngw, nnp::SymGrpExpRad, and nnp::SymGrpExpRadWeighted.

◆ parameterLines()

virtual std::vector< std::string > nnp::SymGrp::parameterLines ( ) const
pure virtual

Give symmetry function group parameters on multiple lines.

Returns
Vector of string containing symmetry function parameters lines.

Implemented in nnp::SymGrpBaseCompAng, nnp::SymGrpBaseCompAngWeighted, nnp::SymGrpBaseExpAng, nnp::SymGrpCompRad, nnp::SymGrpCompRadWeighted, nnp::SymGrpExpAngnWeighted, nnp::SymGrpExpRad, and nnp::SymGrpExpRadWeighted.

◆ setIndex()

void nnp::SymGrp::setIndex ( std::size_t  index)
inline

Set private index member variable.

Parameters
[in]indexIndex number of symmetry function group.

Definition at line 178 of file SymGrp.h.

179{
180 this->index = index;
181 return;
182}

References index.

◆ getIndex()

◆ getType()

◆ getEc()

◆ initializePrintFormat()

SymGrp::PrintFormat const SymGrp::initializePrintFormat ( )
staticprotected

Initialize static print format map for all possible parameters.

Definition at line 45 of file SymGrp.cpp.

46{
47 PrintFormat pf;
48
49 pf["index"] = make_pair("%4zu" , string(4, ' '));
50 pf["ec"] = make_pair("%2s" , string(2, ' '));
51 pf["type"] = make_pair("%2zu" , string(2, ' '));
52 pf["subtype"] = make_pair("%4s" , string(4, ' '));
53 pf["e1"] = make_pair("%2s" , string(2, ' '));
54 pf["e2"] = make_pair("%2s" , string(2, ' '));
55 pf["eta"] = make_pair("%9.3E" , string(9, ' '));
56 pf["rs/rl"] = make_pair("%10.3E", string(10, ' '));
57 pf["rc"] = make_pair("%10.3E", string(10, ' '));
58 pf["angleLeft"] = make_pair("%6.1f" , string(6, ' '));
59 pf["angleRight"] = make_pair("%6.1f" , string(6, ' '));
60 pf["lambda"] = make_pair("%2.0f" , string(2, ' '));
61 pf["zeta"] = make_pair("%4.1f" , string(4, ' '));
62 pf["alpha"] = make_pair("%4.2f" , string(4, ' '));
63 pf["lineNumber"] = make_pair("%5zu" , string(5, ' '));
64 pf["mindex"] = make_pair("%4zu" , string(4, ' '));
65 pf["sfindex"] = make_pair("%4zu" , string(4, ' '));
66 pf["calcexp"] = make_pair("%1d" , string(1, ' '));
67
68 return pf;
69}
std::map< std::string, std::pair< std::string, std::string > > PrintFormat
Definition: SymGrp.h:103

◆ initializePrintOrder()

SymGrp::PrintOrder const SymGrp::initializePrintOrder ( )
staticprotected

Initialize static print order vector for all possible parameters.

Definition at line 71 of file SymGrp.cpp.

72{
73 vector<string> po;
74
75 po.push_back("index" );
76 po.push_back("ec" );
77 po.push_back("type" );
78 po.push_back("subtype" );
79 po.push_back("e1" );
80 po.push_back("e2" );
81 po.push_back("eta" );
82 po.push_back("rs/rl" );
83 po.push_back("rc" );
84 po.push_back("angleLeft" );
85 po.push_back("angleRight");
86 po.push_back("lambda" );
87 po.push_back("zeta" );
88 po.push_back("alpha" );
89 po.push_back("lineNumber");
90 po.push_back("mindex" );
91 po.push_back("sfindex" );
92 po.push_back("calcexp" );
93
94 return po;
95}

◆ getPrintFormatCommon()

string SymGrp::getPrintFormatCommon ( ) const
protected

Get common parameter line format string.

Returns
C-style format string.

Definition at line 97 of file SymGrp.cpp.

98{
99 string s;
100
101 for (PrintOrder::const_iterator it = printOrder.begin();
102 it != printOrder.end(); ++it)
103 {
104 // If common parameter is present add format string.
105 if (parametersCommon.find(*it) != parametersCommon.end())
106 {
107 s += safeFind(printFormat, (*it)).first + ' ';
108 }
109 // Else if member parameter is present add star marker.
110 else if (parametersMember.find(*it) != parametersMember.end())
111 {
112 string t = safeFind(printFormat, (*it)).second;
113 if (t.size () > 0) t.resize (t.size () - 1);
114 t += '*';
115 s += t + ' ';
116 }
117 // Else add just enough empty spaces.
118 else
119 {
120 s += safeFind(printFormat, (*it)).second + ' ';
121 }
122 }
123 // Remove extra space at the end.
124 if (s.size () > 0) s.resize (s.size () - 1);
125 s += '\n';
126
127 return s;
128}
static PrintFormat const printFormat
Map of parameter format strings and empty strings.
Definition: SymGrp.h:126
static PrintOrder const printOrder
Vector of parameters in order of printing.
Definition: SymGrp.h:128
V const & safeFind(std::map< K, V > const &stdMap, typename std::map< K, V >::key_type const &key)
Safely access map entry.
Definition: utility.h:135

References parametersCommon, parametersMember, printFormat, printOrder, and nnp::safeFind().

Referenced by nnp::SymGrpBaseCompAng::parameterLines(), nnp::SymGrpBaseCompAngWeighted::parameterLines(), nnp::SymGrpBaseExpAng::parameterLines(), nnp::SymGrpCompRad::parameterLines(), nnp::SymGrpCompRadWeighted::parameterLines(), nnp::SymGrpExpAngnWeighted::parameterLines(), nnp::SymGrpExpRad::parameterLines(), and nnp::SymGrpExpRadWeighted::parameterLines().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ getPrintFormatMember()

string SymGrp::getPrintFormatMember ( ) const
protected

Get member parameter line format string.

Returns
C-style format string.

Definition at line 130 of file SymGrp.cpp.

131{
132 string s;
133
134 for (PrintOrder::const_iterator it = printOrder.begin();
135 it != printOrder.end(); ++it)
136 {
137 // If common parameter is present add format string.
138 if (parametersMember.find(*it) != parametersMember.end())
139 {
140 s += safeFind(printFormat, (*it)).first + ' ';
141 }
142 // Else if member parameter is present add star marker.
143 else if (parametersCommon.find(*it) != parametersCommon.end())
144 {
145 string t = safeFind(printFormat, (*it)).second;
146 if (t.size () > 0) t.resize (t.size () - 1);
147 t += '-';
148 s += t + ' ';
149 }
150 // Else add just enough empty spaces.
151 else
152 {
153 s += safeFind(printFormat, (*it)).second + ' ';
154 }
155 }
156 // Remove extra space at the end.
157 if (s.size () > 0) s.resize (s.size () - 1);
158 s += '\n';
159
160 return s;
161}

References parametersCommon, parametersMember, printFormat, printOrder, and nnp::safeFind().

Referenced by nnp::SymGrpBaseCompAng::parameterLines(), nnp::SymGrpBaseCompAngWeighted::parameterLines(), nnp::SymGrpBaseExpAng::parameterLines(), nnp::SymGrpCompRad::parameterLines(), nnp::SymGrpCompRadWeighted::parameterLines(), nnp::SymGrpExpAngnWeighted::parameterLines(), nnp::SymGrpExpRad::parameterLines(), and nnp::SymGrpExpRadWeighted::parameterLines().

Here is the call graph for this function:
Here is the caller graph for this function:

Member Data Documentation

◆ type

std::size_t nnp::SymGrp::type
protected

Symmetry function type.

Definition at line 106 of file SymGrp.h.

Referenced by nnp::SymGrpCompAngn::addMember(), nnp::SymGrpCompAngnWeighted::addMember(), nnp::SymGrpCompAngw::addMember(), nnp::SymGrpCompAngwWeighted::addMember(), nnp::SymGrpCompRad::addMember(), nnp::SymGrpCompRadWeighted::addMember(), nnp::SymGrpExpAngn::addMember(), nnp::SymGrpExpAngnWeighted::addMember(), nnp::SymGrpExpAngw::addMember(), nnp::SymGrpExpRad::addMember(), nnp::SymGrpExpRadWeighted::addMember(), getType(), nnp::SymGrpCompAngn::operator<(), nnp::SymGrpCompAngnWeighted::operator<(), nnp::SymGrpCompAngw::operator<(), nnp::SymGrpCompAngwWeighted::operator<(), nnp::SymGrpCompRad::operator<(), nnp::SymGrpCompRadWeighted::operator<(), nnp::SymGrpExpAngn::operator<(), nnp::SymGrpExpAngnWeighted::operator<(), nnp::SymGrpExpAngw::operator<(), nnp::SymGrpExpRad::operator<(), nnp::SymGrpExpRadWeighted::operator<(), nnp::SymGrpCompAngn::operator==(), nnp::SymGrpCompAngnWeighted::operator==(), nnp::SymGrpCompAngw::operator==(), nnp::SymGrpCompAngwWeighted::operator==(), nnp::SymGrpCompRad::operator==(), nnp::SymGrpCompRadWeighted::operator==(), nnp::SymGrpExpAngn::operator==(), nnp::SymGrpExpAngnWeighted::operator==(), nnp::SymGrpExpAngw::operator==(), nnp::SymGrpExpRad::operator==(), nnp::SymGrpExpRadWeighted::operator==(), nnp::SymGrpBaseCompAng::parameterLines(), nnp::SymGrpBaseCompAngWeighted::parameterLines(), nnp::SymGrpBaseExpAng::parameterLines(), nnp::SymGrpCompRad::parameterLines(), nnp::SymGrpCompRadWeighted::parameterLines(), nnp::SymGrpExpAngnWeighted::parameterLines(), nnp::SymGrpExpRad::parameterLines(), and nnp::SymGrpExpRadWeighted::parameterLines().

◆ elementMap

◆ index

◆ ec

std::size_t nnp::SymGrp::ec
protected

Element index of center atom (common feature).

Definition at line 112 of file SymGrp.h.

Referenced by nnp::SymGrpCompAngn::addMember(), nnp::SymGrpCompAngnWeighted::addMember(), nnp::SymGrpCompAngw::addMember(), nnp::SymGrpCompAngwWeighted::addMember(), nnp::SymGrpCompRad::addMember(), nnp::SymGrpCompRadWeighted::addMember(), nnp::SymGrpExpAngn::addMember(), nnp::SymGrpExpAngnWeighted::addMember(), nnp::SymGrpExpAngw::addMember(), nnp::SymGrpExpRad::addMember(), nnp::SymGrpExpRadWeighted::addMember(), getEc(), nnp::SymGrpCompAngn::operator<(), nnp::SymGrpCompAngnWeighted::operator<(), nnp::SymGrpCompAngw::operator<(), nnp::SymGrpCompAngwWeighted::operator<(), nnp::SymGrpCompRad::operator<(), nnp::SymGrpCompRadWeighted::operator<(), nnp::SymGrpExpAngn::operator<(), nnp::SymGrpExpAngnWeighted::operator<(), nnp::SymGrpExpAngw::operator<(), nnp::SymGrpExpRad::operator<(), nnp::SymGrpExpRadWeighted::operator<(), nnp::SymGrpCompAngn::operator==(), nnp::SymGrpCompAngnWeighted::operator==(), nnp::SymGrpCompAngw::operator==(), nnp::SymGrpCompAngwWeighted::operator==(), nnp::SymGrpCompRad::operator==(), nnp::SymGrpCompRadWeighted::operator==(), nnp::SymGrpExpAngn::operator==(), nnp::SymGrpExpAngnWeighted::operator==(), nnp::SymGrpExpAngw::operator==(), nnp::SymGrpExpRad::operator==(), nnp::SymGrpExpRadWeighted::operator==(), nnp::SymGrpBaseCompAng::parameterLines(), nnp::SymGrpBaseCompAngWeighted::parameterLines(), nnp::SymGrpBaseExpAng::parameterLines(), nnp::SymGrpCompRad::parameterLines(), nnp::SymGrpCompRadWeighted::parameterLines(), nnp::SymGrpExpAngnWeighted::parameterLines(), nnp::SymGrpExpRad::parameterLines(), and nnp::SymGrpExpRadWeighted::parameterLines().

◆ convLength

◆ memberIndex

◆ scalingFactors

◆ parametersCommon

◆ parametersMember

◆ memberIndexPerElement

◆ printFormat

SymGrp::PrintFormat const SymGrp::printFormat = initializePrintFormat()
staticprotected

Map of parameter format strings and empty strings.

Definition at line 126 of file SymGrp.h.

Referenced by getPrintFormatCommon(), and getPrintFormatMember().

◆ printOrder

SymGrp::PrintOrder const SymGrp::printOrder = initializePrintOrder()
staticprotected

Vector of parameters in order of printing.

Definition at line 128 of file SymGrp.h.

Referenced by getPrintFormatCommon(), and getPrintFormatMember().


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