Skip to content

Commit 1468935

Browse files
authored
Fix: Resolve the output of E_bandgap (#6590)
* Fix: Resolve the output of Eband * Refactor: Remove the input parameter `out_bandgap` * Refactor: Replace PARAM.inp.nbands with this->ekb.nc in bandgap calculations
1 parent 4c72902 commit 1468935

File tree

13 files changed

+26
-57
lines changed

13 files changed

+26
-57
lines changed

docs/advanced/input_files/input-main.md

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,6 @@
147147
- [out\_band](#out_band)
148148
- [out\_proj\_band](#out_proj_band)
149149
- [out\_stru](#out_stru)
150-
- [out\_bandgap](#out_bandgap)
151150
- [out\_level](#out_level)
152151
- [out\_alllog](#out_alllog)
153152
- [out\_mat\_hs](#out_mat_hs)
@@ -1844,14 +1843,6 @@ These variables are used to control the output of properties.
18441843
- **Description**: Whether to output structure files per ionic step in geometry relaxation calculations into `OUT.${suffix}/STRU_ION${istep}_D`, where `${istep}` is the ionic step.
18451844
- **Default**: False
18461845

1847-
### out_bandgap
1848-
1849-
- **Type**: Boolean
1850-
- **Description**: Whether to print the bandgap per electronic iteration into `OUT.${suffix}/running_${calculation}.log`. The value of bandgaps can be obtained by searching for the keyword:
1851-
- [nupdown](#nupdown) > 0: `E_bandgap_up` and `E_bandgap_dw`
1852-
- [nupdown](#nupdown) = 0: `E_bandgap`
1853-
- **Default**: False
1854-
18551846
### out_level
18561847

18571848
- **Type**: String

docs/advanced/interface/TB2J.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,6 @@ out_mul 1
6666
#Parameters (4.Relaxation)
6767
ks_solver genelpa
6868
scf_nmax 200
69-
out_bandgap 0
7069
7170
#Parameters (5.LCAO)
7271
basis_type lcao

examples/03_spin_polarized/ATOM/INPUT

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@ cal_force 1
4646
cal_stress 1
4747
out_stru 1 # print STRU in OUT
4848
out_chg 0 # print CHG or not
49-
out_bandgap 1 # if bandgap and mul out, chg will out
5049
out_mul 1 # print Mulliken charge and mag of atom in mulliken.txt
5150
# out_wfc_lcao 1
5251
# out_interval 1

examples/19_dftu/NiO/INPUT

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ dft_plus_u 1
2828
orbital_corr 2 2 -1
2929
hubbard_u 5.0 5.0 0.0
3030

31-
out_bandgap 1
3231
out_chg 1
3332
out_mul 1
3433

examples/relax/pw_output/INPUT

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@ out_dos 1 # dos.txt g
3737
out_elf 1 # elf.txt
3838
out_band 1 # eig.txt
3939
out_stru 1 # g
40-
out_bandgap 1
4140

4241
out_app_flag 0
4342

source/source_esolver/esolver_ks.cpp

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -308,23 +308,20 @@ template <typename T, typename Device>
308308
void ESolver_KS<T, Device>::iter_finish(UnitCell& ucell, const int istep, int& iter, bool &conv_esolver)
309309
{
310310

311+
//----------------------------------------------------------------
312+
// 1) print out band gap
313+
//----------------------------------------------------------------
314+
if (!PARAM.globalv.two_fermi)
315+
{
316+
this->pelec->cal_bandgap();
317+
}
318+
else
319+
{
320+
this->pelec->cal_bandgap_updw();
321+
}
322+
311323
if(iter % PARAM.inp.out_freq_elec == 0)
312324
{
313-
//----------------------------------------------------------------
314-
// 1) print out band gap
315-
//----------------------------------------------------------------
316-
if (PARAM.inp.out_bandgap)
317-
{
318-
if (!PARAM.globalv.two_fermi)
319-
{
320-
this->pelec->cal_bandgap();
321-
}
322-
else
323-
{
324-
this->pelec->cal_bandgap_updw();
325-
}
326-
}
327-
328325
//----------------------------------------------------------------
329326
// 2) print out eigenvalues and occupations
330327
//----------------------------------------------------------------

source/source_estate/elecstate_energy.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@ void ElecState::cal_bandgap()
1616
this->bandgap = 0.0;
1717
return;
1818
}
19-
int nbands = PARAM.inp.nbands;
19+
// int nbands = PARAM.inp.nbands;
20+
int nbands = this->ekb.nc;
2021
int nks = this->klist->get_nks();
2122
double homo = this->ekb(0, 0);
2223
double lumo = this->ekb(0, nbands - 1);
@@ -47,7 +48,8 @@ void ElecState::cal_bandgap_updw()
4748
this->bandgap_dw = 0.0;
4849
return;
4950
}
50-
int nbands = PARAM.inp.nbands;
51+
// int nbands = PARAM.inp.nbands;
52+
int nbands = this->ekb.nc;
5153
int nks = this->klist->get_nks();
5254
double homo_up = this->ekb(0, 0);
5355
double lumo_up = this->ekb(0, nbands - 1);

source/source_estate/elecstate_print.cpp

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -276,20 +276,17 @@ void print_etot(const Magnetism& magnet,
276276
}
277277

278278
// print out the band gap if needed
279-
if (PARAM.inp.out_bandgap)
279+
if (!PARAM.globalv.two_fermi)
280280
{
281-
if (!PARAM.globalv.two_fermi)
282-
{
283-
titles.push_back("E_bandgap");
284-
energies_Ry.push_back(elec.bandgap);
285-
}
286-
else
287-
{
288-
titles.push_back("E_bandgap_up");
289-
energies_Ry.push_back(elec.bandgap_up);
290-
titles.push_back("E_bandgap_dw");
291-
energies_Ry.push_back(elec.bandgap_dw);
292-
}
281+
titles.push_back("E_bandgap");
282+
energies_Ry.push_back(elec.bandgap);
283+
}
284+
else
285+
{
286+
titles.push_back("E_bandgap_up");
287+
energies_Ry.push_back(elec.bandgap_up);
288+
titles.push_back("E_bandgap_dw");
289+
energies_Ry.push_back(elec.bandgap_dw);
293290
}
294291
energies_eV.resize(energies_Ry.size());
295292
std::transform(energies_Ry.begin(), energies_Ry.end(), energies_eV.begin(), [](double ener) {

source/source_estate/test/elecstate_print_test.cpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,6 @@ TEST_F(ElecStatePrintTest, PrintEtot)
135135
PARAM.input.efield_flag = true;
136136
PARAM.input.gate_flag = true;
137137
PARAM.sys.two_fermi = true;
138-
PARAM.input.out_bandgap = true;
139138
GlobalV::MY_RANK = 0;
140139
PARAM.input.basis_type = "pw";
141140
PARAM.input.nspin = 2;
@@ -221,7 +220,6 @@ TEST_F(ElecStatePrintTest, PrintEtotColorS2)
221220
PARAM.input.efield_flag = true;
222221
PARAM.input.gate_flag = true;
223222
PARAM.sys.two_fermi = true;
224-
PARAM.input.out_bandgap = true;
225223
PARAM.input.nspin = 2;
226224
GlobalV::MY_RANK = 0;
227225

@@ -251,7 +249,6 @@ TEST_F(ElecStatePrintTest, PrintEtotColorS4)
251249
PARAM.input.efield_flag = true;
252250
PARAM.input.gate_flag = true;
253251
PARAM.sys.two_fermi = true;
254-
PARAM.input.out_bandgap = true;
255252
PARAM.input.nspin = 4;
256253
PARAM.input.noncolin = true;
257254
GlobalV::MY_RANK = 0;

source/source_io/module_parameter/input_parameter.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -379,7 +379,6 @@ struct Input_para
379379
std::string out_level = "ie"; ///< control the output information.
380380
std::vector<int> out_dmr = {0, 8}; ///< output density matrix in real space DM(R)
381381
std::vector<int> out_dmk = {0, 8}; ///< output density matrix in reciprocal space DM(k)
382-
bool out_bandgap = false; ///< QO added for bandgap printing
383382
std::vector<int> out_mat_hs = {0, 8}; ///< output H matrix and S matrix in local basis.
384383
std::vector<int> out_mat_tk = {0, 8}; ///< output T(k) matrix in local basis.
385384
std::vector<int> out_mat_l = {0, 8}; ///< output L matrix in local basis.

0 commit comments

Comments
 (0)