Skip to content

Commit 7a68932

Browse files
Merge remote-tracking branch 'upstream/develop' into exx_pw
2 parents 52e75a5 + 9fb090c commit 7a68932

File tree

82 files changed

+2205
-1234
lines changed

Some content is hidden

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

82 files changed

+2205
-1234
lines changed

docs/advanced/input_files/input-main.md

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2027,10 +2027,13 @@ Warning: this function is not robust enough for the current version. Please try
20272027

20282028
### deepks_out_labels
20292029

2030-
- **Type**: Boolean
2030+
- **Type**: Integer
20312031
- **Availability**: numerical atomic orbital basis
2032-
- **Description**: Print labels and descriptors for DeePKS training in OUT.${suffix}. The names of these files start with "deepks".
2033-
- **Note**: In `LCAO` calculation, the path of a numerical descriptor (an `orb` file) is needed to be specified under the `NUMERICAL_DESCRIPTOR` tag in the `STRU` file. For example:
2032+
- **Description**: Print labels and descriptors for DeePKS in OUT.${suffix}. The names of these files start with "deepks".
2033+
- 0 : No output.
2034+
- 1 : Output intermediate files needed during DeePKS training.
2035+
- 2 : Output target labels for label preperation. The label files are named as `deepks_<property>.npy`, where the units and formats are the same as label files `<property>.npy` required for training, except that the first dimension (`nframes`) is excluded. System structrue files are also given in `deepks_atom.npy` and `deepks_box.npy` in the unit of *Bohr*, which means `lattice_constant` should be set to 1 when training.
2036+
- **Note**: When `deepks_out_labels` equals **1**, the path of a numerical descriptor (an `orb` file) is needed to be specified under the `NUMERICAL_DESCRIPTOR` tag in the `STRU` file. For example:
20342037

20352038
```text
20362039
NUMERICAL_ORBITAL
@@ -2040,8 +2043,8 @@ Warning: this function is not robust enough for the current version. Please try
20402043
NUMERICAL_DESCRIPTOR
20412044
jle.orb
20422045
```
2043-
2044-
- **Default**: False
2046+
This is not needed when `deepks_out_labels` equals 2.
2047+
- **Default**: 0
20452048

20462049
### deepks_scf
20472050

source/module_base/test/timer_test.cpp

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -59,19 +59,22 @@ TEST_F(TimerTest, Tick)
5959
EXPECT_GT(ModuleBase::timer::timer_pool["wavefunc"]["evc"].cpu_second,0.0001);
6060
}
6161

62+
6263
TEST_F(TimerTest, Start)
6364
{
6465
ModuleBase::timer::start();
6566
// start() called tick() once
6667
EXPECT_FALSE(ModuleBase::timer::timer_pool[""]["total"].start_flag);
6768
}
6869

70+
6971
TEST_F(TimerTest, write_to_json)
7072
{
7173
ModuleBase::timer::tick("wavefunc","evc");
7274
std::this_thread::sleep_for(std::chrono::microseconds(T_Elapse)); // 0.1 ms
7375
ModuleBase::timer::tick("wavefunc","evc");
7476
ModuleBase::timer::write_to_json("tmp.json");
77+
7578
// check if tmp.json exists
7679
ifs.open("tmp.json");
7780
EXPECT_TRUE(ifs.good());
@@ -89,9 +92,6 @@ TEST_F(TimerTest, write_to_json)
8992
content += tmp;
9093
}
9194

