n2p2 - A neural network potential package
SymGrpBaseExpAng.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//
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#include "SymGrpBaseExpAng.h"
18#include "Atom.h"
19#include "SymFnc.h"
20#include "SymFncBaseExpAng.h"
21#include "Vec3D.h"
22#include "utility.h"
23#include <algorithm> // std::sort
24#include <cmath> // exp
25#include <stdexcept> // std::runtime_error
26
27using namespace std;
28using namespace nnp;
29
30SymGrpBaseExpAng::SymGrpBaseExpAng(size_t type, ElementMap const& elementMap) :
31 SymGrpBaseCutoff(type, elementMap),
32 e1(0),
33 e2(0)
34{
35 parametersCommon.insert("e1");
36 parametersCommon.insert("e2");
37
38 parametersMember.insert("eta");
39 parametersMember.insert("rs/rl");
40 parametersMember.insert("lambda");
41 parametersMember.insert("zeta");
42 parametersMember.insert("calcexp");
43}
44
46{
47 vector<SymFncBaseExpAng const*> members = getMembers();
48
49 scalingFactors.resize(members.size(), 0.0);
50 for (size_t i = 0; i < members.size(); i++)
51 {
52 scalingFactors.at(i) = members[i]->getScalingFactor();
53 factorNorm.at(i) *= scalingFactors.at(i);
54 }
55
56 return;
57}
58
60{
61 vector<string> v;
62 vector<SymFncBaseExpAng const*> members = getMembers();
63
64 v.push_back(strpr(getPrintFormatCommon().c_str(),
65 index + 1,
66 elementMap[ec].c_str(),
67 type,
68 subtype.c_str(),
69 elementMap[e1].c_str(),
70 elementMap[e2].c_str(),
71 rc / convLength,
73
74 for (size_t i = 0; i < members.size(); ++i)
75 {
76 v.push_back(strpr(getPrintFormatMember().c_str(),
77 members[i]->getEta() * convLength * convLength,
78 members[i]->getRs() / convLength,
79 members[i]->getLambda(),
80 members[i]->getZeta(),
81 members[i]->getLineNumber() + 1,
82 i + 1,
83 members[i]->getIndex() + 1,
84 (int)calculateExp[i]));
85 }
86
87 return v;
88}
Contains element map.
Definition: ElementMap.h:30
double cutoffAlpha
Cutoff function parameter (common feature).
std::string subtype
Subtype string (specifies cutoff type) (common feature).
double rc
Cutoff radius (common feature).
std::vector< double > factorNorm
Vector containing precalculated normalizing factor for each zeta.
std::size_t e2
Element index of neighbor atom 2 (common feature).
std::vector< bool > calculateExp
Vector indicating whether exponential term needs to be calculated.
virtual std::vector< std::string > parameterLines() const
Give symmetry function group parameters on multiple lines.
virtual std::vector< SymFncBaseExpAng const * > getMembers() const =0
Get symmetry function members.
virtual void setScalingFactors()
Fill scalingFactors with values from member symmetry functions.
std::size_t e1
Element index of neighbor atom 1 (common feature).
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