n2p2 - A neural network potential package
SymGrpBaseCompAng.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
18#include "SymGrpBaseCompAng.h"
19#include "SymFncBaseCompAng.h"
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
30SymGrpBaseCompAng::
31SymGrpBaseCompAng(size_t type, ElementMap const& elementMap) :
32 SymGrpBaseComp(type, elementMap),
33 e1(0),
34 e2(0)
35{
36 parametersCommon.insert("e1");
37 parametersCommon.insert("e2");
38
39 parametersMember.insert("angleLeft");
40 parametersMember.insert("angleRight");
41 parametersMember.insert("calcexp");
42}
43
45{
46 vector<SymFncBaseCompAng const*> members = getMembers();
47 scalingFactors.resize(members.size(), 0.0);
48 for (size_t i = 0; i < members.size(); i++)
49 {
50 scalingFactors.at(i) = members[i]->getScalingFactor();
51 }
52
53 return;
54}
55
57{
58 vector<string> v;
59 vector<SymFncBaseCompAng const*> members = getMembers();
60
61 v.push_back(strpr(getPrintFormatCommon().c_str(),
62 index + 1,
63 elementMap[ec].c_str(),
64 type,
65 elementMap[e1].c_str(),
66 elementMap[e2].c_str(),
68 rmax / convLength));
69
70 for (size_t i = 0; i < members.size(); ++i)
71 {
72 v.push_back(strpr(getPrintFormatMember().c_str(),
73 members[i]->getSubtype().c_str(),
74 members[i]->getRl() / convLength,
75 members[i]->getRc() / convLength,
76 members[i]->getAngleLeft(),
77 members[i]->getAngleRight(),
78 members[i]->getLineNumber() + 1,
79 i + 1,
80 members[i]->getIndex() + 1,
81 calculateComp[i]));
82 }
83
84 return v;
85}
Contains element map.
Definition: ElementMap.h:30
std::size_t e1
Element index of neighbor atom 1 (common feature).
std::size_t e2
Element index of neighbor atom 2 (common feature).
virtual void setScalingFactors()
Fill scalingFactors with values from member symmetry functions.
virtual std::vector< std::string > parameterLines() const
Give symmetry function group parameters on multiple lines.
virtual std::vector< SymFncBaseCompAng const * > getMembers() const =0
Get symmetry function members.
std::vector< bool > calculateComp
Vector indicating whether compact function needs to be recalculated.
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
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::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