ABACUS develop
Atomic-orbital Based Ab-initio Computation at UStc
Loading...
Searching...
No Matches
sccs_test.h
Go to the documentation of this file.
1#ifndef SCCS_TEST_H
2#define SCCS_TEST_H
3
8#include <gtest/gtest.h>
9
10#include <cmath>
11#include <vector>
12
13namespace SccsTest
14{
15// Model charges of the open-boundary tests, mean + amplitude * cosine mode.
16// The mean gives a monopole and the mode has an analytic potential; the
17// operators are linear, so only the shape matters, and the values are of
18// valence-density size with the density kept positive.
19const double charge_mean = 1e-3;
20const double charge_amplitude = 2e-4;
21// A second charge, not proportional to the first, for symmetry checks.
22const double probe_mean = 3e-4;
23const double probe_amplitude = 1e-4;
24// Cavity density inside the water-neutral switching range (1e-4 to 5e-3), so
25// the dielectric varies in space; the small amplitude keeps it mildly
26// nonuniform and the sqrt-CG short.
27const double cavity_mean = 1e-3;
28const double cavity_amplitude = 2e-5;
29
30extern int pool_size;
31extern int pool_rank;
32// Probe kernel of a cavity without the solvent-aware filling.
33const std::vector<double> no_probe;
34
35class PwTest : public testing::Test
36{
37 protected:
38 PwTest() : basis("cpu", "double") {}
39
40 void SetUp() override
41 {
42 const ModuleBase::Matrix3 lattice(1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 1.0);
43 set_up_basis(lattice);
44 }
45
46 // Rows of lattice in units of length; ecut 20 Ry.
47 void set_up_basis(const ModuleBase::Matrix3 &lattice)
48 {
49#ifdef __MPI
51#endif
52 basis.initgrids(length, lattice, 20.0);
54 }
55
56 // Explicit FFT grid. A pool with more ranks than nz leaves ranks without
57 // real-space grid points (nrxx == 0); they still own G vectors.
59 const ModuleBase::Matrix3 &lattice,
60 int nx,
61 int ny,
62 int nz)
63 {
64#ifdef __MPI
66#endif
67 basis.initgrids(length, lattice, nx, ny, nz);
69 }
70
72 {
73 basis.initparameters(false, 20.0, 1, false);
74 basis.setuptransform();
75 basis.collect_local_pw();
77 }
78
79 // A cosine along x or y, in the PW local real-grid ordering.
80 std::vector<double> cosine_mode(int direction) const
81 {
82 std::vector<double> values(basis.nrxx);
83 for (int ir = 0; ir < basis.nrxx; ++ir)
84 {
85 const int ix = ir / (basis.ny * basis.nplane);
86 const int iy = ir / basis.nplane - ix * basis.ny;
87 const int coordinate = direction == 0 ? ix : iy;
88 const int count = direction == 0 ? basis.nx : basis.ny;
89 const double angle = ModuleBase::TWO_PI * coordinate / count;
90 values[ir] = std::cos(angle);
91 }
92 return values;
93 }
94
95 const double length = 10.0;
96 double tpiba = 0.0;
98 std::string error;
99};
100// A cell short along c on a 12 x 12 x 2 grid: with three pool ranks the
101// third owns no z plane, while the G sphere keeps sticks for every rank.
103{
104 protected:
105 void SetUp() override { set_up_grid(lattice, 12, 12, 2); }
106
107 const ModuleBase::Matrix3 lattice = ModuleBase::Matrix3(1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.25);
108};
109} // namespace SccsTest
110
111#endif
3x3 matrix and related mathamatical operations
Definition matrix3.h:15
A class which can convert a function of "r" to the corresponding linear superposition of plane waves ...
Definition pw_basis.h:60
Definition sccs_test.h:103
void SetUp() override
Definition sccs_test.h:105
const ModuleBase::Matrix3 lattice
Definition sccs_test.h:107
void set_up_basis(const ModuleBase::Matrix3 &lattice)
Definition sccs_test.h:47
void finish_basis()
Definition sccs_test.h:71
std::vector< double > cosine_mode(int direction) const
Definition sccs_test.h:80
void SetUp() override
Definition sccs_test.h:40
std::string error
Definition sccs_test.h:98
ModulePW::PW_Basis basis
Definition sccs_test.h:97
void set_up_grid(const ModuleBase::Matrix3 &lattice, int nx, int ny, int nz)
Definition sccs_test.h:58
PwTest()
Definition sccs_test.h:38
const double length
Definition sccs_test.h:95
double tpiba
Definition sccs_test.h:96
const double TWO_PI
Definition constants.h:21
Definition sccs_cell_test.h:11
const std::vector< double > no_probe
Definition sccs_test.h:33
const double charge_mean
Definition sccs_test.h:19
const double cavity_mean
Definition sccs_test.h:27
const double charge_amplitude
Definition sccs_test.h:20
const double cavity_amplitude
Definition sccs_test.h:28
int pool_size
Definition test_sccs_pw_coulomb.cpp:8
const double probe_mean
Definition sccs_test.h:22
const double probe_amplitude
Definition sccs_test.h:23
int pool_rank
Definition test_sccs_pw_coulomb.cpp:9
MPI_Comm POOL_WORLD
Definition parallel_comm.cpp:6