Skip to content

Commit e7722b7

Browse files
committed
change default method_sto; replace 2 with 3
1 parent e62485b commit e7722b7

File tree

10 files changed

+32
-32
lines changed

10 files changed

+32
-32
lines changed

docs/input-main.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -598,8 +598,8 @@ This part of variables are used to control the parameters of stochastic DFT (SDF
598598
- Different method to do SDFT.
599599
- 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.
600600
- 2: SDFT calculates $T_n(\hat{h})\ket{\chi}$ once but need much more memory. This method is much faster. Besides, it calculate $N_e$ with $\bra{\chi}\sqrt{\hat f}\sqrt{\hat f}\ket{\chi}$, which needs smaller [nche_sto](#nche_sto). However, when memory is not enough, only method 1 can be used.
601-
- other: use 1
602-
- **Default**: 1
601+
- other: use 2
602+
- **Default**: 2
603603
604604
#### nbands_sto
605605

source/input.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ void Input::Default(void)
144144
bndpar = 1;
145145
kpar = 1;
146146
initsto_freq = 1000;
147-
method_sto = 1;
147+
method_sto = 2;
148148
cal_cond = false;
149149
dos_nche = 100;
150150
cond_nche = 20;
@@ -1940,6 +1940,10 @@ void Input::Default_2(void) // jiyy add 2019-08-04
19401940
}
19411941
if(calculation.substr(0,3) != "sto") bndpar = 1;
19421942
if(bndpar > GlobalV::NPROC) bndpar = GlobalV::NPROC;
1943+
if(method_sto != 1 || method_sto != 2)
1944+
{
1945+
method_sto = 2;
1946+
}
19431947
}
19441948
#ifdef __MPI
19451949
void Input::Bcast()

source/src_pw/sto_iter.cpp

Lines changed: 13 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ Stochastic_Iter::Stochastic_Iter()
2727
{
2828
change = false;
2929
mu0 = 0;
30-
method = 1;
30+
method = 2;
3131
}
3232

