n2p2 - A neural network potential package
nnp::KspaceGrid Class Reference

#include <Kspace.h>

Collaboration diagram for nnp::KspaceGrid:

Public Member Functions

 KspaceGrid ()
 Constructor. More...
 
void setup (Vec3D box[3], EwaldSetup &ewaldSetup)
 Set up reciprocal box vectors and eta. More...
 

Public Attributes

double eta
 Ewald summation eta parameter. More...
 
double kCut
 Cutoff in reciprocal space. More...
 
double rCut
 Cutoff in real space. More...
 
double volume
 Volume of real box. More...
 
double pre
 Ewald sum prefactor \(\frac{2\pi}{V}\). More...
 
int n [3]
 Required box copies in each box vector direction. More...
 
Vec3D kbox [3]
 Reciprocal box vectors. More...
 
std::vector< Kvectorkvectors
 Vector containing all k-vectors. More...
 

Private Member Functions

void calculatePbcCopies (double cutoffRadius)
 Compute box copies in each direction. More...
 

Detailed Description

Definition at line 43 of file Kspace.h.

Constructor & Destructor Documentation

◆ KspaceGrid()

KspaceGrid::KspaceGrid ( )

Constructor.

Definition at line 38 of file Kspace.cpp.

38 : eta (0.0),
39 kCut (0.0),
40 volume(0.0),
41 pre (0.0)
42{
43}
double pre
Ewald sum prefactor .
Definition: Kspace.h:55
double eta
Ewald summation eta parameter.
Definition: Kspace.h:47
double volume
Volume of real box.
Definition: Kspace.h:53
double kCut
Cutoff in reciprocal space.
Definition: Kspace.h:49

Member Function Documentation

◆ setup()

void KspaceGrid::setup ( Vec3D  box[3],
EwaldSetup ewaldSetup 
)

Set up reciprocal box vectors and eta.

Parameters
[in]boxReal box vectors.
[in]ewaldSetupSettings of ewald summation.

Definition at line 45 of file Kspace.cpp.

46{
47 volume = fabs(box[0] * (box[1].cross(box[2])));
48 pre = 2.0 * M_PI / volume;
49
50 kbox[0] = pre * box[1].cross(box[2]);
51 kbox[1] = pre * box[2].cross(box[0]);
52 kbox[2] = pre * box[0].cross(box[1]);
53
54 eta = ewaldSetup.params.eta;
55 kCut = ewaldSetup.params.kCut;
56
57 // Compute box copies required in each direction.
59
60 // Compute k-grid (only half sphere because of symmetry)
61 for (int i = 0; i <= n[0]; ++i)
62 {
63 int sj = -n[1];
64 if (i == 0) sj = 0;
65 for (int j = sj; j <= n[1]; ++j)
66 {
67 int sk = -n[2];
68 if (i == 0 && j == 0) sk = 0;
69 for (int k = sk; k <= n[2]; ++k)
70 {
71 if (i == 0 && j == 0 && k == 0) continue;
72 Vec3D kv = i * kbox[0] + j * kbox[1] + k * kbox[2];
73 double knorm2 = kv.norm2();
74 if (kv.norm2() < kCut * kCut)
75 {
76 kvectors.push_back(kv);
77 kvectors.back().knorm2 = knorm2; // TODO: Really necessary?
78 kvectors.back().coeff = exp(-0.5 * eta * eta * knorm2)
79 * 2.0 * pre / knorm2;
80 }
81 }
82 }
83 }
84}
EwaldParameters params
Definition: EwaldSetup.h:39
std::vector< Kvector > kvectors
Vector containing all k-vectors.
Definition: Kspace.h:61
Vec3D kbox[3]
Reciprocal box vectors.
Definition: Kspace.h:59
void calculatePbcCopies(double cutoffRadius)
Compute box copies in each direction.
Definition: Kspace.cpp:86
int n[3]
Required box copies in each box vector direction.
Definition: Kspace.h:57
double eta
Width of the gaussian screening charges.
Definition: IEwaldTrunc.h:40
double kCut
Cutoff in reciprocal space.
Definition: IEwaldTrunc.h:44
Vector in 3 dimensional real space.
Definition: Vec3D.h:30
double norm2() const
Calculate square of norm of vector.
Definition: Vec3D.h:299
Vec3D cross(Vec3D const &v) const
Cross product, argument vector is second in product.
Definition: Vec3D.h:319

References calculatePbcCopies(), nnp::Vec3D::cross(), nnp::EwaldParameters::eta, eta, kbox, nnp::EwaldParameters::kCut, kCut, kvectors, n, nnp::Vec3D::norm2(), nnp::EwaldSetup::params, pre, and volume.

Referenced by nnp::Structure::calculateDAdrQ(), and nnp::Structure::calculateElectrostaticEnergy().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ calculatePbcCopies()

void KspaceGrid::calculatePbcCopies ( double  cutoffRadius)
private

Compute box copies in each direction.

Parameters
[in]cutoffRadiusCutoff radius.

TODO: This is code copy from Structure class!

Definition at line 86 of file Kspace.cpp.

87{
88 Vec3D axb;
89 Vec3D axc;
90 Vec3D bxc;
91
92 axb = kbox[0].cross(kbox[1]).normalize();
93 axc = kbox[0].cross(kbox[2]).normalize();
94 bxc = kbox[1].cross(kbox[2]).normalize();
95
96 double proja = fabs(kbox[0] * bxc);
97 double projb = fabs(kbox[1] * axc);
98 double projc = fabs(kbox[2] * axb);
99
100 n[0] = 0;
101 n[1] = 0;
102 n[2] = 0;
103 while (n[0] * proja <= cutoffRadius) n[0]++;
104 while (n[1] * projb <= cutoffRadius) n[1]++;
105 while (n[2] * projc <= cutoffRadius) n[2]++;
106
107 return;
108}
Vec3D & normalize()
Normalize vector, norm equals 1.0 afterwards.
Definition: Vec3D.h:309

References nnp::Vec3D::cross(), kbox, n, and nnp::Vec3D::normalize().

Referenced by setup().

Here is the call graph for this function:
Here is the caller graph for this function:

Member Data Documentation

◆ eta

double nnp::KspaceGrid::eta

Ewald summation eta parameter.

Definition at line 47 of file Kspace.h.

Referenced by setup().

◆ kCut

double nnp::KspaceGrid::kCut

Cutoff in reciprocal space.

Definition at line 49 of file Kspace.h.

Referenced by setup().

◆ rCut

double nnp::KspaceGrid::rCut

Cutoff in real space.

Definition at line 51 of file Kspace.h.

◆ volume

double nnp::KspaceGrid::volume

Volume of real box.

Definition at line 53 of file Kspace.h.

Referenced by setup().

◆ pre

double nnp::KspaceGrid::pre

Ewald sum prefactor \(\frac{2\pi}{V}\).

Definition at line 55 of file Kspace.h.

Referenced by setup().

◆ n

int nnp::KspaceGrid::n[3]

Required box copies in each box vector direction.

Definition at line 57 of file Kspace.h.

Referenced by calculatePbcCopies(), and setup().

◆ kbox

Vec3D nnp::KspaceGrid::kbox[3]

Reciprocal box vectors.

Definition at line 59 of file Kspace.h.

Referenced by calculatePbcCopies(), and setup().

◆ kvectors

std::vector<Kvector> nnp::KspaceGrid::kvectors

Vector containing all k-vectors.

Definition at line 61 of file Kspace.h.

Referenced by nnp::Structure::calculateDAdrQ(), nnp::Structure::calculateElectrostaticEnergy(), and setup().


The documentation for this class was generated from the following files: