Skip to content

Commit f40f8c9

Browse files
committed
Merge branch 'develop' of github.com:deepmodeling/abacus-develop into HSolver
2 parents db78c45 + 22887eb commit f40f8c9

File tree

174 files changed

+5751
-3719
lines changed

Some content is hidden

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

174 files changed

+5751
-3719
lines changed

README.md

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,14 @@ ABACUS is an electronic structure package based on density functional theory(DFT
1717
Please refer to our [GitHub repository](https://github.com/deepmodeling/abacus-develop) for more information and support.
1818
# Table of contents
1919

20+
- [Table of contents](#table-of-contents)
2021
- [Features](#features)
2122
- [Download and install](#download-and-install)
2223
- [Quickstart guide](#quickstart-guide)
2324
- [Input files](#input-files)
25+
- [Run ABACUS](#run-abacus)
2426
- [Output files](#output-files)
25-
- [Features](#features)
27+
- [Features](#features-1)
2628
- [Functionalities](#functionalities)
2729
- [Examples](#examples)
2830
- [For developers](#for-developers)
@@ -92,6 +94,22 @@ The following files are the central input files for ABACUS. Before executing the
9294

9395
[back to top](#readme-top)
9496

97+
## Run ABACUS
98+
99+
After putting all required input files under one folder, enter this folder.
100+
```bash
101+
cd input_folder
102+
```
103+
104+
Perform calculation by:
105+
```bash
106+
mpirun -np 4 abacus
107+
```
108+
109+
You can replace `4` with your desired number of process, typically the result of the command `nproc`.
110+
111+
[back to top](#readme-top)
112+
95113
## Output files
96114

97115
When the calculation finishes, the program will create an output directory (default: OUT.ABACUS/),

docs/input-main.md

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828

2929
- [Electronic structure (SDFT)](#electronic-structure-sdft)
3030

31-
[nbands_sto](#nbands_sto) | [nche_sto](#nche_sto) | [emin_sto](#emin_sto) | [emax_sto](#emax_sto) | [seed_sto](#seed_sto)
31+
[method_sto](#method_sto) | [nbands_sto](#nbands_sto) | [nche_sto](#nche_sto) | [emin_sto](#emin_sto) | [emax_sto](#emax_sto) | [seed_sto](#seed_sto) | [initsto_freq](#initsto_freq)
3232

3333
- [Geometry relaxation](#geometry-relaxation)
3434

@@ -469,7 +469,7 @@ calculations.
469469
#### nbands
470470
471471
- **Type**: Integer
472-
- **Description**: Number of bands to calculate. It is recommended you setup this value, especially when you use smearing techniques, more bands should be included.
472+
- **Description**: Number of Kohn-Sham orbitals to calculate. It is recommended you setup this value, especially when you use smearing techniques, more bands should be included.
473473
- **Default**:
474474
- nspin=1: 1.2\*occupied_bands, occupied_bands+10)
475475
- nspin=2: max(1.2\*nelec, nelec+20)
@@ -577,14 +577,25 @@ calculations.
577577
578578
### Electronic structure (SDFT)
579579
580-
This part of variables are used to control the parameters of stochastic DFT (SDFT), mix stochastic-deterministic DFT (MDFT), or complete-basis Chebyshev method (CT).
580+
This part of variables are used to control the parameters of stochastic DFT (SDFT), mix stochastic-deterministic DFT (MDFT), or complete-basis Chebyshev method (CT). We now support calculation of "sto-scf" and "sto-md".
581+
582+
#### method_sto
583+
584+
- **Type**: Integer
585+
- **Description**:
586+
- Different method to do SDFT.
587+
- 1: SDFT calculates $T_n(\hat{h})\ket{\chi}$ twice, where $T_n(x)$ is the n-th order Chebyshev polynomial and $\hat{h}=\frac{\hat{H}-\bar{E}}{\Delta E}$ owning eigen-value $\in(-1,1)$. This method cost less memory but slow.
588+
- 2: SDFT calculates $T_n(\hat{h})\ket{\chi}$ once but need much more memory. This method is fast but when memory is not enough. Only method 1 can be used.
589+
- other: use 1
590+
- **Default**: 1
581591
582592
#### nbands_sto
583593
584594
- **Type**: Integer
585595
- **Description**:
586596
- nbands_sto>0: Number of stochastic orbitals to calculate in SDFT and MDFT. More bands obtain more precise results or smaller stochastic errors ($ \propto 1/\sqrt{N_{\chi}}$);
587597
- nbands_sto=0: Complete basis will be used to replace stochastic orbitals with the Chebyshev method (CT) and it will get the results the same as KSDFT without stochastic errors.
598+
- If you want to do MDFT. [nbands](#nbands) which represents the number of KS orbitals should be set.
588599
- **Default**: 0
589600
590601
#### nche_sto
@@ -609,8 +620,15 @@ This part of variables are used to control the parameters of stochastic DFT (SDF
609620
610621
- **Type**: Integer
611622
- **Description**: The random seed to generate stochastic orbitals.
612-
- seed_sto>=0: Stochastic orbitals have the form of $\exp(i2\pi\theta(G))$, where $\theta$ is a uniform distribution in $(0,1)$. If seed_sto=0, the seed is decided by time(NULL).
613-
- seed_sto<=-1: Stochastic orbitals have the form of $\pm1$ with the equal probability. If seed_sto=-1, the seed is decided
623+
- seed_sto>=0: Stochastic orbitals have the form of $\exp(i2\pi\theta(G))$, where $\theta$ is a uniform distribution in $(0,1)$. If seed_sto = 0, the seed is decided by time(NULL).
624+
- seed_sto<=-1: Stochastic orbitals have the form of $\pm1$ with the equal probability. If seed_sto = -1, the seed is decided by time(NULL).
625+
- **Default**:0
626+
627+
#### initsto_freq
628+
629+
- **Type**: Integer
630+
- **Description**: Frequency (once each initsto_freq steps) to generate new stochastic orbitals when running md.
631+
- **Default**:1000
614632
615633
### Geometry relaxation
616634

source/Makefile.Objects

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,6 @@ parallel_kpoints.o\
219219
parallel_common.o\
220220
parallel_reduce.o\
221221
parallel_pw.o\
222-
ft.o\
223222
parallel_grid.o\
224223

225224
OBJS_ESOLVER=esolver.o\
@@ -273,11 +272,13 @@ diago_elpa.o\
273272
diago_iter_assist.o\
274273
hsolver_lcao.o\
275274
hsolver_pw.o\
275+
hsolver_pw_sdft.o
276276

277277
OBJ_ELECSTATES=elecstate.o\
278278
dm2d_to_grid.o\
279279
elecstate_lcao.o\
280280
elecstate_pw.o\
281+
elecstate_pw_sdft.o
281282

282283
OBJ_PSI=psi.o
283284

source/input.cpp

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,8 @@ void Input::Default(void)
143143
seed_sto = 0;
144144
bndpar = 1;
145145
kpar = 1;
146+
initsto_freq = 1000;
147+
method_sto = 1;
146148
berry_phase = false;
147149
gdir = 3;
148150
towannier90 = false;
@@ -421,6 +423,10 @@ void Input::Default(void)
421423
sigma_k = 0.6;
422424
nc_k = 0.00037;
423425

426+
//==========================================================
427+
// compensating charge donghs added on 2022-06-23
428+
//==========================================================
429+
comp_chg = 0;
424430
comp_q = 0.0;
425431
comp_l = 1.0;
426432
comp_center = 0.0;
@@ -569,6 +575,14 @@ bool Input::Read(const std::string &fn)
569575
{
570576
read_value(ifs, emin_sto);
571577
}
578+
else if (strcmp("initsto_freq", word) == 0)
579+
{
580+
read_value(ifs, initsto_freq);
581+
}
582+
else if (strcmp("method_sto", word) == 0)
583+
{
584+
read_value(ifs, method_sto);
585+
}
572586
else if (strcmp("bndpar", word) == 0)
573587
{
574588
read_value(ifs, bndpar);
@@ -1503,6 +1517,10 @@ bool Input::Read(const std::string &fn)
15031517
{
15041518
read_value(ifs, nc_k);
15051519
}
1520+
else if (strcmp("comp_chg", word) == 0)
1521+
{
1522+
read_value(ifs, comp_chg);
1523+
}
15061524
else if (strcmp("comp_q", word) == 0)
15071525
{
15081526
read_value(ifs, comp_q);
@@ -1899,6 +1917,8 @@ void Input::Bcast()
18991917
Parallel_Common::bcast_int(pw_seed);
19001918
Parallel_Common::bcast_double(emax_sto);
19011919
Parallel_Common::bcast_double(emin_sto);
1920+
Parallel_Common::bcast_int(initsto_freq);
1921+
Parallel_Common::bcast_int(method_sto);
19021922
Parallel_Common::bcast_int(bndpar);
19031923
Parallel_Common::bcast_int(kpar);
19041924
Parallel_Common::bcast_bool(berry_phase);
@@ -2189,6 +2209,12 @@ void Input::Bcast()
21892209
Parallel_Common::bcast_double(sigma_k);
21902210
Parallel_Common::bcast_double(nc_k);
21912211

2212+
Parallel_Common::bcast_bool(comp_chg);
2213+
Parallel_Common::bcast_double(comp_q);
2214+
Parallel_Common::bcast_double(comp_l);
2215+
Parallel_Common::bcast_double(comp_center);
2216+
Parallel_Common::bcast_int(comp_dim);
2217+
21922218
return;
21932219
}
21942220
#endif

source/input.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,8 @@ class Input
7070
double emax_sto; // Emax & Emin to normalize H
7171
double emin_sto;
7272
int bndpar; //parallel for stochastic/deterministic bands
73+
int initsto_freq; //frequency to init stochastic orbitals when running md
74+
int method_sto; //different methods for sdft, 1: slow, less memory 2: fast, more memory
7375

7476
//==========================================================
7577
// electrons / spin
@@ -400,7 +402,8 @@ class Input
400402
double tau;
401403
double sigma_k;
402404
double nc_k;
403-
// gauss charge
405+
// compensating charge
406+
bool comp_chg;
404407
double comp_q;
405408
double comp_l;
406409
double comp_center;

source/input_conv.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -494,6 +494,10 @@ void Input_Conv::Convert(void)
494494
GlobalV::sigma_k = INPUT.sigma_k;
495495
GlobalV::nc_k = INPUT.nc_k;
496496

497+
//-----------------------------------------------
498+
// compensating charge
499+
//-----------------------------------------------
500+
GlobalV::comp_chg = INPUT.comp_chg;
497501
GlobalC::solvent_model.comp_q = INPUT.comp_q;
498502
GlobalC::solvent_model.comp_l = INPUT.comp_l;
499503
GlobalC::solvent_model.comp_center = INPUT.comp_center;

source/module_base/global_variable.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -205,4 +205,6 @@ double eb_k = 80.0;
205205
double tau = 1.0798 * 1e-5;
206206
double sigma_k = 0.6;
207207
double nc_k = 0.00037;
208+
209+
bool comp_chg = false; // compensating charge
208210
} // namespace GlobalV

source/module_base/global_variable.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -232,5 +232,8 @@ extern double eb_k;
232232
extern double tau;
233233
extern double sigma_k;
234234
extern double nc_k;
235+
236+
// compensating charge
237+
extern bool comp_chg;
235238
} // namespace GlobalV
236239
#endif

source/module_base/math_chebyshev.h

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ class Chebyshev
104104
void calfinalvec(T *ptr,
105105
void (T::*funA)(REAL *in, REAL *out, const int),
106106
REAL *wavein, REAL *waveout,
107-
const int N, const int LDA = 1, const int m = 1);
107+
const int N, const int LDA = 1, const int m = 1); //do not define yet
108108

109109
// calfinalvec_real uses C_n[f], where f is a function of real number and A is a complex Operator.
110110
template<class T>
@@ -129,8 +129,25 @@ class Chebyshev
129129
T *ptr, void (T::*funA)(std::complex<REAL> *in, std::complex<REAL> *out, const int),
130130
std::complex<REAL> *wavein,
131131
const int N, const int LDA = 1, const int m = 1);
132-
//get T_n(x)
132+
133+
// get T_n(x)
133134
void getpolyval(REAL x, REAL* polyval, const int N);
135+
136+
// get each order of vector: {T_0(A)v, T_1(A)v, ..., T_n(A)v}
137+
// Note: use it carefully, it will cost a lot of memory!
138+
// calpolyvec_real: f(x) = \sum_n C_n*T_n(x), f is a real function
139+
template<class T>
140+
void calpolyvec_real(T *ptr,
141+
void (T::*funA)(REAL *in, REAL *out, const int),
142+
REAL *wavein, REAL *waveout,
143+
const int N, const int LDA = 1, const int m = 1);//do not define yet
144+
// calpolyvec_complex: f(x) = \sum_n C_n*T_n(x), f is a complex function
145+
template<class T>
146+
void calpolyvec_complex(T *ptr,
147+
void (T::*funA)(std::complex<REAL> *in, std::complex<REAL> *out, const int),
148+
std::complex<REAL> *wavein, std::complex<REAL> *waveout,
149+
const int N, const int LDA = 1, const int m = 1);
150+
134151

135152
// IV.
136153
// recurs fomula: v_{n+1} = 2Av_n - v_{n-1}

source/module_base/math_chebyshev_def.h

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -339,6 +339,40 @@ void Chebyshev<REAL>::calfinalvec_complex(T *ptr,
339339
return;
340340
}
341341

342+
template<typename REAL>
343+
template<class T>
344+
void Chebyshev<REAL>::calpolyvec_complex(T *ptr,
345+
void (T::*funA)(std::complex<REAL> *in, std::complex<REAL> *out, const int),
346+
std::complex<REAL> *wavein,
347+
std::complex<REAL> *polywaveout,
348+
const int N, const int LDA, const int m)
349+
{
350+
351+
assert(N>=0 && LDA >= N);
352+
int ndmxt;
353+
if(m == 1) ndmxt = N * m;
354+
else ndmxt = LDA * m;
355+
356+
std::complex<REAL> *arraynp1 = polywaveout + 2 * ndmxt;
357+
std::complex<REAL> *arrayn = polywaveout + ndmxt;
358+
std::complex<REAL> *arrayn_1 = polywaveout;
359+
360+
ModuleBase::GlobalFunc::DCOPY(wavein, arrayn_1, ndmxt);
361+
362+
//1-st order
363+
(ptr->*funA)(arrayn_1, arrayn, m);
364+
365+
//more than 1-st orders
366+
for(int ior = 2; ior < norder; ++ior)
367+
{
368+
recurs_complex(ptr, funA, arraynp1, arrayn, arrayn_1, N, LDA, m);
369+
arrayn_1 += ndmxt;
370+
arrayn += ndmxt;
371+
arraynp1 += ndmxt;
372+
}
373+
return;
374+
}
375+
342376
template<typename REAL>
343377
template<class T>
344378
void Chebyshev<REAL>::tracepolyA(

0 commit comments

Comments
 (0)