3333
Stochastic_Iter::~Stochastic_Iter()
@@ -46,12 +46,12 @@ void Stochastic_Iter::init(const int dim, int* nchip_in, const int method_in, St
4646
delete[] spolyv;
4747
const int norder = p_che->norder;
4848
this->method = method_in;
49-
if(method == 1 || method ==2) spolyv = new double [norder];
49+
if(method == 1) spolyv = new double [norder];
5050
else spolyv = new double [norder*norder];
5151
stofunc.Emin = INPUT.emin_sto;
5252
stofunc.Emax = INPUT.emax_sto;
5353

54-
if(this->method == 2 || this->method == 3)
54+
if(this->method == 2)
5555
{
5656
double tot = 0;
5757
for (int ik = 0; ik < GlobalC::kv.nks; ++ik)
@@ -184,7 +184,7 @@ void Stochastic_Iter::check_precision(const double ref, const double thr, const
184184
//precision check
185185
//==============================
186186
double error = 0;
187-
if(this->method == 1 || this->method == 2)
187+
if(this->method == 1)
188188
{
189189
error = p_che->coef_real[p_che->norder-1] * spolyv[p_che->norder-1];
190190
}
@@ -316,7 +316,7 @@ void Stochastic_Iter::calPn(const int& ik, Stochastic_WF& stowf)
316316
const int nchip_ik = nchip[ik];
317317
if(ik==0)
318318
{
319-
if(this->method == 1 || this->method == 2)
319+
if(this->method == 1)
320320
ModuleBase::GlobalFunc::ZEROS(spolyv, norder);
321321
else
322322
ModuleBase::GlobalFunc::ZEROS(spolyv, norder*norder);
@@ -338,22 +338,13 @@ void Stochastic_Iter::calPn(const int& ik, Stochastic_WF& stowf)
338338
p_che->calpolyvec_complex(&stohchi, &Stochastic_hchi::hchi_norm, pchi, this->chiallorder[ik].c, GlobalC::kv.ngk[ik], GlobalC::wf.npwx, nchip_ik);
339339
double* vec_all= (double *) this->chiallorder[ik].c;
340340
char trans = 'T';
341+
char normal = 'N';
341342
double one = 1;
342343
int LDA = GlobalC::wf.npwx * nchip_ik * 2;
343344
int M = GlobalC::wf.npwx * nchip_ik * 2; //Do not use kv.ngk[ik]
344345
int N = norder;
345346
double kweight = GlobalC::kv.wk[ik];
346-
if(this->method == 2)
347-
{
348-
int inc = 1;
349-
double* vec= (double *) pchi;
350-
dgemv_(&trans, &M, &N, &kweight, vec_all, &LDA, vec, &inc, &one, spolyv, &inc);
351-
}
352-
else if(this->method == 3)
353-
{
354-
char normal = 'N';
355-
dgemm_(&trans,&normal, &N,&N,&M,&kweight,vec_all,&LDA,vec_all,&LDA,&one,spolyv,&N);
356-
}
347+
dgemm_(&trans,&normal, &N,&N,&M,&kweight,vec_all,&LDA,vec_all,&LDA,&one,spolyv,&N);
357348
}
358349
ModuleBase::timer::tick("Stochastic_Iter", "calPn");
359350
return;
@@ -366,7 +357,7 @@ double Stochastic_Iter::calne(elecstate::ElecState* pes)
366357
KS_ne = 0;
367358
const int norder = p_che->norder;
368359
double sto_ne;
369-
if(this->method == 1 || this->method == 2)
360+
if(this->method == 1)
370361
{
371362
//Note: spolyv contains kv.wk[ik]
372363
p_che->calcoef_real(&stofunc,&Sto_Func<double>::nfd);
@@ -422,7 +413,7 @@ void Stochastic_Iter::sum_stoband(Stochastic_WF& stowf, elecstate::ElecState* pe
422413

423414
//---------------cal demet-----------------------
424415
double stodemet;
425-
if(this->method == 1 || this->method == 2)
416+
if(this->method == 1)
426417
{
427418
p_che->calcoef_real(&stofunc,&Sto_Func<double>::nfdlnfd);
428419
stodemet = BlasConnector::dot(norder,p_che->coef_real,1,spolyv,1);
@@ -456,12 +447,12 @@ void Stochastic_Iter::sum_stoband(Stochastic_WF& stowf, elecstate::ElecState* pe
456447

457448
//--------------------cal eband------------------------
458449
double sto_eband = 0;
459-
if(this->method == 1 || this->method == 2)
450+
if(this->method == 1)
460451
{
461452
p_che->calcoef_real(&stofunc,&Sto_Func<double>::nxfd);
462453
sto_eband = BlasConnector::dot(norder,p_che->coef_real,1,spolyv,1);
463454
}
464-
else if(this->method == 3)
455+
else
465456
{
466457
for(int ik = 0; ik < GlobalC::kv.nks; ++ik)
467458
{
@@ -584,7 +575,7 @@ void Stochastic_Iter::calTnchi_ik(const int& ik, Stochastic_WF& stowf)
584575
pchi = stowf.chiortho[ik].c;
585576
else
586577
pchi = stowf.chi0[ik].c;
587-
if(this->method==2 || this->method == 3)
578+
if(this->method==2)
588579
{
589580
char transa = 'N';
590581
std::complex<double> one = 1;
@@ -609,7 +600,7 @@ void Stochastic_Iter::calTnchi_ik(const int& ik, Stochastic_WF& stowf)
609600

610601
void Stochastic_Iter::cleanchiallorder()
611602
{
612-
if(this->method == 2 || this->method == 3)
603+
if(this->method == 2)
613604
{
614605
delete[] chiallorder;
615606
chiallorder = nullptr;

tests/integrate/185_PW_SDFT_5D10S_METHD2/INPUT

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ nbands_sto 10
1212

1313
nche_sto 120
1414
seed_sto 20000
15-
kpar 1
15+
kpar 2
16+
bndpar 2
1617
cal_force 1
1718
cal_stress 1
1819

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
K_POINTS
22
0
33
Gamma
4-
1 1 1 0 0 0
4+
2 2 1 0 0 0
Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
etotref -321.3205422051494793
2-
etotperatomref -160.6602711026
3-
totalforceref 4.120026
4-
totalstressref 2048.414311
5-
totaltimeref +0.33989
1+
etotref -324.2147557509094895
2+
etotperatomref -162.1073778755
3+
totalforceref 4.067434
4+
totalstressref 1839.372263
5+
totaltimeref +2.42942

tests/integrate/186_PW_SDOS_10D10S/INPUT

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ INPUT_PARAMETERS
22
#Parameters (1.General)
33
suffix autotest
44
calculation sto-scf
5+
method_sto 2
56
ntype 1
67
nbands 10
78
nbands_sto 10

tests/integrate/186_PW_SDOS_MALL/INPUT

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ INPUT_PARAMETERS
22
#Parameters (1.General)
33
suffix autotest
44
calculation sto-scf
5+
method_sto 1
56
ntype 1
67
nbands 10
78
nbands_sto 0

tests/integrate/186_PW_SKG_10D10S/INPUT

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ INPUT_PARAMETERS
22
#Parameters (1.General)
33
suffix autotest
44
calculation sto-scf
5+
method_sto 2
56
ntype 1
67
nbands 10
78
nbands_sto 10

tests/integrate/186_PW_SKG_ALL/INPUT

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ INPUT_PARAMETERS
22
#Parameters (1.General)
33
suffix autotest
44
calculation sto-scf
5+
method_sto 1
56
ntype 1
67
nbands 0
78
nbands_sto 0

0 commit comments

Comments
 (0)