Skip to content

Commit f20ad54

Browse files
authored
Merge pull request #935 from deepmodeling/SDFT
refactor:Add module_pw to Cmakelists and merge SDFT to develop branch
2 parents bb3f69c + 3e0db29 commit f20ad54

File tree

214 files changed

+15640
-3942
lines changed

Some content is hidden

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

214 files changed

+15640
-3942
lines changed

CMakeLists.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -282,6 +282,7 @@ target_link_libraries(${ABACUS_BIN_NAME}
282282
cell
283283
symmetry
284284
md
285+
planewave
285286
surchem
286287
neighbor
287288
orb
@@ -295,6 +296,10 @@ target_link_libraries(${ABACUS_BIN_NAME}
295296
ri
296297
driver
297298
xc
299+
hsolver
300+
elecstate
301+
hamilt
302+
psi
298303
esolver
299304
-lm
300305
)

source/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ add_subdirectory(module_hamilt)
88
add_subdirectory(module_hsolver)
99
add_subdirectory(module_orbital)
1010
add_subdirectory(module_md)
11+
add_subdirectory(module_pw)
1112
add_subdirectory(module_surchem)
1213
add_subdirectory(module_deepks)
1314
add_subdirectory(module_xc)

source/Makefile

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,15 @@ VPATH=./src_global\
1414
:./module_cell\
1515
:./module_base\
1616
:./module_md\
17+
:./module_pw\
1718
:./module_surchem\
1819
:./module_deepks\
1920
:./module_xc\
2021
:./module_esolver\
22+
:./module_hsolver\
23+
:./module_elecstate\
24+
:./module_psi\
25+
:./module_hamilt\
2126
:./src_pw\
2227
:./src_lcao\
2328
:./src_ions\

source/Makefile.Objects

Lines changed: 43 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,10 @@ unk_overlap_pw.o \
5959
berryphase.o \
6060
sto_iter.o\
6161
sto_wf.o\
62+
sto_func.o\
6263
sto_hchi.o\
63-
sto_che.o\
64+
sto_forces.o\
65+
sto_stress_pw.o
6466

6567
OBJS_TOOLS=complexarray.o\
6668
complexmatrix.o \
@@ -79,6 +81,7 @@ math_integral.o\
7981
math_ylmreal.o\
8082
mathzone_add1.o\
8183
math_bspline.o\
84+
math_chebyshev.o\
8285
integral.o \
8386
polint.o \
8487
sph_bessel.o \
@@ -257,12 +260,47 @@ xc_functional_wrapper_tauxc.o \
257260
xc_functional_wrapper_xc.o \
258261
xc_functional.o \
259262

263+
OBJ_PLANEWAVE=fft.o\
264+
pw_basis.o\
265+
pw_basis_k.o\
266+
pw_distributeg.o\
267+
pw_distributeg_method1.o\
268+
pw_distributeg_method2.o\
269+
pw_distributer.o\
270+
pw_init.o\
271+
pw_operation.o\
272+
pw_transform.o\
273+
pw_transform_k.o
274+
275+
OBJ_HSOLVER=diago_blas.o\
276+
diago_cg.o\
277+
diago_david.o\
278+
diago_elpa.o\
279+
diago_iter_assist.o\
280+
hsolver_lcao.o\
281+
hsolver_pw.o\
282+
283+
OBJ_ELECSTATES=elecstate.o\
284+
dm2d_to_grid.o\
285+
elecstate_lcao.o\
286+
elecstate_pw.o\
287+
288+
OBJ_PSI=psi.o
289+
290+
OBJ_HAMILT=hamilt_lcao.o\
291+
hamilt_pw.o
292+
260293
OBJS_FIRST_PRINCIPLES=$(OBJS_MAIN)\
261294
$(OBJS_PW)\
262295
$(OBJS_LCAO)\
263296
$(OBJS_ESOLVER)\
264297
$(OBJS_XC)\
265298
$(OBJS_SURCHEM)\
299+
$(OBJ_PLANEWAVE)\
300+
$(OBJ_HSOLVER)\
301+
$(OBJ_ELECSTATES)\
302+
$(OBJ_PSI)\
303+
${OBJ_HAMILT}\
266304
charge.o \
267305
charge_mixing.o \
268306
charge_pulay.o \
@@ -320,14 +358,14 @@ dmft.o \
320358

321359
OBJS_COMMON=atom_spec.o \
322360
unitcell.o \
323-
pw_basis.o\
361+
pw_basis_old.o\
324362
bspline_sf.o\
325363
hamilt.o \
326364
pw_complement.o\
327365
wf_local.o \
328-
hamilt_pw.o \
329-
diago_david.o\
330-
diago_cg.o\
366+
hamilt_pw_old.o \
367+
diago_david_old.o\
368+
diago_cg_old.o\
331369
output.o \
332370
run_md_classic.o\
333371
LJ_potential.o\

source/input.cpp

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -383,7 +383,7 @@ void Input::Default(void)
383383

384384
cell_factor = 1.2; // LiuXh add 20180619
385385

386-
GlobalV::out_mul = 0; // qi feng add 2019/9/10
386+
out_mul = 0; // qi feng add 2019/9/10
387387

388388
//---------------------------------------------------------- //Peize Lin add 2020-04-04
389389
// restart
@@ -1342,7 +1342,7 @@ bool Input::Read(const std::string &fn)
13421342
}
13431343
else if (strcmp("out_mul", word) == 0)
13441344
{
1345-
read_value(ifs, GlobalV::out_mul);
1345+
read_value(ifs, out_mul);
13461346
} // qifeng add 2019/9/10
13471347
//----------------------------------------------------------
13481348
// exx
@@ -1841,6 +1841,7 @@ void Input::Default_2(void) // jiyy add 2019-08-04
18411841
}
18421842
}
18431843
if(calculation.substr(0,3) != "sto") bndpar = 1;
1844+
if(bndpar > GlobalV::NPROC) bndpar = GlobalV::NPROC;
18441845
}
18451846
#ifdef __MPI
18461847
void Input::Bcast()
@@ -2092,7 +2093,7 @@ void Input::Bcast()
20922093
Parallel_Common::bcast_bool(test_just_neighbor);
20932094
Parallel_Common::bcast_int(GlobalV::ocp);
20942095
Parallel_Common::bcast_string(GlobalV::ocp_set);
2095-
Parallel_Common::bcast_int(GlobalV::out_mul); // qifeng add 2019/9/10
2096+
Parallel_Common::bcast_int(out_mul); // qifeng add 2019/9/10
20962097

