@@ -119,29 +119,24 @@ std::vector<double> XC_Functional_Libxc::convert_sigma(
119119// sgn for threshold mask
120120std::vector<double > XC_Functional_Libxc::cal_sgn (
121121 const double rho_threshold,
122- const double grho_threshold,
123- const xc_func_type &func,
124- const int nspin,
122+ const double grho_threshold,
125123 const std::size_t nrxx,
126124 const std::vector<double > &rho,
127125 const std::vector<double > &sigma)
128126{
129- std::vector<double > sgn (nrxx*nspin , 1.0 );
127+ std::vector<double > sgn (nrxx * 2 , 1.0 ); // to be consistent with "ir*2" in the following code
130128 // in the case of GGA correlation for polarized case,
131- // a cutoff for grho is required to ensure that libxc gives reasonable results
132- if (nspin==2 && func.info ->family != XC_FAMILY_LDA && func.info ->kind ==XC_CORRELATION)
133- {
134- #ifdef _OPENMP
135- #pragma omp parallel for schedule(static, 512)
136- #endif
137- for ( int ir=0 ; ir<nrxx; ++ir )
138- {
139- if ( rho[ir*2 ]<rho_threshold || std::sqrt (std::abs (sigma[ir*3 ]))<grho_threshold )
140- sgn[ir*2 ] = 0.0 ;
141- if ( rho[ir*2 +1 ]<rho_threshold || std::sqrt (std::abs (sigma[ir*3 +2 ]))<grho_threshold )
142- sgn[ir*2 +1 ] = 0.0 ;
143- }
144- }
129+ // a cutoff for grho is required to ensure that libxc gives reasonable results
130+ #ifdef _OPENMP
131+ #pragma omp parallel for schedule(static, 512)
132+ #endif
133+ for (int ir = 0 ; ir < nrxx; ++ir)
134+ {
135+ if (rho[ir * 2 ] < rho_threshold || std::sqrt (std::abs (sigma[ir * 3 ])) < grho_threshold)
136+ sgn[ir * 2 ] = 0.0 ;
137+ if (rho[ir * 2 + 1 ] < rho_threshold || std::sqrt (std::abs (sigma[ir * 3 + 2 ])) < grho_threshold)
138+ sgn[ir * 2 + 1 ] = 0.0 ;
139+ }
145140 return sgn;
146141}
147142
0 commit comments