n2p2 - A neural network potential package
SymGrpBaseCompAngWeighted.cpp
Go to the documentation of this file.
1// n2p2 - A neural network potential package
2// Copyright (C) 2018 Andreas Singraber (University of Vienna)
3// Copyright (C) 2020 Martin P. Bircher
4//
5// This program is free software: you can redistribute it and/or modify
6// it under the terms of the GNU General Public License as published by
7// the Free Software Foundation, either version 3 of the License, or
8// (at your option) any later version.
9//
10// This program is distributed in the hope that it will be useful,
11// but WITHOUT ANY WARRANTY; without even the implied warranty of
12// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13// GNU General Public License for more details.
14//
15// You should have received a copy of the GNU General Public License
16// along with this program. If not, see <https://www.gnu.org/licenses/>.
17
20#include "Atom.h"
21#include "SymFnc.h"
22#include "Vec3D.h"
23#include "utility.h"
24#include <algorithm> // std::sort
25#include <cmath> // exp
26#include <stdexcept> // std::runtime_error
27using namespace std;
28using namespace nnp;
29
30SymGrpBaseCompAngWeighted::
31SymGrpBaseCompAngWeighted(size_t type, ElementMap const& elementMap) :
32 SymGrpBaseComp(type, elementMap)
33{
34 parametersMember.insert("angleLeft");
35 parametersMember.insert("angleRight");
36 parametersMember.insert("calcexp");
37}
38
40{
41 vector<SymFncBaseCompAngWeighted const*> members = getMembers();
42 scalingFactors.resize(members.size(), 0.0);
43 for (size_t i = 0; i < members.size(); i++)
44 {
45 scalingFactors.at(i) = members[i]->getScalingFactor();
46 }
47
48 return;
49}
50
52{
53 vector<string> v;
54 vector<SymFncBaseCompAngWeighted const*> members = getMembers();
55
56 v.push_back(strpr(getPrintFormatCommon().c_str(),
57 index + 1,
58 elementMap[ec].c_str(),
59 type,
61 rmax / convLength));
62
63 for (size_t i = 0; i < members.size(); ++i)
64 {
65 v.push_back(strpr(getPrintFormatMember().c_str(),
66 members[i]->getSubtype().c_str(),
67 members[i]->getRl() / convLength,
68 members[i]->getRc() / convLength,
69 members[i]->getAngleLeft(),
70 members[i]->getAngleRight(),
71 members[i]->getLineNumber() + 1,
72 i + 1,
73 members[i]->getIndex() + 1,
74 calculateComp[i]));
75 }
76
77 return v;
78}
Contains element map.
Definition: ElementMap.h:30
virtual std::vector< std::string > parameterLines() const
Give symmetry function group parameters on multiple lines.
std::vector< bool > calculateComp
Vector indicating whether compact function needs to be recalculated.
virtual std::vector< SymFncBaseCompAngWeighted const * > getMembers() const =0
Get symmetry function members.
virtual void setScalingFactors()
Fill scalingFactors with values from member symmetry functions.
double rmin
Minimum radius within group.
double rmax
Maximum radius within group.
std::size_t type
Symmetry function type.
Definition: SymGrp.h:106
std::size_t index
Symmetry function group index.
Definition: SymGrp.h:110
std::string getPrintFormatCommon() const
Get common parameter line format string.
Definition: SymGrp.cpp:97
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
ElementMap elementMap
Copy of element map.
Definition: SymGrp.h:108
std::size_t getIndex() const
Get private index member variable.
Definition: SymGrp.h:184
std::string getPrintFormatMember() const
Get member parameter line format string.
Definition: SymGrp.cpp:130
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
Definition: Atom.h:29
string strpr(const char *format,...)
String version of printf function.
Definition: utility.cpp:90