92-
// check if the content is correct
93-
// shuold be like this:
94-
// {"total": 0, "sub":[{"class_name": "wavefunc","sub":[{"name":"evc","cpu_second": 0.000318,"calls":2,"cpu_second_per_call":0.000159,"cpu_second_per_total": null}]}]}
9595
EXPECT_THAT(content,testing::HasSubstr("\"total\":"));
9696
EXPECT_THAT(content,testing::HasSubstr("\"sub\":[{\"class_name\":\"wavefunc\",\"sub\":[{\"name\":\"evc\",\"cpu_second\":"));
9797
EXPECT_THAT(content,testing::HasSubstr("\"calls\":2,\"cpu_second_per_call\":"));
@@ -106,25 +106,29 @@ TEST_F(TimerTest, PrintAll)
106106
ModuleBase::timer::tick("wavefunc","evc");
107107
std::this_thread::sleep_for(std::chrono::microseconds(T_Elapse)); // 0.1 ms
108108
ModuleBase::timer::tick("wavefunc","evc");
109+
109110
// call print_all
110111
ofs.open("tmp");
111112
testing::internal::CaptureStdout();
112113
ModuleBase::timer::print_all(ofs);
113114
output = testing::internal::GetCapturedStdout();
114115
ofs.close();
116+
115117
// checout output on screen
116-
std::cout << "Get captured stdout: \n" << std::endl;
117-
std::cout << output << std::endl;
118+
// std::cout << "Get captured stdout: \n" << std::endl;
119+
// std::cout << output << std::endl;
118120
EXPECT_THAT(output,testing::HasSubstr("TIME STATISTICS"));
119121
EXPECT_THAT(output,testing::HasSubstr("CLASS_NAME"));
120122
EXPECT_THAT(output,testing::HasSubstr("NAME"));
121123
EXPECT_THAT(output,testing::HasSubstr("TIME/s"));
122124
EXPECT_THAT(output,testing::HasSubstr("CALLS"));
123125
EXPECT_THAT(output,testing::HasSubstr("AVG/s"));
124126
EXPECT_THAT(output,testing::HasSubstr("PER/%"));
127+
125128
// check output in file
126129
ifs.open("tmp");
127-
std::cout << "Capture contents line by line from output file: \n" << std::endl;
130+
// std::cout << "Capture contents line by line from output file: \n" << std::endl;
131+
getline(ifs,output);
128132
getline(ifs,output);
129133
EXPECT_THAT(output,testing::HasSubstr("TIME STATISTICS"));
130134
getline(ifs,output);
@@ -139,36 +143,41 @@ TEST_F(TimerTest, PrintAll)
139143
remove("time.json");
140144
}
141145

146+
142147
TEST_F(TimerTest, PrintUntilNow)
143148
{
144149
long double time = ModuleBase::timer::print_until_now();
145150
EXPECT_TRUE(time>0.0);
146151
}
147152

153+
148154
TEST_F(TimerTest, Finish)
149155
{
150156
ModuleBase::timer::tick("wavefunc","evc");
151157
std::this_thread::sleep_for(std::chrono::microseconds(T_Elapse)); // 0.1 ms
152158
ModuleBase::timer::tick("wavefunc","evc");
159+
153160
// call print_all
154161
ofs.open("tmp");
155162
testing::internal::CaptureStdout();
156163
ModuleBase::timer::finish(ofs);
157164
output = testing::internal::GetCapturedStdout();
158165
ofs.close();
159166
// checout output on screen
160-
std::cout << "Get captured stdout: \n" << std::endl;
161-
std::cout << output << std::endl;
167+
//std::cout << "Get captured stdout: \n" << std::endl;
168+
//std::cout << output << std::endl;
162169
EXPECT_THAT(output,testing::HasSubstr("TIME STATISTICS"));
163170
EXPECT_THAT(output,testing::HasSubstr("CLASS_NAME"));
164171
EXPECT_THAT(output,testing::HasSubstr("NAME"));
165172
EXPECT_THAT(output,testing::HasSubstr("TIME/s"));
166173
EXPECT_THAT(output,testing::HasSubstr("CALLS"));
167174
EXPECT_THAT(output,testing::HasSubstr("AVG/s"));
168175
EXPECT_THAT(output,testing::HasSubstr("PER/%"));
176+
169177
// check output in file
170178
ifs.open("tmp");
171-
std::cout << "Capture contents line by line from output file: \n" << std::endl;
179+
//std::cout << "Capture contents line by line from output file: \n" << std::endl;
180+
getline(ifs,output);
172181
getline(ifs,output);
173182
EXPECT_THAT(output,testing::HasSubstr("TIME STATISTICS"));
174183
getline(ifs,output);
@@ -182,7 +191,6 @@ TEST_F(TimerTest, Finish)
182191
ifs.close();
183192
}
184193

