ABACUS develop
Atomic-orbital Based Ab-initio Computation at UStc
Loading...
Searching...
No Matches
dfpt_test_tool.h
Go to the documentation of this file.
1#ifndef DFPT_TEST_TOOL_H
2#define DFPT_TEST_TOOL_H
3
4// Shared free-function utilities for the DFPT serial unit tests
5// (module_pw test/test_tool.{h,cpp} pattern): every test file derives
6// its own gtest fixture from ::testing::Test, owns the objects it needs
7// and calls these functions -- there is no shared fixture base class.
8
9#include <complex>
10
11class UnitCell;
12namespace ModuleBase
13{
14class Matrix3;
15template <class T>
16class Vector3;
17} // namespace ModuleBase
18namespace ModulePW
19{
20class PW_Basis;
21class PW_Basis_K;
22} // namespace ModulePW
23namespace ModuleCell
24{
25class QList;
26}
27namespace ModuleDFPT
28{
29class DFPT_PW_Data;
30}
31
32namespace dfpt_test
33{
34
35// shared test-world conventions (the fixture values every test agrees on)
36constexpr double lat0 = 1.8897261254578281; // bohr
37constexpr double ecutwfc = 2.5; // Ry
38// rho cutoff inflated to 9x ecutwfc so every Delta = G''-G' of the
39// convolution lies inside the rho ball and nothing aliases
40constexpr double rho_mult = 9.0;
41constexpr double cubic_edge = 10.0; // cubic cell edge in lat0 units
42
43// Build the cubic single-atom cell (latvec / G / GT / tpiba / omega and
44// the iat2it / iat2ia wiring; the atom itself is Coulomb flavor until a
45// make_*_atom call replaces it).
46void setup_cell(UnitCell &ucell, ModuleBase::Matrix3 &latvec);
47
48// Reconfigure the cell's single atom as a bare Coulomb Z=4 atom at tau.
49void make_coulomb_atom(UnitCell &ucell);
50
51// Reconfigure the cell's single atom as a norm-conserving pseudo atom
52// (analytic Bessel projectors, no nlcc).
53void make_nc_atom(UnitCell &ucell);
54
55// Reconfigure the cell as a two-atom Z=4/Z=2 crystal breaking all
56// symmetry (masses 12/4), the second atom at the anti-blind-spot tau
57// (0.25, 0.31, 0.17).
58void make_two_atom_cell(UnitCell &ucell);
59
60// Extend the two-atom cell with a nonlinear core correction on the
61// second species: a Gaussian rho_atc of total charge 0.24 e at the
62// non-origin tau (0.25, 0.31, 0.17).
64
65// Assemble the shared rho/wfc bases for a (k, q) pair and bind the q
66// list and the data object: the rho basis at rho_mult * ecutwfc, the
67// wfc basis on the rho FFT box with the k list, the q list holding the
68// single q, and q_cart = q_frac * ucell.G. Convention: k defaults to -q
69// so the k+q ball stays inside the ground-state G list.
70void setup_bases(
71 ModulePW::PW_Basis &pw_rho,
73 ModuleCell::QList &qlist,
75 const UnitCell &ucell,
78 int nbands,
80
81// Analytic Coulomb local potential (Ry) at g2_bohr (bohr^-2) for valence
82// zv in cell volume omega, mirroring
83// vl_pw.cpp::vloc_coulomb independently of DFPT_Pert::vloc_at_g.
84double vloc_coulomb(double zv, double omega, double g2_bohr);
85
86// Analytic dVloc/dtau_alpha coefficient at displacement vector w
87// (1/lat0): dV/dtau = -i (w)_alpha tpiba Vloc exp(-i 2pi w.tau) with the
88// GS structure-factor phase convention.
89std::complex<double> analytic_dvloc(
90 const UnitCell &ucell,
92 int dir,
94
95// Integer FFT triple key (ix, iy, iz) on the cubic cell.
96long long fkey(int ix, int iy, int iz);
97// Key of g on the cubic cell (gcar * a is integral).
98long long gkey(const ModuleBase::Vector3<double> &g, double a);
99
100} // namespace dfpt_test
101
102#endif // DFPT_TEST_TOOL_H
3x3 matrix and related mathamatical operations
Definition matrix3.h:15
3 elements vector
Definition vector3.h:21
QList class for managing q-points.
Definition qlist.h:35
Definition dfpt_pw_data.h:46
Special pw_basis class. It includes different k-points.
Definition pw_basis_k.h:56
A class which can convert a function of "r" to the corresponding linear superposition of plane waves ...
Definition pw_basis.h:60
Provide the basic information about unitcell.
Definition unitcell.h:16
Definition clebsch_gordan_coeff.cpp:8
Definition qlist.cpp:19
Definition esolver_dfpt_pw.h:16
Definition pw_op.cpp:3
Definition dfpt_stru_tool.h:20
std::complex< double > analytic_dvloc(const UnitCell &ucell, const ModuleBase::Vector3< double > &tau, int dir, const ModuleBase::Vector3< double > &w)
Definition test_dfpt_fixture.cpp:231
constexpr double cubic_edge
Definition dfpt_test_tool.h:41
constexpr double lat0
Definition dfpt_test_tool.h:36
void setup_bases(ModulePW::PW_Basis &pw_rho, ModulePW::PW_Basis_K &pw_wfc, ModuleCell::QList &qlist, ModuleDFPT::DFPT_PW_Data &data, const UnitCell &ucell, const ModuleBase::Vector3< double > &k_d, const ModuleBase::Vector3< double > &q_d, int nbands, ModuleBase::Vector3< double > &q_cart)
Definition test_dfpt_fixture.cpp:184
long long gkey(const ModuleBase::Vector3< double > &g, double a)
Definition test_dfpt_fixture.cpp:250
void make_two_atom_cell(UnitCell &ucell)
Definition test_dfpt_fixture.cpp:106
void make_nlcc_two_atom_cell(UnitCell &ucell)
Definition test_dfpt_fixture.cpp:138
constexpr double ecutwfc
Definition dfpt_test_tool.h:37
void make_nc_atom(UnitCell &ucell)
Definition test_dfpt_fixture.cpp:69
double vloc_coulomb(double zv, double omega, double g2_bohr)
Definition test_dfpt_fixture.cpp:226
constexpr double rho_mult
Definition dfpt_test_tool.h:40
long long fkey(int ix, int iy, int iz)
Definition test_dfpt_fixture.cpp:248
void make_coulomb_atom(UnitCell &ucell)
Definition test_dfpt_fixture.cpp:54
void setup_cell(UnitCell &ucell, ModuleBase::Matrix3 &latvec)
Definition test_dfpt_fixture.cpp:31