n2p2 - A neural network potential package
EwaldTruncJackson.cpp
Go to the documentation of this file.
1//
2// Created by philipp on 2/17/23.
3//
4
5#include "EwaldTruncJackson.h"
6#include <cmath>
7#include <stdexcept>
8
9namespace nnp
10{
11 void
13 EwaldStructureData const& sData,
14 EwaldParameters &params)
15 {
16 double V = sData.getVolume();
17 newCutoffs = (V != volume);
18 if (!newCutoffs) return;
20 volume = V;
21
22 if ( settings.precision >= 1.0 )
23 throw std::runtime_error("ERROR: Ewald truncation method 0 "
24 "(Jackson) requires precision < 1.0");
25 params.eta = calculateEta();
26 if ( params.eta <= 0.0 )
27 throw std::runtime_error("ERROR: Ewald screening parameter eta is "
28 "not positive, is the unit cell volume "
29 "correct?");
30 params.rCut = calculateRCut(params.eta, settings.precision);
31 params.kCut = calculateKCut(params.eta, settings.precision);
32 return;
33 }
34
36 {
37 bool answer = newCutoffsWerePublished;
39 return answer;
40 }
41
43 {
44 // Matrix version of eta.
45 return 1.0 / sqrt(2.0 * M_PI) * pow(volume, 1.0 / 3.0);
46 }
47
48 double EwaldTruncJackson::calculateRCut(double const eta,
49 double const prec) const
50 {
51 return sqrt(-2.0 * log(prec)) * eta;
52 }
53
54 double EwaldTruncJackson::calculateKCut(double const eta,
55 double const prec) const
56 {
57 return sqrt(-2.0 * log(prec)) / eta;
58 }
59} // nnp
double getVolume() const
Definition: IEwaldTrunc.h:30
void calculateParameters(EwaldGlobalSettings const &settings, EwaldStructureData const &sData, EwaldParameters &params) override
double calculateRCut(double const eta, double const prec) const
double calculateKCut(double const eta, double const prec) const
bool publishedNewCutoffs() override
Definition: Atom.h:29
double rCut
Cutoff in real space.
Definition: IEwaldTrunc.h:42
double eta
Width of the gaussian screening charges.
Definition: IEwaldTrunc.h:40
double kCut
Cutoff in reciprocal space.
Definition: IEwaldTrunc.h:44