185-
// use __MPI to activate parallel environment
186194
#ifdef __MPI
187195
int main(int argc, char **argv)
188196
{

source/module_base/test/tool_quit_test.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ TEST_F(ToolQuitTest,warningquit)
9393
ifs.open("running.log");
9494
getline(ifs,output);
9595
// test output in running.log file
96-
EXPECT_THAT(output,testing::HasSubstr("!!!!!!!"));
96+
EXPECT_THAT(output,testing::HasSubstr("-------"));
9797
ifs.close();
9898
}
9999

@@ -116,7 +116,7 @@ TEST_F(ToolQuitTest,warningquit_with_ret)
116116
ifs.open("running.log");
117117
getline(ifs,output);
118118
// test output in running.log file
119-
EXPECT_THAT(output,testing::HasSubstr("!!!!!!!"));
119+
EXPECT_THAT(output,testing::HasSubstr("-------"));
120120
ifs.close();
121121
}
122122
// use __MPI to activate parallel environment

source/module_base/timer.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -306,7 +306,7 @@ void timer::print_all(std::ofstream &ofs)
306306
/*indent=*/0,
307307
/*align=*/{/*value*/FmtTable::Align::LEFT, /*title*/FmtTable::Align::CENTER});
308308
time_statistics << class_names << names << times << calls << avgs << pers;
309-
const std::string table = "TIME STATISTICS\n" + time_statistics.str();
309+
const std::string table = "\nTIME STATISTICS\n" + time_statistics.str();
310310
std::cout<<table<<std::endl;
311311
ofs<<table<<std::endl;
312312
write_to_json("time.json");

