@@ -22,15 +22,16 @@ void ElecState::cal_bandgap()
2222 int nks = this ->klist ->get_nks ();
2323 double vbm = -std::numeric_limits<double >::infinity (); // Valence Band Maximum
2424 double cbm = std::numeric_limits<double >::infinity (); // Conduction Band Minimum
25+ const double threshold = 1.0e-5 ; // threshold to avoid E_gap(k) = 0
2526 for (int ib = 0 ; ib < nbands; ib++)
2627 {
2728 for (int ik = 0 ; ik < nks; ik++)
2829 {
29- if (this ->ekb (ik, ib) <= this ->eferm .ef && this ->ekb (ik, ib) > vbm)
30+ if (this ->ekb (ik, ib) <= this ->eferm .ef + threshold && this ->ekb (ik, ib) > vbm)
3031 {
3132 vbm = this ->ekb (ik, ib);
3233 }
33- if (this ->ekb (ik, ib) >= this ->eferm .ef && this ->ekb (ik, ib) < cbm)
34+ if (this ->ekb (ik, ib) > this ->eferm .ef + threshold && this ->ekb (ik, ib) < cbm)
3435 {
3536 cbm = this ->ekb (ik, ib);
3637 }
@@ -62,28 +63,29 @@ void ElecState::cal_bandgap_updw()
6263 double cbm_up = std::numeric_limits<double >::infinity ();
6364 double vbm_dw = -std::numeric_limits<double >::infinity ();
6465 double cbm_dw = std::numeric_limits<double >::infinity ();
66+ const double threshold = 1.0e-5 ;
6567 for (int ib = 0 ; ib < nbands; ib++)
6668 {
6769 for (int ik = 0 ; ik < nks; ik++)
6870 {
6971 if (this ->klist ->isk [ik] == 0 )
7072 {
71- if (this ->ekb (ik, ib) <= this ->eferm .ef_up && this ->ekb (ik, ib) > vbm_up)
73+ if (this ->ekb (ik, ib) <= this ->eferm .ef_up + threshold && this ->ekb (ik, ib) > vbm_up)
7274 {
7375 vbm_up = this ->ekb (ik, ib);
7476 }
75- if (this ->ekb (ik, ib) >= this ->eferm .ef_up && this ->ekb (ik, ib) < cbm_up)
77+ if (this ->ekb (ik, ib) > this ->eferm .ef_up + threshold && this ->ekb (ik, ib) < cbm_up)
7678 {
7779 cbm_up = this ->ekb (ik, ib);
7880 }
7981 }
8082 if (this ->klist ->isk [ik] == 1 )
8183 {
82- if (this ->ekb (ik, ib) <= this ->eferm .ef_dw && this ->ekb (ik, ib) > vbm_dw)
84+ if (this ->ekb (ik, ib) <= this ->eferm .ef_dw + threshold && this ->ekb (ik, ib) > vbm_dw)
8385 {
8486 vbm_dw = this ->ekb (ik, ib);
8587 }
86- if (this ->ekb (ik, ib) >= this ->eferm .ef_dw && this ->ekb (ik, ib) < cbm_dw)
88+ if (this ->ekb (ik, ib) > this ->eferm .ef_dw + threshold && this ->ekb (ik, ib) < cbm_dw)
8789 {
8890 cbm_dw = this ->ekb (ik, ib);
8991 }
0 commit comments