n2p2 - A neural network potential package
CompactFunction.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 "CompactFunction.h"
19#include <stdexcept>
20
21using namespace std;
22using namespace nnp;
23
24CompactFunction::CompactFunction() : center (0.0 ),
25 width (0.0 ),
26 left (0.0 ),
27 right (0.0 ),
28 scale (0.0 )
29{
31}
32
33#ifndef N2P2_NO_ASYM_POLY
35{
36 return core.getAsymmetric();
37}
38
39void CompactFunction::setAsymmetric(bool asymmetric)
40{
41 core.setAsymmetric(asymmetric);
42
43 return;
44}
45#endif
46
47void CompactFunction::setCenterWidth(double center, double width)
48{
49 if (width <= 0.0)
50 {
51 throw invalid_argument("ERROR: Width <= 0.\n");
52 }
53
54 this->center = center;
55 this->width = width;
56 this->left = center - width;
57 this->right = center + width;
58 this->scale = 1.0 / width;
59
60 return;
61}
62
63void CompactFunction::setLeftRight(double left, double right)
64{
65 if (left >= right)
66 {
67 throw invalid_argument("ERROR: Left >= Right.\n");
68 }
69
70 this->left = left;
71 this->right = right;
72 this->center = (right + left) / 2.0;
73 this->width = (right - left) / 2.0;
74 this->scale = 1.0 / width;
75
76 return;
77}
double width
Width of compact function.
void setCenterWidth(double center, double width)
Set center and width.
double center
Center of compact function.
bool getAsymmetric() const
Check if asymmetry is enabled in core function.
void setLeftRight(double left, double right)
Set left and right boundary.
double scale
Inverse width.
CoreFunction core
Core function to be used on either side of compact function.
double right
Right boundary of compact function.
double left
Left boundary of compact function.
void setAsymmetric(bool asymmetric)
Set asymmetric property in core function.
void setAsymmetric(bool asymmetric)
Set asymmetric property.
Definition: CoreFunction.h:143
void setType(Type const type)
Set function type.
bool getAsymmetric() const
Getter for asymmetric.
Definition: CoreFunction.h:150
Definition: Atom.h:28