source/module_base/tool_quit.cpp

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -68,34 +68,34 @@ void WARNING_QUIT(const std::string &file,const std::string &description,int ret
6868
{
6969
#ifdef __NORMAL
7070

71-
std::cout << " !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" << std::endl;
72-
std::cout << " NOTICE " << std::endl;
73-
std::cout << " !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" << std::endl;
71+
std::cout << " ---------------------------------------------------------" << std::endl;
72+
std::cout << " !NOTICE! " << std::endl;
73+
std::cout << " ---------------------------------------------------------" << std::endl;
7474

7575
#else
7676
std::cout << " " << std::endl;
77-
std::cout << " !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" << std::endl;
78-
std::cout << " NOTICE " << std::endl;
79-
std::cout << " !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" << std::endl;
77+
std::cout << " ---------------------------------------------------------" << std::endl;
78+
std::cout << " !NOTICE! " << std::endl;
79+
std::cout << " ---------------------------------------------------------" << std::endl;
8080
std::cout << " " << std::endl;
8181
std::cout << " " << description << std::endl;
8282
std::cout << " CHECK IN FILE : " << PARAM.globalv.global_out_dir << "warning.log" << std::endl;
8383
std::cout << " " << std::endl;
84-
std::cout << " !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" << std::endl;
85-
std::cout << " NOTICE " << std::endl;
86-
std::cout << " !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" << std::endl;
84+
std::cout << " ---------------------------------------------------------" << std::endl;
85+
std::cout << " !NOTICE! " << std::endl;
86+
std::cout << " ---------------------------------------------------------" << std::endl;
8787

8888

89-
GlobalV::ofs_running << " !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" << std::endl;
90-
GlobalV::ofs_running << " NOTICE " << std::endl;
91-
GlobalV::ofs_running << " !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" << std::endl;
89+
GlobalV::ofs_running << " ---------------------------------------------------------" << std::endl;
90+
GlobalV::ofs_running << " !NOTICE! " << std::endl;
91+
GlobalV::ofs_running << " ---------------------------------------------------------" << std::endl;
9292
GlobalV::ofs_running << std::endl;
9393
GlobalV::ofs_running << " " << description << std::endl;
9494
GlobalV::ofs_running << " CHECK IN FILE : " << PARAM.globalv.global_out_dir << "warning.log" << std::endl;
9595
GlobalV::ofs_running << std::endl;
96-
GlobalV::ofs_running << " !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" << std::endl;
96+
GlobalV::ofs_running << " ---------------------------------------------------------" << std::endl;
9797
GlobalV::ofs_running << " NOTICE " << std::endl;
98-
GlobalV::ofs_running << " !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" << std::endl;
98+
GlobalV::ofs_running << " ---------------------------------------------------------" << std::endl;
9999

100100
WARNING(file,description);
101101
GlobalV::ofs_running<<" Check in file : "<<PARAM.globalv.global_out_dir<<"warning.log"<<std::endl;
@@ -128,10 +128,10 @@ void CHECK_WARNING_QUIT(const bool error_in, const std::string &file,const std::
128128
}
129129

130130
//print error information
131-
std::cout << " !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" << std::endl;
131+
std::cout << " ---------------------------------------------------------" << std::endl;
132132
std::cout << " ERROR! " << description << std::endl;
133133
std::cout << " CHECK IN FILE : " << PARAM.globalv.global_out_dir << "warning.log" << std::endl;
134-
std::cout << " !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" << std::endl;
134+
std::cout << " ---------------------------------------------------------" << std::endl;
135135
GlobalV::ofs_running << " ERROR! CHECK IN FILE : " << PARAM.globalv.global_out_dir << "warning.log" << std::endl;
136136
GlobalV::ofs_warning << std::endl;
137137
GlobalV::ofs_warning << " ERROR! " << file << ", core " << GlobalV::MY_RANK+1 << ": " << description << std::endl;

source/module_cell/unitcell.cpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -301,9 +301,6 @@ void UnitCell::setup_cell(const std::string& fn, std::ofstream& log)
301301
assert(lat0 > 0.0);
302302
this->omega = latvec.Det() * this->lat0 * this->lat0 * this->lat0;
303303

304-
std::cout << "latvec.det=" << latvec.Det() << std::endl;
305-
std::cout << "lat0=" << lat0 << std::endl;
306-
307304

308305
if (this->omega < 0)
309306
{

source/module_elecstate/fp_energy.h

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
1+
#ifndef FP_ENERGY_H
2+
#define FP_ENERGY_H
3+
14
#include <vector>
25

36
/**
47
* @file fp_energy.h
58
* @brief This file contains all energies about first-principle calculations
69
*/
7-
#ifndef FP_ENERGY_H
8-
#define FP_ENERGY_H
910
namespace elecstate
1011
{
1112
/**
@@ -63,11 +64,11 @@ struct efermi
6364
double ef = 0.0; ///< Fermi energy
6465
double ef_up = 0.0; ///< spin up Fermi energy
6566
double ef_dw = 0.0; ///< spin down Fermi energy
66-
bool two_efermi = false; ///<
67+
bool two_efermi = false;
6768
void set_efval(const int& is, const double& ef_in);
6869
double get_efval(const int& is) const;
6970
std::vector<double> get_all_ef() const;
7071
};
7172

7273
} // namespace elecstate
73-
#endif
74+
#endif

source/module_elecstate/module_charge/charge_init.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ void Charge::init_rho(elecstate::efermi& eferm_iout,
7373
{
7474
if (is == 1) // failed at the second spin
7575
{
76-
std::cout << "Incomplete electron density file!" << std::endl;
76+
std::cout << " Incomplete electron density file." << std::endl;
7777
read_error = true;
7878
break;
7979
}
@@ -105,15 +105,15 @@ void Charge::init_rho(elecstate::efermi& eferm_iout,
105105
if (read_error)
106106
{
107107
const std::string warn_msg
108-
= " WARNING: \"init_chg\" is enabled but ABACUS failed to read charge density from file.\n"
109-
" Please check if there is SPINX_CHG.cube (X=1,...) or {suffix}-CHARGE-DENSITY.restart in the "
108+
= " WARNING: \"init_chg\" is enabled but ABACUS failed to read\n charge density from file.\n"
109+
" Please check if there is SPINX_CHG.cube (X=1,...) or\n {suffix}-CHARGE-DENSITY.restart in the "
110110
"directory.\n";
111-
std::cout << std::endl << warn_msg;
111+
std::cout << warn_msg;
112112
if (PARAM.inp.init_chg == "file")
113113
{
114114
ModuleBase::WARNING_QUIT("Charge::init_rho",
115-
"Failed to read in charge density from file.\nIf you want to use atomic "
116-
"charge initialization, \nplease set init_chg to atomic in INPUT.");
115+
"Failed to read in charge density from file.\n For initializing atomic "
116+
"charge in calculations,\n please set init_chg to atomic in INPUT.");
117117
}
118118
}
119119

source/module_esolver/esolver_ks.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -733,7 +733,7 @@ void ESolver_KS<T, Device>::after_all_runners(UnitCell& ucell)
733733
// 1) write information
734734
if (PARAM.inp.out_dos != 0 || PARAM.inp.out_band[0] != 0 || PARAM.inp.out_proj_band != 0)
735735
{
736-
GlobalV::ofs_running << "\n\n\n\n";
736+
GlobalV::ofs_running << "\n\n";
737737
GlobalV::ofs_running << " >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>"
738738
">>>>>>>>>>>>>>>>>>>>>>>>>"
739739
<< std::endl;
@@ -761,17 +761,17 @@ void ESolver_KS<T, Device>::after_all_runners(UnitCell& ucell)
761761
GlobalV::ofs_running << " <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<"
762762
"<<<<<<<<<<<<<<<<<<<<<<<<<"
763763
<< std::endl;
764-
GlobalV::ofs_running << "\n\n\n\n";
764+
GlobalV::ofs_running << "\n\n";
765765
}
766766

767767
// 2) write information
768768
ModuleIO::write_istate_info(this->pelec->ekb, this->pelec->wg, this->kv);
769769

770-
const int nspin0 = (PARAM.inp.nspin == 2) ? 2 : 1;
771770

772771
// 3) print out band information
773772
if (PARAM.inp.out_band[0])
774773
{
774+
const int nspin0 = (PARAM.inp.nspin == 2) ? 2 : 1;
775775
for (int is = 0; is < nspin0; is++)
776776
{
777777
std::stringstream ss2;

source/module_esolver/esolver_ks_lcao.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
#include "module_hamilt_lcao/module_deltaspin/spin_constrain.h"
99
#include "module_hamilt_lcao/module_dftu/dftu.h"
1010
#include "module_io/berryphase.h"
11+
#include "module_io/cal_ldos.h"
1112
#include "module_io/cube_io.h"
1213
#include "module_io/dos_nao.h"
1314
#include "module_io/io_dmk.h"
@@ -419,6 +420,15 @@ void ESolver_KS_LCAO<TK, TR>::after_all_runners(UnitCell& ucell)
419420
this->p_hamilt);
420421
}
421422

423+
// out ldos
424+
if (PARAM.inp.out_ldos[0])
425+
{
426+
ModuleIO::Cal_ldos<TK>::cal_ldos_lcao(reinterpret_cast<elecstate::ElecStateLCAO<TK>*>(this->pelec),
427+
this->psi[0],
428+
this->Pgrid,
429+
ucell);
430+
}
431+
422432
// 6) print out exchange-correlation potential
423433
if (PARAM.inp.out_mat_xc)
424434
{

0 commit comments

Comments
 (0)