Skip to content

Commit 2e95214

Browse files
committed
prepare for PR
2 parents 2313f46 + 9f960a5 commit 2e95214

File tree

184 files changed

+5520
-5498
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

184 files changed

+5520
-5498
lines changed

docs/advanced/input_files/input-main.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1392,7 +1392,7 @@ These variables are used to control the geometry relaxation.
13921392

13931393
- **Type**: Integer
13941394
- **Description**: The maximal number of ionic iteration steps, the minimum value is 1.
1395-
- **Default**: 1
1395+
- **Default**: 1 for SCF, 50 for relax and cell-relax calcualtions
13961396

13971397
### relax_cg_thr
13981398

@@ -2928,7 +2928,7 @@ These variables are used to control DFT+U correlated parameters
29282928

29292929
- where $\gamma$ is a parameter that adjusts the relative weight of the error function to the derivative error function.
29302930
- **Unit**: Bohr
2931-
- **Default**: 5.0
2931+
- **Default**: 3.0
29322932

29332933
[back to top](#full-list-of-input-keywords)
29342934

source/Makefile.Objects

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,6 @@ OBJS_ELECSTAT=elecstate.o\
230230
pot_xc.o\
231231

232232
OBJS_ELECSTAT_LCAO=elecstate_lcao.o\
233-
elecstate_lcao_tddft.o\
234233
elecstate_lcao_cal_tau.o\
235234
density_matrix.o\
236235
density_matrix_io.o\
@@ -255,10 +254,9 @@ OBJS_ESOLVER=esolver.o\
255254
OBJS_ESOLVER_LCAO=esolver_ks_lcao.o\
256255
esolver_ks_lcao_tddft.o\
257256
dpks_cal_e_delta_band.o\
258-
dftu_cal_occup_m.o\
259257
set_matrix_grid.o\
260258
lcao_before_scf.o\
261-
lcao_gets.o\
259+
esolver_gets.o\
262260
lcao_others.o\
263261
lcao_init_after_vc.o\
264262

@@ -321,7 +319,7 @@ OBJS_HAMILT_LCAO=hamilt_lcao.o\
321319
op_dftu_lcao.o\
322320
deepks_lcao.o\
323321
op_exx_lcao.o\
324-
sc_lambda_lcao.o\
322+
dspin_lcao.o\
325323
dftu_lcao.o\
326324

327325
OBJS_HCONTAINER=base_matrix.o\
@@ -686,7 +684,9 @@ OBJS_VDW=vdw.o\
686684
vdwd3_parameters.o\
687685
vdwd2.o\
688686
vdwd3.o\
689-
vdwd3_parameters_tab.o
687+
vdwd3_parameters_tab.o\
688+
vdwd3_autoset_xcname.o\
689+
vdwd3_autoset_xcparam.o
690690

691691
OBJS_DFTU=dftu.o\
692692
dftu_force.o\
@@ -698,14 +698,11 @@ OBJS_DFTU=dftu.o\
698698
dftu_hamilt.o
699699

700700
OBJS_DELTASPIN=basic_funcs.o\
701-
cal_h_lambda.o\
702701
cal_mw_from_lambda.o\
703-
cal_mw_helper.o\
704702
cal_mw.o\
705703
init_sc.o\
706704
lambda_loop_helper.o\
707705
lambda_loop.o\
708-
sc_parse_json.o\
709706
spin_constrain.o\
710707
template_helpers.o\
711708

source/driver_run.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,13 +67,16 @@ void Driver::driver_run() {
6767
Relax_Driver rl_driver;
6868
rl_driver.relax_driver(p_esolver);
6969
}
70+
else if (cal_type == "get_S")
71+
{
72+
p_esolver->runner(0, GlobalC::ucell);
73+
}
7074
else
7175
{
7276
//! supported "other" functions:
7377
//! get_pchg(LCAO),
7478
//! test_memory(PW,LCAO),
7579
//! test_neighbour(LCAO),
76-
//! get_S(LCAO),
7780
//! gen_bessel(PW), et al.
7881
const int istep = 0;
7982
p_esolver->others(istep);

source/module_base/test/CMakeLists.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,11 @@ AddTest(
230230
SOURCES formatter_test.cpp
231231
)
232232

233+
AddTest(
234+
TARGET lebedev_laikov
235+
SOURCES test_lebedev_laikov.cpp ../ylm.cpp ../math_lebedev_laikov.cpp
236+
)
237+
233238
if(ENABLE_GOOGLEBENCH)
234239
AddTest(
235240
TARGET perf_sphbes
Lines changed: 152 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,152 @@
1+
#include "module_base/math_lebedev_laikov.h"
2+
#include "module_base/ylm.h"
3+
4+
#include "gtest/gtest.h"
5+
#include <random>
6+
#ifdef __MPI
7+
#include <mpi.h>
8+
#endif
9+
10+
using ModuleBase::Lebedev_laikov_grid;
11+
12+
// mock the function to prevent unnecessary dependency
13+
namespace ModuleBase {
14+
void WARNING_QUIT(const std::string&, const std::string&) {}
15+
}
16+
17+
class LebedevLaikovTest: public ::testing::Test {
18+
protected:
19+
void randgen(int lmax, std::vector<double>& coef);
20+
const double tol = 1e-12;
21+
};
22+
23+
24+
void LebedevLaikovTest::randgen(int lmax, std::vector<double>& coef) {
25+
coef.resize((lmax + 1) * (lmax + 1));
26+
27+
// fill coef with uniformly distributed random numbers
28+
std::random_device rd;
29+
std::mt19937 gen(rd());
30+
std::uniform_real_distribution<double> dis(0.0, 1.0);
31+
for (size_t i = 0; i < coef.size(); ++i) {
32+
coef[i] = dis(gen);
33+
}
34+
35+
// normalize the coefficients
36+
double fac = 0.0;
37+
for (size_t i = 0; i < coef.size(); ++i) {
38+
fac += coef[i] * coef[i];
39+
}
40+
41+
fac = 1.0 / std::sqrt(fac);
42+
for (size_t i = 0; i < coef.size(); ++i) {
43+
coef[i] *= fac;
44+
}
45+
}
46+
47+
48+
TEST_F(LebedevLaikovTest, Accuracy) {
49+
/*
50+
* Given
51+
*
52+
* f = c[0]*Y00 + c[1]*Y10 + c[2]*Y11 + ...,
53+
*
54+
* where c[0], c[1], c[2], ... are some random numbers, the integration
55+
* of |f|^2 on the unit sphere
56+
*
57+
* \int |f|^2 d\Omega = c[0]^2 + c[1]^2 + c[2]^2 + ... .
58+
*
59+
* This test verifies with the above integral that quadrature with
60+
* Lebedev grid is exact up to floating point errors.
61+
*
62+
*/
63+
64+
// (ngrid, lmax)
65+
std::set<std::pair<int, int>> supported = {
66+
{6, 3},
67+
{14, 5},
68+
{26, 7},
69+
{38, 9},
70+
{50, 11},
71+
{74, 13},
72+
{86, 15},
73+
{110, 17},
74+
{146, 19},
75+
{170, 21},
76+
{194, 23},
77+
{230, 25},
78+
{266, 27},
79+
{302, 29},
80+
{350, 31},
81+
{434, 35},
82+
{590, 41},
83+
{770, 47},
84+
{974, 53},
85+
{1202, 59},
86+
{1454, 65},
87+
{1730, 71},
88+
{2030, 77},
89+
{2354, 83},
90+
{2702, 89},
91+
{3074, 95},
92+
{3470, 101},
93+
{3890, 107},
94+
{4334, 113},
95+
{4802, 119},
96+
{5294, 125},
97+
{5810, 131},
98+
};
99+
100+
std::vector<double> coef;
101+
102+
for (auto& grid_info: supported) {
103+
int ngrid = grid_info.first;
104+
int grid_lmax = grid_info.second;
105+
106+
Lebedev_laikov_grid lebgrid(ngrid);
107+
lebgrid.generate_grid_points();
108+
109+
const double* weight = lebgrid.get_weight();
110+
const ModuleBase::Vector3<double>* grid = lebgrid.get_grid_coor();
111+
112+
int func_lmax = grid_lmax / 2;
113+
randgen(func_lmax, coef);
114+
115+
double val = 0.0;
116+
std::vector<double> ylm_real;
117+
for (int i = 0; i < ngrid; i++) {
118+
ModuleBase::Ylm::sph_harm(func_lmax,
119+
grid[i].x, grid[i].y, grid[i].z, ylm_real);
120+
double tmp = 0.0;
121+
for (size_t j = 0; j < coef.size(); ++j) {
122+
tmp += coef[j] * ylm_real[j];
123+
}
124+
val += weight[i] * tmp * tmp;
125+
}
126+
127+
double val_ref = 0.0;
128+
for (size_t i = 0; i < coef.size(); ++i) {
129+
val_ref += coef[i] * coef[i];
130+
}
131+
132+
double abs_diff = std::abs(val - val_ref);
133+
EXPECT_LT(abs_diff, tol);
134+
}
135+
}
136+
137+
138+
int main(int argc, char** argv)
139+
{
140+
#ifdef __MPI
141+
MPI_Init(&argc, &argv);
142+
#endif
143+
144+
testing::InitGoogleTest(&argc, argv);
145+
int result = RUN_ALL_TESTS();
146+
147+
#ifdef __MPI
148+
MPI_Finalize();
149+
#endif
150+
151+
return result;
152+
}

source/module_basis/module_ao/parallel_orbitals.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,10 @@ int Parallel_Orbitals::set_nloc_wfc_Eij(
247247
}
248248
else
249249
{
250-
ModuleBase::WARNING_QUIT("Parallel_Orbitals::set_nloc_wfc_Eij", "some processor has no bands-row-blocks.");
250+
ModuleBase::WARNING_QUIT("Parallel_Orbitals::set_nloc_wfc_Eij",
251+
"The number of columns of the 2D process grid exceeds the number of bands. "
252+
"Try launching the calculation with fewer MPI processes."
253+
);
251254
}
252255
}
253256
int col_b_bands = block / dim1;

source/module_basis/module_nao/two_center_bundle.cpp

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ void TwoCenterBundle::tabulate()
6363
{
6464
ModuleBase::SphericalBesselTransformer sbt(true);
6565
orb_->set_transformer(sbt);
66-
beta_->set_transformer(sbt);
66+
if (beta_) { beta_->set_transformer(sbt); }
6767
if (alpha_) {
6868
alpha_->set_transformer(sbt);
6969
}
@@ -75,22 +75,17 @@ void TwoCenterBundle::tabulate()
7575
// build two-center integration tables
7676
//================================================================
7777
// set up a universal radial grid
78-
double rmax = std::max(orb_->rcut_max(), beta_->rcut_max());
79-
if (alpha_) {
80-
rmax = std::max(rmax, alpha_->rcut_max());
81-
}
78+
double rmax = orb_->rcut_max();
79+
if (beta_) { rmax = std::max(rmax, beta_->rcut_max()); }
80+
if (alpha_) { rmax = std::max(rmax, alpha_->rcut_max()); }
8281
double dr = 0.01;
8382
double cutoff = 2.0 * rmax;
8483
int nr = static_cast<int>(rmax / dr) + 1;
8584

8685
orb_->set_uniform_grid(true, nr, cutoff, 'i', true);
87-
beta_->set_uniform_grid(true, nr, cutoff, 'i', true);
88-
if (alpha_) {
89-
alpha_->set_uniform_grid(true, nr, cutoff, 'i', true);
90-
}
91-
if (orb_onsite_) {
92-
orb_onsite_->set_uniform_grid(true, nr, cutoff, 'i', true);
93-
}
86+
if (beta_) { beta_->set_uniform_grid(true, nr, cutoff, 'i', true); }
87+
if (alpha_) { alpha_->set_uniform_grid(true, nr, cutoff, 'i', true);}
88+
if (orb_onsite_) { orb_onsite_->set_uniform_grid(true, nr, cutoff, 'i', true);}
9489

9590
// build TwoCenterIntegrator objects
9691
kinetic_orb = std::unique_ptr<TwoCenterIntegrator>(new TwoCenterIntegrator);
@@ -101,9 +96,12 @@ void TwoCenterBundle::tabulate()
10196
overlap_orb->tabulate(*orb_, *orb_, 'S', nr, cutoff);
10297
ModuleBase::Memory::record("TwoCenterTable: Overlap", overlap_orb->table_memory());
10398

104-
overlap_orb_beta = std::unique_ptr<TwoCenterIntegrator>(new TwoCenterIntegrator);
105-
overlap_orb_beta->tabulate(*orb_, *beta_, 'S', nr, cutoff);
106-
ModuleBase::Memory::record("TwoCenterTable: Nonlocal", overlap_orb_beta->table_memory());
99+
if (beta_)
100+
{
101+
overlap_orb_beta = std::unique_ptr<TwoCenterIntegrator>(new TwoCenterIntegrator);
102+
overlap_orb_beta->tabulate(*orb_, *beta_, 'S', nr, cutoff);
103+
ModuleBase::Memory::record("TwoCenterTable: Nonlocal", overlap_orb_beta->table_memory());
104+
}
107105

108106
if (alpha_)
109107
{

source/module_basis/module_pw/CMakeLists.txt

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,17 @@ if (ENABLE_FLOAT_FFTW)
33
module_fft/fft_cpu_float.cpp
44
)
55
endif()
6+
if (USE_CUDA)
7+
list (APPEND FFT_SRC
8+
module_fft/fft_cuda.cpp
9+
)
10+
endif()
11+
if (USE_ROCM)
12+
list (APPEND FFT_SRC
13+
module_fft/fft_rcom.cpp
14+
)
15+
endif()
16+
617
list(APPEND objects
718
fft.cpp
819
pw_basis.cpp

source/module_basis/module_pw/module_fft/fft_base.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,11 @@ class FFT_BASE
3030
bool gamma_only_in,
3131
bool xprime_in = true);
3232

33+
virtual __attribute__((weak))
34+
void initfft(int nx_in,
35+
int ny_in,
36+
int nz_in);
37+
3338
/**
3439
* @brief Setup the fft Plan and data As pure virtual function.
3540
*

0 commit comments

Comments
 (0)