n2p2 - A neural network potential package
ScreeningFunction.cpp
Go to the documentation of this file.
1// n2p2 - A neural network potential package
2// Copyright (C) 2021 Andreas Singraber
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 "ScreeningFunction.h"
18#include "utility.h"
19#include <stdexcept>
20
21using namespace std;
22using namespace nnp;
23
24ScreeningFunction::ScreeningFunction() : inner(0.0),
25 outer(0.0),
26 scale(0.0)
27{
29}
30
31void ScreeningFunction::setInnerOuter(double inner, double outer)
32{
33 if (inner >= outer)
34 {
35 throw invalid_argument("ERROR: Inner radius of transition region >= "
36 "outer radius.\n");
37 }
38
39 this->inner = inner;
40 this->outer = outer;
41 this->scale = 1.0 / (outer - inner);
42
43 return;
44}
45
47{
48 inner *= conv;
49 outer *= conv;
50 scale /= conv;
51}
52vector<string> ScreeningFunction::info() const
53{
54 vector<string> v;
55
56 v.push_back("Screening function information:\n");
57 v.push_back(strpr("Inner radius : %16.8E\n", inner));
58 v.push_back(strpr("Outer radius : %16.8E\n", outer));
59 v.push_back("Transition region functional form:\n");
60 v.push_back("x := (r - inner) / (outer - inner)\n");
61 v.push_back("fs(x) := 1 - f(x)\n");
62 vector<string> ci = core.info();
63 v.insert(v.end(), ci.begin(), ci.end());
64
65 return v;
66}
std::vector< std::string > info() const
Get string with formula of compact function.
void setType(Type const type)
Set function type.
double scale
Inverse width.
double inner
Inner radius where transition region starts.
CoreFunction core
Core function to be used in the transition region.
void changeLengthUnits(double const conv)
Change length units of screening function.
std::vector< std::string > info() const
Get string with information of screening function.
double outer
Outer radius where transition region ends.
void setInnerOuter(double inner, double outer)
Set inner and outer limit of transition region.
Definition: Atom.h:29
string strpr(const char *format,...)
String version of printf function.
Definition: utility.cpp:90