n2p2 - A neural network potential package
SymGrp.h
Go to the documentation of this file.
1// n2p2 - A neural network potential package
2// Copyright (C) 2018 Andreas Singraber (University of Vienna)
3//
4// This program is free software: you can redistribute it and/or modify
5// it under the terms of the GNU General Public License as published by
6// the Free Software Foundation, either version 3 of the License, or
7// (at your option) any later version.
8//
9// This program is distributed in the hope that it will be useful,
10// but WITHOUT ANY WARRANTY; without even the implied warranty of
11// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12// GNU General Public License for more details.
13//
14// You should have received a copy of the GNU General Public License
15// along with this program. If not, see <https://www.gnu.org/licenses/>.
16
17#ifndef SYMGRP_H
18#define SYMGRP_H
19
20#include "ElementMap.h"
21#include <cstddef> // std::size_t
22#include <set> // std::set
23#include <string> // std::string
24#include <vector> // std::vector
25
26namespace nnp
27{
28
29struct Atom;
30class SymFnc;
31
32class SymGrp
33{
34public:
37 virtual ~SymGrp() {};
40 virtual bool operator==(SymGrp const& rhs) const = 0;
43 virtual bool operator<(SymGrp const& rhs) const = 0;
46 bool operator!=(SymGrp const& rhs) const;
49 bool operator>(SymGrp const& rhs) const;
52 bool operator<=(SymGrp const& rhs) const;
55 bool operator>=(SymGrp const& rhs) const;
64 virtual bool addMember(SymFnc const* const symmetryFunction) = 0;
69 virtual void sortMembers() = 0;
72 virtual void setScalingFactors() = 0;
79 virtual void calculate(Atom& atom, bool const derivatives) const = 0;
84 virtual std::vector<std::string>
85 parameterLines() const = 0;
90 void setIndex(std::size_t index);
93 std::size_t getIndex() const;
96 std::size_t getType() const;
99 std::size_t getEc() const;
100
101protected:
102 typedef std::map<std::string,
103 std::pair<std::string, std::string> > PrintFormat;
104 typedef std::vector<std::string> PrintOrder;
106 std::size_t type;
110 std::size_t index;
112 std::size_t ec;
116 std::vector<size_t> memberIndex;
118 std::vector<double> scalingFactors;
120 std::set<std::string> parametersCommon;
122 std::set<std::string> parametersMember;
124 std::vector<std::vector<std::size_t> > memberIndexPerElement;
128 static PrintOrder const printOrder;
129
135 SymGrp(std::size_t type, ElementMap const& elementMap);
138 static PrintFormat const initializePrintFormat();
141 static PrintOrder const initializePrintOrder();
146 std::string getPrintFormatCommon() const;
151 std::string getPrintFormatMember() const;
152};
153
155// Inlined function definitions //
157
158inline bool SymGrp::operator!=(SymGrp const& rhs) const
159{
160 return !((*this) == rhs);
161}
162
163inline bool SymGrp::operator>(SymGrp const& rhs) const
164{
165 return rhs < (*this);
166}
167
168inline bool SymGrp::operator<=(SymGrp const& rhs) const
169{
170 return !((*this) > rhs);
171}
172
173inline bool SymGrp::operator>=(SymGrp const& rhs) const
174{
175 return !((*this) < rhs);
176}
177
178inline void SymGrp::setIndex(size_t index)
179{
180 this->index = index;
181 return;
182}
183
184inline std::size_t SymGrp::getIndex() const { return index; }
185inline std::size_t SymGrp::getType() const { return type; }
186inline std::size_t SymGrp::getEc() const { return ec; }
187
188}
189
190#endif
Contains element map.
Definition: ElementMap.h:30
Symmetry function base class.
Definition: SymFnc.h:40
std::size_t type
Symmetry function type.
Definition: SymGrp.h:106
bool operator>=(SymGrp const &rhs) const
Overload >= operator.
Definition: SymGrp.h:173
std::size_t getType() const
Get private type member variable.
Definition: SymGrp.h:185
static PrintFormat const printFormat
Map of parameter format strings and empty strings.
Definition: SymGrp.h:126
std::size_t index
Symmetry function group index.
Definition: SymGrp.h:110
static PrintFormat const initializePrintFormat()
Initialize static print format map for all possible parameters.
Definition: SymGrp.cpp:45
virtual bool operator<(SymGrp const &rhs) const =0
Overload < operator.
std::vector< size_t > memberIndex
Vector containing indices of all member symmetry functions.
Definition: SymGrp.h:116
std::string getPrintFormatCommon() const
Get common parameter line format string.
Definition: SymGrp.cpp:97
bool operator<=(SymGrp const &rhs) const
Overload <= operator.
Definition: SymGrp.h:168
virtual void sortMembers()=0
Sort member symmetry functions.
virtual ~SymGrp()
Virtual destructor.
Definition: SymGrp.h:37
virtual std::vector< std::string > parameterLines() const =0
Give symmetry function group parameters on multiple lines.
bool operator!=(SymGrp const &rhs) const
Overload != operator.
Definition: SymGrp.h:158
std::size_t ec
Element index of center atom (common feature).
Definition: SymGrp.h:112
std::vector< std::vector< std::size_t > > memberIndexPerElement
Vector containing per-element indices of all member symmetry functions.
Definition: SymGrp.h:124
std::size_t getEc() const
Get private ec member variable.
Definition: SymGrp.h:186
std::map< std::string, std::pair< std::string, std::string > > PrintFormat
Definition: SymGrp.h:103
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
std::vector< std::string > PrintOrder
Definition: SymGrp.h:104
ElementMap elementMap
Copy of element map.
Definition: SymGrp.h:108
std::size_t getIndex() const
Get private index member variable.
Definition: SymGrp.h:184
virtual bool operator==(SymGrp const &rhs) const =0
Overload == operator.
std::string getPrintFormatMember() const
Get member parameter line format string.
Definition: SymGrp.cpp:130
void setIndex(std::size_t index)
Set private index member variable.
Definition: SymGrp.h:178
virtual bool addMember(SymFnc const *const symmetryFunction)=0
Potentially add a member to group.
std::vector< double > scalingFactors
Scaling factors of all member symmetry functions.
Definition: SymGrp.h:118
std::set< std::string > parametersMember
Set of common parameters IDs.
Definition: SymGrp.h:122
static PrintOrder const printOrder
Vector of parameters in order of printing.
Definition: SymGrp.h:128
SymGrp(std::size_t type, ElementMap const &elementMap)
Constructor, sets type.
Definition: SymGrp.cpp:27
virtual void setScalingFactors()=0
Fill scalingFactors with values from member symmetry functions.
static PrintOrder const initializePrintOrder()
Initialize static print order vector for all possible parameters.
Definition: SymGrp.cpp:71
virtual void calculate(Atom &atom, bool const derivatives) const =0
Calculate all symmetry functions of this group for one atom.
bool operator>(SymGrp const &rhs) const
Overload > operator.
Definition: SymGrp.h:163
Definition: Atom.h:28
Storage for a single atom.
Definition: Atom.h:32