20972098
// Peize Lin add 2018-06-20
20982099
Parallel_Common::bcast_string(dft_functional);
@@ -2314,9 +2315,9 @@ void Input::Check(void)
23142315
ModuleBase::WARNING_QUIT("Input::Check", "calculate = istate is only availble for LCAO.");
23152316
}
23162317
}
2317-
else if (calculation == "md") // mohan add 2011-11-04
2318+
else if (calculation == "md" || calculation == "sto-md") // mohan add 2011-11-04
23182319
{
2319-
GlobalV::CALCULATION = "md";
2320+
GlobalV::CALCULATION = calculation;
23202321
symmetry = false;
23212322
cal_force = 1;
23222323
if (mdp.md_nstep == 0)

source/module_base/CMakeLists.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@ add_library(
1616
math_polyint.cpp
1717
math_sphbes.cpp
1818
math_ylmreal.cpp
19-
math_bspline.cpp
19+
math_bspline.cpp
20+
math_chebyshev.cpp
2021
mathzone.cpp
2122
mathzone_add1.cpp
2223
matrix.cpp
Lines changed: 125 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,125 @@
1+
#include "./math_chebyshev.h"
2+
#include "./constants.h"
3+
#include "./blas_connector.h"
4+
#include "./global_function.h"
5+
namespace ModuleBase
6+
{
7+
//we only have two examples: double and float.
8+
template class Chebyshev<double>;
9+
#ifdef __MIX_PRECISION
10+
template class Chebyshev<float>;
11+
#endif
12+
13+
FFTW<double>::FFTW(const int norder2_in)
14+
{
15+
ccoef = (fftw_complex *) fftw_malloc(sizeof(fftw_complex) * norder2_in);
16+
dcoef = (double *) fftw_malloc(sizeof(double) * norder2_in);
17+
coef_plan = fftw_plan_dft_r2c_1d(norder2_in, dcoef, ccoef, FFTW_ESTIMATE);
18+
}
19+
FFTW<double>::~FFTW()
20+
{
21+
fftw_destroy_plan(coef_plan);
22+
fftw_free(ccoef);
23+
fftw_free(dcoef);
24+
}
25+
void FFTW<double>::execute_fftw()
26+
{
27+
fftw_execute(this->coef_plan);
28+
}
29+
30+
#ifdef __MIX_PRECISION
31+
FFTW<float>::FFTW(const int norder2_in)
32+
{
33+
ccoef = (fftwf_complex *) fftw_malloc(sizeof(fftwf_complex) * norder2_in);
34+
dcoef = (float *) fftw_malloc(sizeof(float) * norder2_in);
35+
coef_plan = fftwf_plan_dft_r2c_1d(norder2_in, dcoef, ccoef, FFTW_ESTIMATE);
36+
}
37+
FFTW<float>::~FFTW()
38+
{
39+
fftwf_destroy_plan(coef_plan);
40+
fftw_free(ccoef);
41+
fftw_free(dcoef);
42+
}
43+
void FFTW<float>::execute_fftw()
44+
{
45+
fftwf_execute(this->coef_plan);
46+
}
47+
#endif
48+
49+
//A number to control the number of grids in C_n integration
50+
#define EXTEND 16
51+
52+
template<typename REAL>
53+
Chebyshev<REAL>::Chebyshev(const int norder_in) : fftw(2 * EXTEND * norder_in)
54+
{
55+
this->norder = norder_in;
56+
norder2 = 2 * norder * EXTEND;
57+
if(this->norder < 1)
58+
{
59+
ModuleBase::WARNING_QUIT("Stochastic_Chebychev", "The Chebyshev expansion order should be at least 1!");
60+
}
61+
polytrace = new REAL [norder];
62+
coef_real = new REAL [norder];
63+
coef_complex = new std::complex<REAL> [norder];
64+
65+
// ndmin = ndmax = ndmax_in;
66+
67+
getcoef_complex = false;
68+
getcoef_real = false;
69+
}
70+
71+
template<typename REAL>
72+
Chebyshev<REAL>::~Chebyshev()
73+
{
74+
delete [] polytrace;
75+
delete [] coef_real;
76+
delete [] coef_complex;
77+
}
78+
79+
template<typename REAL>
80+
void Chebyshev<REAL>::getpolyval(const REAL x, REAL* polyval, const int N)
81+
{
82+
polyval[0] = 1;
83+
polyval[1] = x;
84+
for(int i = 2; i < N; ++i)
85+
{
86+
polyval[i] = 2 * x * polyval[i-1] - polyval[i-2];
87+
}
88+
}
89+
template<typename REAL>
90+
REAL Chebyshev<REAL>::recurs(const REAL x, const REAL Tn, REAL const Tn_1)
91+
{
92+
return 2*x*Tn-Tn_1;
93+
}
94+
95+
template<typename REAL>
96+
REAL Chebyshev<REAL>:: ddot_real(
97+
const std::complex<REAL>* psi_L,
98+
const std::complex<REAL>* psi_R,
99+
const int N, const int LDA, const int m)
100+
{
101+
REAL result = 0;
102+
if(N == LDA || m==1)
103+
{
104+
int dim2=2 * N * m;
105+
REAL *pL,*pR;
106+
pL=(REAL *)psi_L;
107+
pR=(REAL *)psi_R;
108+
result=BlasConnector::dot(dim2,pL,1,pR,1);
109+
}
110+
else
111+
{
112+
REAL *pL,*pR;
113+
pL=(REAL *)psi_L;
114+
pR=(REAL *)psi_R;
115+
for(int i = 0 ; i < m ; ++i)
116+
{
117+
int dim2=2 * N;
118+
result += BlasConnector::dot(dim2,pL,1,pR,1);
119+
pL += 2 * LDA;
120+
pR += 2 * LDA;
121+
}
122+
}
123+
return result;
124+
}
125+
}

0 commit comments

Comments
 (0)