diff --git a/source/module_hamilt_general/module_xc/xc_functional_gradcorr.cpp b/source/module_hamilt_general/module_xc/xc_functional_gradcorr.cpp index 75acbbcfe44..4d373ef950b 100644 --- a/source/module_hamilt_general/module_xc/xc_functional_gradcorr.cpp +++ b/source/module_hamilt_general/module_xc/xc_functional_gradcorr.cpp @@ -233,9 +233,10 @@ void XC_Functional::gradcorr(double &etxc, double &vtxc, ModuleBase::matrix &v, if(arho > epsr) { grho2a = gdr1[ir].norm2(); - + + //normally values in rhotmp can either be >= 0 or < 0. if( rhotmp1[ir] >= 0.0 ) segno = 1.0; - if( rhotmp1[ir] < 0.0 ) segno = -1.0; + else segno = -1.0; if (use_libxc && is_stress) { #ifdef USE_LIBXC diff --git a/source/module_hamilt_pw/hamilt_pwdft/wavefunc.cpp b/source/module_hamilt_pw/hamilt_pwdft/wavefunc.cpp index cd66bd5fc96..ac168199670 100644 --- a/source/module_hamilt_pw/hamilt_pwdft/wavefunc.cpp +++ b/source/module_hamilt_pw/hamilt_pwdft/wavefunc.cpp @@ -779,23 +779,24 @@ int wavefunc::get_R(int ix, int iy, int iz) // pengfei 2016-11-23 } -int wavefunc::iw2it( int iw) // pengfei 2016-11-23 +int wavefunc::iw2it(int iw) // pengfei 2016-11-23 { int ic, type; - ic =0; - for(int it =0; it*** wfc return; } +//REMARK: the code next seemed to duplicate with those in +//module_hamilt_pw/hamilt/pwdft/wavefunc.cpp. int unkOverlap_lcao::iw2it(int iw) { int ic, type; ic = 0; + type = 0; for(int it = 0; it < GlobalC::ucell.ntype; it++) { for(int ia = 0; ia < GlobalC::ucell.atoms[it].na; ia++) @@ -255,7 +258,7 @@ int unkOverlap_lcao::iw2it(int iw) { if(ic == iw) { - type = it; + type = it; } ic++; } @@ -270,9 +273,10 @@ int unkOverlap_lcao::iw2ia(int iw) { int ic, na; ic = 0; + na = 0; for(int it = 0; it < GlobalC::ucell.ntype; it++) { - for(int ia = 0; ia< GlobalC::ucell.atoms[it].na; ia++) + for(int ia = 0; ia < GlobalC::ucell.atoms[it].na; ia++) { for(int L = 0; L < GlobalC::ucell.atoms[it].nwl+1; L++) { @@ -282,7 +286,7 @@ int unkOverlap_lcao::iw2ia(int iw) { if(ic == iw) { - na = ia; + na = ia; } ic++; } @@ -297,9 +301,10 @@ int unkOverlap_lcao::iw2iL(int iw) { int ic, iL; ic = 0; + iL = 0; for(int it = 0; it < GlobalC::ucell.ntype; it++) { - for(int ia = 0; ia< GlobalC::ucell.atoms[it].na; ia++) + for(int ia = 0; ia < GlobalC::ucell.atoms[it].na; ia++) { for(int L = 0; L < GlobalC::ucell.atoms[it].nwl+1; L++) { @@ -309,7 +314,7 @@ int unkOverlap_lcao::iw2iL(int iw) { if(ic == iw) { - iL = L; + iL = L; } ic++; } @@ -324,9 +329,10 @@ int unkOverlap_lcao::iw2iN(int iw) { int ic, iN; ic = 0; + iN = 0; for(int it = 0; it < GlobalC::ucell.ntype; it++) { - for(int ia = 0; ia< GlobalC::ucell.atoms[it].na; ia++) + for(int ia = 0; ia < GlobalC::ucell.atoms[it].na; ia++) { for(int L = 0; L < GlobalC::ucell.atoms[it].nwl+1; L++) { @@ -336,7 +342,7 @@ int unkOverlap_lcao::iw2iN(int iw) { if(ic == iw) { - iN = N; + iN = N; } ic++; } @@ -351,9 +357,10 @@ int unkOverlap_lcao::iw2im(int iw) { int ic, im; ic = 0; + im = 0; for(int it = 0; it < GlobalC::ucell.ntype; it++) { - for(int ia = 0; ia< GlobalC::ucell.atoms[it].na; ia++) + for(int ia = 0; ia < GlobalC::ucell.atoms[it].na; ia++) { for(int L = 0; L < GlobalC::ucell.atoms[it].nwl+1; L++) { @@ -363,7 +370,7 @@ int unkOverlap_lcao::iw2im(int iw) { if(ic == iw) { - im = i; + im = i; } ic++; } diff --git a/source/module_relax/relax_new/relax.cpp b/source/module_relax/relax_new/relax.cpp index bf4b5d0279d..06b75acb44f 100644 --- a/source/module_relax/relax_new/relax.cpp +++ b/source/module_relax/relax_new/relax.cpp @@ -411,7 +411,8 @@ void Relax::new_direction() //prepare for line search bool restart = true; double x=0, y=etot; - double xnew, yd; + //TODO: add a certain threshold for the progress. + double xnew, yd = 1e-8; this->ls.line_search(restart, x, y, f, xnew, yd);