Skip to content

Commit 80c5265

Browse files
authored
Reformat running log, delete 'printe' command in INPUT and fix the output eigenvalue information issue (deepmodeling#6326)
* update output files * keep updating the output information in running log * update output formats * change the file name of write_istate_info write_eig_occ * update output of band information * update output of eigenvalues, delete useless functions * adjust output formats in running log * close screen output of stress * update documents, delete printe variable and use out_band command * update examples * update lbfgs output of coordinates * update CMakeLists.txt in module_io * update write_eig_occ_test.cpp * fix some tests * fix io tests * update bessel_basis warning information * fix extracting the keep information ibz * fix tests in cell * fix some output formats * update some INPUTs * update outputtest * update pband * update DOS info * fix two tests * update dH and T(R) matrix output information * update elecstate_print_test * update file name of dH/dR * update examples of dhrxs1 * update test
1 parent eb9b228 commit 80c5265

File tree

80 files changed

+841
-926
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

80 files changed

+841
-926
lines changed

docs/advanced/input_files/input-main.md

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,6 @@
8686
- [mixing\_tau](#mixing_tau)
8787
- [mixing\_dftu](#mixing_dftu)
8888
- [gamma\_only](#gamma_only)
89-
- [printe](#printe)
9089
- [scf\_nmax](#scf_nmax)
9190
- [scf\_thr](#scf_thr)
9291
- [scf\_ene\_thr](#scf_ene_thr)
@@ -1253,12 +1252,6 @@ Note: In new angle mixing, you should set `mixing_beta_mag >> mixing_beta`. The
12531252

12541253
- **Default**: 0
12551254

1256-
### printe
1257-
1258-
- **Type**: Integer
1259-
- **Description**: Print out energy for each band for every printe step
1260-
- **Default**: `scf_nmax`
1261-
12621255
### scf_nmax
12631256

12641257
- **Type**: Integer
@@ -1772,7 +1765,7 @@ These variables are used to control the output of properties.
17721765
### out_band
17731766

17741767
- **Type**: Boolean \[Integer\](optional)
1775-
- **Description**: Whether to output the eigenvalues of Hamiltonian matrix (in eV), optionally output precision can be set by a second parameter, default is 8. The output file names are:
1768+
- **Description**: Whether to output the eigenvalues of the Hamiltonian matrix (in eV) into the running log during electronic iterations and into a file at the end of calculations. The former can be used with the 'out_freq_elec' parameter while the latter option allows the output precision to be set via a second parameter, with a default value of 8. The output file names are:
17761769
- nspin = 1 or 4: `eigs1.txt`;
17771770
- nspin = 2: `eigs1.txt` and `eigs2.txt`;
17781771
- For more information, refer to the [band.md](../elec_properties/band.md)
@@ -1864,7 +1857,7 @@ These variables are used to control the output of properties.
18641857

18651858
- **Type**: Boolean
18661859
- **Availability**: Numerical atomic orbital basis (not gamma-only algorithm)
1867-
- **Description**: Generate files containing the kinetic energy matrix $T(R)$. The format will be the same as the Hamiltonian matrix $H(R)$ and overlap matrix $S(R)$ as mentioned in [out_mat_hs2](#out_mat_hs2). The name of the files will be `trs1.csr` and so on. Also controled by [out_interval](#out_interval) and [out_app_flag](#out_app_flag).
1860+
- **Description**: Generate files containing the kinetic energy matrix $T(R)$. The format will be the same as the Hamiltonian matrix $H(R)$ and overlap matrix $S(R)$ as mentioned in [out_mat_hs2](#out_mat_hs2). The name of the files will be `trs1_nao.csr` and so on. Also controled by [out_interval](#out_interval) and [out_app_flag](#out_app_flag).
18681861
- **Default**: False
18691862
- **Unit**: Ry
18701863
- **Note**: In the 3.10-LTS version, the file name is data-TR-sparse_SPIN0.csr.
@@ -1873,7 +1866,7 @@ These variables are used to control the output of properties.
18731866

18741867
- **Type**: Boolean
18751868
- **Availability**: Numerical atomic orbital basis (not gamma-only algorithm)
1876-
- **Description**: Whether to print files containing the derivatives of the Hamiltonian matrix. The format will be the same as the Hamiltonian matrix $H(R)$ and overlap matrix $S(R)$ as mentioned in [out_mat_hs2](#out_mat_hs2). The name of the files will be `dhrxs1.csr` and so on. Also controled by [out_interval](#out_interval) and [out_app_flag](#out_app_flag).
1869+
- **Description**: Whether to print files containing the derivatives of the Hamiltonian matrix. The format will be the same as the Hamiltonian matrix $H(R)$ and overlap matrix $S(R)$ as mentioned in [out_mat_hs2](#out_mat_hs2). The name of the files will be `dhrxs1_nao.csr`, `dhrys1_nao.csr`, `dhrzs1_nao.csr` and so on. Also controled by [out_interval](#out_interval) and [out_app_flag](#out_app_flag).
18771870
- **Default**: False
18781871
- **Unit**: Ry/Bohr
18791872
- **Note**: In the 3.10-LTS version, the file name is data-dHRx-sparse_SPIN0.csr and so on.

examples/relax/lcao_output/INPUT

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@ INPUT_PARAMETERS
33
suffix autotest
44

55
nbands 8
6-
calculation cell-relax
6+
calculation relax #cell-relax
77
ecutwfc 10
8-
scf_nmax 20
8+
scf_nmax 2
99

1010
basis_type lcao
1111
relax_nmax 5
@@ -20,6 +20,7 @@ mixing_type broyden
2020
mixing_beta 0.7
2121

2222
relax_new 0
23+
relax_method bfgs
2324

2425
pseudo_dir ../../../tests/PP_ORB
2526
orbital_dir ../../../tests/PP_ORB

examples/relax/lcao_output/STRU

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ LATTICE_VECTORS
1515
ATOMIC_POSITIONS
1616
Cartesian #Cartesian(Unit is LATTICE_CONSTANT)
1717
Si #Name of element
18-
0.0 #Magnetic for this element.
18+
4.0 #Magnetic for this element.
1919
2 #Number of atoms
20-
0.00 0.00 0.00 0 0 0 #x,y,z, move_x, move_y, move_z
21-
0.25 0.25 0.25 0 0 0
20+
0.00 0.00 0.00 1 1 1 #x,y,z, move_x, move_y, move_z
21+
0.27 0.25 0.25 1 1 1

examples/relax/pw_output/INPUT

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ INPUT_PARAMETERS
33
suffix autotest
44

55
nbands 8
6-
calculation cell-relax
6+
calculation relax
77
ecutwfc 10
88
scf_nmax 20
99

@@ -20,6 +20,7 @@ mixing_type broyden
2020
mixing_beta 0.7
2121

2222
relax_new 0
23+
relax_method lbfgs
2324

2425
pseudo_dir ../../../tests/PP_ORB
2526
orbital_dir ../../../tests/PP_ORB
@@ -30,8 +31,12 @@ out_chg 1
3031
out_pot 1
3132
out_wfc_pw 1
3233
out_dos 1
33-
out_band 1
3434
out_stru 1
3535
out_app_flag 0
3636

3737
out_interval 1
38+
kpar 2
39+
symmetry -1
40+
41+
#out_freq_elec 2
42+
#out_band 1

examples/relax/pw_output/STRU

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,4 @@ Si #Name of element
1818
0.0 #Magnetic for this element.
1919
2 #Number of atoms
2020
0.00 0.00 0.00 0 0 0 #x,y,z, move_x, move_y, move_z
21-
0.25 0.25 0.25 0 0 0
21+
0.27 0.243 0.233 1 1 1

source/Makefile.Objects

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -571,7 +571,7 @@ OBJS_IO_LCAO=cal_r_overlap_R.o\
571571
write_orb_info.o\
572572
write_dos_lcao.o\
573573
write_proj_band_lcao.o\
574-
write_istate_info.o\
574+
write_eig_occ.o\
575575
get_pchg_lcao.o\
576576
get_wf_lcao.o\
577577
io_dmk.o\

source/module_elecstate/cal_nelec_nband.cpp

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -7,22 +7,22 @@ namespace elecstate {
77
void cal_nelec(const Atom* atoms, const int& ntype, double& nelec)
88
{
99
ModuleBase::TITLE("UnitCell", "cal_nelec");
10-
GlobalV::ofs_running << "\n SETUP THE ELECTRONS NUMBER" << std::endl;
10+
//GlobalV::ofs_running << "\n Setup number of electrons" << std::endl;
1111

1212
if (nelec == 0)
1313
{
1414
for (int it = 0; it < ntype; it++)
1515
{
1616
std::stringstream ss1, ss2;
17-
ss1 << "electron number of element " << atoms[it].label;
17+
ss1 << "Electron number of element " << atoms[it].label;
1818
const double nelec_it = atoms[it].ncpp.zv * atoms[it].na;
1919
nelec += nelec_it;
20-
ss2 << "total electron number of element " << atoms[it].label;
20+
ss2 << "Total electron number of element " << atoms[it].label;
2121

2222
ModuleBase::GlobalFunc::OUT(GlobalV::ofs_running, ss1.str(), atoms[it].ncpp.zv);
2323
ModuleBase::GlobalFunc::OUT(GlobalV::ofs_running, ss2.str(), nelec_it);
2424
}
25-
ModuleBase::GlobalFunc::OUT(GlobalV::ofs_running, "AUTOSET number of electrons: ", nelec);
25+
ModuleBase::GlobalFunc::OUT(GlobalV::ofs_running, "Autoset the number of electrons", nelec);
2626
}
2727
if (PARAM.inp.nelec_delta != 0)
2828
{
@@ -42,20 +42,22 @@ void cal_nbands(const int& nelec, const int& nlocal, const std::vector<double>&
4242
{
4343
return;
4444
}
45+
4546
//=======================================
4647
// calculate number of bands (setup.f90)
4748
//=======================================
4849
double occupied_bands = static_cast<double>(nelec / ModuleBase::DEGSPIN);
49-
if (PARAM.inp.lspinorb == 1) {
50-
occupied_bands = static_cast<double>(nelec);
51-
}
50+
if (PARAM.inp.lspinorb == 1)
51+
{
52+
occupied_bands = static_cast<double>(nelec);
53+
}
5254

5355
if ((occupied_bands - std::floor(occupied_bands)) > 0.0)
5456
{
5557
occupied_bands = std::floor(occupied_bands) + 1.0; // mohan fix 2012-04-16
5658
}
5759

58-
ModuleBase::GlobalFunc::OUT(GlobalV::ofs_running, "occupied bands", occupied_bands);
60+
ModuleBase::GlobalFunc::OUT(GlobalV::ofs_running, "Occupied electronic states", occupied_bands);
5961

6062
if (nbands == 0)
6163
{
@@ -89,8 +91,6 @@ void cal_nbands(const int& nelec, const int& nlocal, const std::vector<double>&
8991
}
9092
ModuleBase::GlobalFunc::AUTO_SET("NBANDS", nbands);
9193
}
92-
// else if ( PARAM.inp.calculation=="scf" || PARAM.inp.calculation=="md" || PARAM.inp.calculation=="relax") //pengfei
93-
// 2014-10-13
9494
else
9595
{
9696
if (nbands < occupied_bands) {
@@ -112,7 +112,6 @@ void cal_nbands(const int& nelec, const int& nlocal, const std::vector<double>&
112112
}
113113

114114
// mohan add 2010-09-04
115-
// std::cout << "nbands(this-> = " <<nbands <<std::endl;
116115
if (nbands == occupied_bands)
117116
{
118117
if (PARAM.inp.smearing_method != "fixed")
@@ -127,16 +126,16 @@ void cal_nbands(const int& nelec, const int& nlocal, const std::vector<double>&
127126
{
128127
if (nbands > nlocal)
129128
{
130-
ModuleBase::WARNING_QUIT("ElecState::cal_nbandsc", "NLOCAL < NBANDS");
129+
ModuleBase::WARNING_QUIT("ElecState::cal_nbands",
130+
"Number of basis (NLOCAL) < Number of electronic states (NBANDS)");
131131
}
132132
else
133133
{
134-
ModuleBase::GlobalFunc::OUT(GlobalV::ofs_running, "NLOCAL", nlocal);
135-
ModuleBase::GlobalFunc::OUT(GlobalV::ofs_running, "NBANDS", nbands);
134+
ModuleBase::GlobalFunc::OUT(GlobalV::ofs_running, "Number of basis (NLOCAL)", nlocal);
136135
}
137136
}
138137

139-
ModuleBase::GlobalFunc::OUT(GlobalV::ofs_running, "NBANDS", nbands);
138+
ModuleBase::GlobalFunc::OUT(GlobalV::ofs_running, "Number of electronic states (NBANDS)", nbands);
140139
}
141140

142-
}
141+
}

source/module_elecstate/cal_wfc.cpp

Lines changed: 36 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,8 @@ namespace elecstate
4141
}
4242
}
4343

44-
log << " " << std::setw(40) << "NLOCAL"
45-
<< " = " << nlocal_tmp << std::endl;
44+
// log << " " << std::setw(40) << "NLOCAL"
45+
// << " = " << nlocal_tmp << std::endl;
4646
//========================================================
4747
// (4) set index for itia2iat, itiaiw2iwt
4848
//========================================================
@@ -140,33 +140,38 @@ namespace elecstate
140140
void cal_natomwfc(std::ofstream& log,int& natomwfc,const int ntype,const Atom* atoms)
141141
{
142142
natomwfc = 0;
143-
for (int it = 0; it < ntype; it++) {
144-
//============================
145-
// Use pseudo-atomic orbitals
146-
//============================
147-
int tmp = 0;
148-
for (int l = 0; l < atoms[it].ncpp.nchi; l++) {
149-
if (atoms[it].ncpp.oc[l] >= 0) {
150-
if (PARAM.inp.nspin == 4) {
151-
if (atoms[it].ncpp.has_so) {
152-
tmp += 2 * atoms[it].ncpp.lchi[l];
153-
if (fabs(atoms[it].ncpp.jchi[l] - atoms[it].ncpp.lchi[l] - 0.5)< 1e-6)
154-
{
155-
tmp += 2;
156-
}
157-
} else {
158-
tmp += 2 * (2 * atoms[it].ncpp.lchi[l] + 1);
159-
}
160-
} else {
161-
tmp += 2 * atoms[it].ncpp.lchi[l] + 1;
162-
}
163-
}
164-
}
165-
natomwfc += tmp * atoms[it].na;
166-
}
167-
ModuleBase::GlobalFunc::OUT(log,
168-
"initial pseudo atomic orbital number",
169-
natomwfc);
170-
return;
143+
for (int it = 0; it < ntype; it++)
144+
{
145+
//============================
146+
// Use pseudo-atomic orbitals
147+
//============================
148+
int tmp = 0;
149+
for (int l = 0; l < atoms[it].ncpp.nchi; l++)
150+
{
151+
if (atoms[it].ncpp.oc[l] >= 0)
152+
{
153+
if (PARAM.inp.nspin == 4)
154+
{
155+
if (atoms[it].ncpp.has_so)
156+
{
157+
tmp += 2 * atoms[it].ncpp.lchi[l];
158+
if (fabs(atoms[it].ncpp.jchi[l] - atoms[it].ncpp.lchi[l] - 0.5)< 1e-6)
159+
{
160+
tmp += 2;
161+
}
162+
} else
163+
{
164+
tmp += 2 * (2 * atoms[it].ncpp.lchi[l] + 1);
165+
}
166+
} else
167+
{
168+
tmp += 2 * atoms[it].ncpp.lchi[l] + 1;
169+
}
170+
}
171+
}
172+
natomwfc += tmp * atoms[it].na;
173+
}
174+
ModuleBase::GlobalFunc::OUT(log, "Number of pseudo atomic orbitals", natomwfc);
175+
return;
171176
}
172-
}
177+
}

source/module_elecstate/elecstate_print.cpp

Lines changed: 5 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -149,56 +149,6 @@ void print_scf_iterinfo(const std::string& ks_solver,
149149
std::cout << buf;
150150
}
151151

152-
/// @brief function for printing eigenvalues : ekb
153-
/// @param ik: index of kpoints
154-
/// @param printe: print energy every 'printe' electron iteration.
155-
/// @param iter: index of iterations
156-
void print_band(const ModuleBase::matrix& ekb,
157-
const ModuleBase::matrix& wg,
158-
const K_Vectors* klist,
159-
const int& ik,
160-
const int& printe,
161-
const int& iter,
162-
std::ofstream &ofs)
163-
{
164-
const double largest_eig = 1.0e10;
165-
166-
// check the band energy.
167-
bool wrong = false;
168-
for (int ib = 0; ib < PARAM.globalv.nbands_l; ++ib)
169-
{
170-
if (std::abs(ekb(ik, ib)) > largest_eig)
171-
{
172-
GlobalV::ofs_warning << " ik=" << ik + 1 << " ib=" << ib + 1 << " " << ekb(ik, ib) << " Ry" << std::endl;
173-
wrong = true;
174-
}
175-
}
176-
if (wrong)
177-
{
178-
ModuleBase::WARNING_QUIT("print_eigenvalue", "Eigenvalues are too large!");
179-
}
180-
181-
if (GlobalV::MY_RANK == 0)
182-
{
183-
if (printe > 0 && ((iter + 1) % printe == 0))
184-
{
185-
ofs << std::setprecision(6);
186-
ofs << " Energy (eV) & Occupations for spin=" << klist->isk[ik] + 1
187-
<< " k-point=" << ik + 1 << std::endl;
188-
ofs << std::setiosflags(std::ios::showpoint);
189-
for (int ib = 0; ib < PARAM.globalv.nbands_l; ib++)
190-
{
191-
ofs << " " << std::setw(6) << ib + 1 << std::setw(15)
192-
<< ekb(ik, ib) * ModuleBase::Ry_to_eV;
193-
// for the first electron iteration, we don't have the energy
194-
// spectrum, so we can't get the occupations.
195-
ofs << std::setw(15) << wg(ik, ib);
196-
ofs << std::endl;
197-
}
198-
}
199-
}
200-
return;
201-
}
202152

203153
/// @brief print total free energy and other energies
204154
/// @param ucell: unit cell
@@ -216,7 +166,6 @@ void print_etot(const Magnetism& magnet,
216166
const double& scf_thr,
217167
const double& scf_thr_kin,
218168
const double& duration,
219-
const int printe,
220169
const double& pw_diag_thr,
221170
const double& avg_iter,
222171
const bool print)
@@ -228,7 +177,8 @@ void print_etot(const Magnetism& magnet,
228177

229178
GlobalV::ofs_running << std::setprecision(12);
230179
GlobalV::ofs_running << std::setiosflags(std::ios::right);
231-
GlobalV::ofs_running << " Electron density deviation is " << scf_thr << std::endl;
180+
181+
ModuleBase::GlobalFunc::OUT(GlobalV::ofs_running,"Electron density deviation",scf_thr);
232182

233183
if (PARAM.inp.basis_type == "pw")
234184
{
@@ -239,8 +189,8 @@ void print_etot(const Magnetism& magnet,
239189
std::vector<double> energies_Ry;
240190
std::vector<double> energies_eV;
241191

242-
if (printe > 0 && ((iter + 1) % printe == 0 || converged || iter == PARAM.inp.scf_nmax))
243-
{
192+
if( (iter % PARAM.inp.out_freq_elec == 0) || converged || iter == PARAM.inp.scf_nmax )
193+
{
244194
int n_order = std::max(0, Occupy::gaussian_type);
245195
titles.push_back("E_KohnSham");
246196
energies_Ry.push_back(elec.f_en.etot);
@@ -350,7 +300,7 @@ void print_etot(const Magnetism& magnet,
350300
FmtTable table(/*titles=*/{"Energy", "Rydberg", "eV"},
351301
/*nrows=*/titles.size(),
352302
/*formats=*/{"%-14s", "%20.10f", "%20.10f"},
353-
/*indents=*/0,
303+
/*indents=*/1,
354304
/*align=*/{/*value*/FmtTable::Align::LEFT, /*title*/FmtTable::Align::CENTER});
355305
// print out the titles
356306
table << titles << energies_Ry << energies_eV;

0 commit comments

Comments
 (0)