Skip to content

Commit 96d0d7d

Browse files
committed
Merge branch 'develop' of https://github.com/ErjieWu/abacus-develop into refactor
2 parents bce3cf2 + 4adc91b commit 96d0d7d

File tree

109 files changed

+3183
-2819
lines changed

Some content is hidden

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

109 files changed

+3183
-2819
lines changed

docs/advanced/input_files/input-main.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,7 @@
153153
- [out\_mat\_t](#out_mat_t)
154154
- [out\_mat\_dh](#out_mat_dh)
155155
- [out\_mat\_xc](#out_mat_xc)
156+
- [out\_mat\_xc2](#out_mat_xc2)
156157
- [out\_eband\_terms](#out_eband_terms)
157158
- [out\_hr\_npz/out\_dm\_npz](#out_hr_npzout_dm_npz)
158159
- [dm\_to\_rho](#dm_to_rho)
@@ -1799,6 +1800,13 @@ These variables are used to control the output of properties.
17991800
The band (KS orbital) energy for each (k-point, spin, band) will be printed in the file `OUT.${suffix}/vxc_out.dat`. If EXX is calculated, the local and EXX part of band energy will also be printed in `OUT.${suffix}/vxc_local_out.dat`and `OUT.${suffix}/vxc_exx_out.dat`, respectively. All the `vxc*_out.dat` files contains 3 integers (nk, nspin, nband) followed by nk\*nspin\*nband lines of energy Hartree and eV.
18001801
- **Default**: False
18011802

1803+
### out_mat_xc2
1804+
1805+
- **Type**: Boolean
1806+
- **Availability**: Numerical atomic orbital (NAO) basis
1807+
- **Description**: Whether to print the exchange-correlation matrices in **numerical orbital representation** (unit: Ry): $\braket{\phi_i|V_\text{xc}^\text{(semi-)local}+V_\text{exx}+V_\text{DFTU}|\phi_j}(\mathbf{R})$ in CSR format (the same format as [out_mat_hs2](../elec_properties/hs_matrix.md#out_mat_hs2)) in the directory `OUT.${suffix}`. (Note that currently DeePKS term is not included. ) The files are named `Vxc_R_spin$s`.
1808+
- **Default**: False
1809+
18021810
### out_eband_terms
18031811

18041812
- **Type**: Boolean

docs/quick_start/output.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ For a complete list of input parameters, please consult this [instruction](../ad
1414

1515
`running_scf.log` contains information on nearly all function calls made during the execution of ABACUS.
1616

17-
## *KPT*
17+
## *KPT.info*
1818

1919
This file contains the information of all generated k-points, as well as the list of k-points actually used for calculations after considering symmetry.
2020

@@ -39,4 +39,4 @@ ABACUS generates a `.cif` format structure file based on the input file `STRU`,
3939

4040
## *warning.log*
4141

42-
The file contains all the warning messages generated during the ABACUS run.
42+
The file contains all the warning messages generated during the ABACUS run.

source/Makefile.Objects

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -267,6 +267,7 @@ OBJS_ESOLVER_LCAO=esolver_ks_lcao.o\
267267
lcao_after_scf.o\
268268
esolver_gets.o\
269269
lcao_others.o\
270+
esolver_dm2rho.o\
270271

271272
OBJS_GINT=gint.o\
272273
gint_gamma_env.o\
@@ -462,6 +463,14 @@ OBJS_SURCHEM=surchem.o\
462463

463464
OBJS_SYMMETRY=symm_other.o\
464465
symmetry_basic.o\
466+
symm_analysis.o\
467+
symm_check.o\
468+
symm_getgroup.o\
469+
symm_hermite.o\
470+
symm_lattice.o\
471+
symm_magnetic.o\
472+
symm_pricell.o\
473+
symm_rho.o\
465474
symmetry.o\
466475

467476
OBJS_XC=xc_functional.o\

source/driver_run.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626
void Driver::driver_run()
2727
{
2828
ModuleBase::TITLE("Driver", "driver_line");
29-
ModuleBase::timer::tick("Driver", "driver_line");
3029

3130
//! 1: setup cell and atom information
3231
// this warning should not be here, mohan 2024-05-22
@@ -93,6 +92,5 @@ void Driver::driver_run()
9392

9493
//! 6: output the json file
9594
Json::create_Json(&ucell, PARAM);
96-
ModuleBase::timer::tick("Driver", "driver_line");
9795
return;
9896
}

source/module_base/formatter.h

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -191,17 +191,22 @@ class FmtTable
191191
*
192192
* @param titles titles, its size should be the same as the number of columns
193193
* @param nrows number of rows
194-
* @param aligns Alignments instance, can be constructed with initializer_list<char> like {'r', 'c'}, for right and center alignment for values and titles
194+
* @param fmts format strings for each column, its size should be the same as the number of columns
195+
* @param indent indent for each column, default is 0
196+
* @param aligns Alignments instance, for alignment of values and titles, e.g. {Align::LEFT, Align::RIGHT} for left alignment of values and right alignment of titles
195197
* @param frames Frames instance, can be constructed with initializer_list<char> like {'-', '-', '-', ' ', ' '}, for up, middle, down, left and right frames
196198
* @param delimiters Delimiters instance, can be constructed with initializer_list<char> like {'-', ' '}, for horizontal and vertical delimiters
197199
*/
198200
FmtTable(const std::vector<std::string>& titles,
199-
const size_t& nrows,
201+
const size_t nrows,
200202
const std::vector<std::string>& fmts,
203+
const size_t indent = 0,
201204
const Alignments& aligns = {},
202205
const Frames& frames = {},
203-
const Delimiters& delimiters = {}): titles_(titles), data_(nrows, titles.size()), fmts_(fmts), aligns_(aligns), frames_(frames), delimiters_(delimiters)
204-
{ assert(titles.size() == fmts.size()); };
206+
const Delimiters& delimiters = {}):
207+
titles_(titles), data_(nrows, titles.size()), // data
208+
fmts_(fmts), indent_(indent), aligns_(aligns), frames_(frames), delimiters_(delimiters) // styles
209+
{ assert(titles.size() == fmts.size()||titles.size() == 0); };
205210
~FmtTable() {};
206211
/**
207212
* @brief import data from std::vector
@@ -269,22 +274,24 @@ class FmtTable
269274
*/
270275
std::string concat_title(const std::vector<std::string>& titles) const
271276
{
272-
std::string dst;
277+
std::string dst = "";
273278
// first sum width of all titles
274279
size_t width = std::accumulate(titles.begin(), titles.end(), 0, [](const size_t& acc, const std::string& s) { return acc + s.size(); });
275280
// add width of delimiters
276281
width += titles.size() - 1;
277282
// add width of left and right frames
278283
width += 2;
279-
dst += std::string(width, frames_.up_) + "\n" + std::string(1, frames_.l_);
284+
dst += std::string(indent_, ' ') + std::string(width, frames_.up_) + "\n"; // first line: the upper frame
285+
dst += std::string(indent_, ' ') + std::string(1, frames_.l_); // second line: the left frame + titles + right frame
280286
for(size_t i = 0; i < titles.size(); i++)
281287
{
282288
dst += titles[i];
283289
if (i != titles.size() - 1) {
284290
dst += delimiters_.v_;
285291
}
286292
}
287-
dst += std::string(1, frames_.r_) + "\n" + std::string(width, frames_.mid_) + "\n";
293+
dst += std::string(1, frames_.r_) + "\n";
294+
dst += std::string(indent_, ' ') + std::string(width, frames_.mid_) + "\n"; // third line: the middle frame
288295
return dst;
289296
}
290297
/**
@@ -303,10 +310,10 @@ class FmtTable
303310
width += row.size() - 1;
304311
// for the left and right frame
305312
width += 2;
306-
if (pos == 't') {
307-
dst += std::string(width, frames_.up_) + "\n";
313+
if (pos == 't') { // 't' for top
314+
dst += std::string(indent_, ' ') + std::string(width, frames_.up_) + "\n";
308315
}
309-
dst += std::string(1, frames_.l_);
316+
dst += std::string(indent_, ' ') + std::string(1, frames_.l_);
310317
for(size_t i = 0; i < row.size(); i++)
311318
{
312319
dst += row[i];
@@ -315,8 +322,8 @@ class FmtTable
315322
}
316323
}
317324
dst += std::string(1, frames_.r_) + "\n";
318-
if (pos == 'b') {
319-
dst += std::string(width, frames_.dw_) + "\n";
325+
if (pos == 'b') { // 'b' for bottom
326+
dst += std::string(indent_, ' ') + std::string(width, frames_.dw_) + "\n"; // the last line
320327
}
321328
return dst;
322329
}
@@ -397,6 +404,7 @@ class FmtTable
397404
std::vector<std::string> titles_;
398405
NDArray<std::string> data_; // data
399406
std::vector<std::string> fmts_; // format strings for each column
407+
size_t indent_ = 0; // indent for each column
400408
};
401409

402410
#endif

source/module_base/test/formatter_test.cpp

Lines changed: 60 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,28 @@ TEST(FormatterTest, FmtTableDefaultArgs)
217217
EXPECT_EQ(result, ref);
218218
}
219219

220+
TEST(FormatterTest, FmtTableHeadless)
221+
{
222+
const std::vector<std::string> titles = {"", "", ""};
223+
const std::vector<std::string> fmts = {"%s", "%d", "%f"};
224+
FmtTable table(titles, 5, fmts);
225+
const std::vector<std::string> col1 = {"row1", "row2", "row3", "row4", "row5"};
226+
const std::vector<int> col2 = {1, 2, 3, 4, 5};
227+
const std::vector<float> col3 = {1.1, 2.2, 3.3, 4.4, 5.5};
228+
table << col1 << col2 << col3;
229+
const std::string result = table.str();
230+
std::cout << result << std::endl;
231+
std::string ref = "";
232+
ref += "-----------------\n";
233+
ref += " row1 1 1.100000 \n";
234+
ref += " row2 2 2.200000 \n";
235+
ref += " row3 3 3.300000 \n";
236+
ref += " row4 4 4.400000 \n";
237+
ref += " row5 5 5.500000 \n";
238+
ref += "-----------------\n";
239+
EXPECT_EQ(result, ref);
240+
}
241+
220242
TEST(FormatterTest, FmtTableCustomArgsAlign)
221243
{
222244
// shared data
@@ -226,7 +248,7 @@ TEST(FormatterTest, FmtTableCustomArgsAlign)
226248
std::vector<int> col2 = {1, 2, 3, 4, 5};
227249
std::vector<float> col3 = {1.1, 2.2, 3.3, 4.4, 5.5};
228250
// align: l and l
229-
FmtTable table(titles, 5, fmts, {FmtTable::Align::LEFT, FmtTable::Align::LEFT});
251+
FmtTable table(titles, 5, fmts, 0, {FmtTable::Align::LEFT, FmtTable::Align::LEFT});
230252
table << col1 << col2 << col3;
231253
std::string result = table.str();
232254
std::cout << result << std::endl;
@@ -243,7 +265,7 @@ TEST(FormatterTest, FmtTableCustomArgsAlign)
243265
EXPECT_EQ(result, ref);
244266

245267
// align: r and r
246-
FmtTable table2(titles, 5, fmts, {FmtTable::Align::RIGHT, FmtTable::Align::RIGHT});
268+
FmtTable table2(titles, 5, fmts, 0, {FmtTable::Align::RIGHT, FmtTable::Align::RIGHT});
247269
table2 << col1 << col2 << col3;
248270
result = table2.str();
249271
std::cout << result << std::endl;
@@ -260,7 +282,7 @@ TEST(FormatterTest, FmtTableCustomArgsAlign)
260282
EXPECT_EQ(result, ref);
261283

262284
// align: l and r
263-
FmtTable table3(titles, 5, fmts, {FmtTable::Align::RIGHT, FmtTable::Align::LEFT});
285+
FmtTable table3(titles, 5, fmts, 0, {FmtTable::Align::RIGHT, FmtTable::Align::LEFT});
264286
table3 << col1 << col2 << col3;
265287
result = table3.str();
266288
std::cout << result << std::endl;
@@ -277,7 +299,7 @@ TEST(FormatterTest, FmtTableCustomArgsAlign)
277299
EXPECT_EQ(result, ref);
278300

279301
// align: r and l
280-
FmtTable table4(titles, 5, fmts, {FmtTable::Align::LEFT, FmtTable::Align::RIGHT});
302+
FmtTable table4(titles, 5, fmts, 0, {FmtTable::Align::LEFT, FmtTable::Align::RIGHT});
281303
table4 << col1 << col2 << col3;
282304
result = table4.str();
283305
std::cout << result << std::endl;
@@ -303,7 +325,12 @@ TEST(FormatterTest, FmtTableCustomArgsAlignFrame)
303325
std::vector<int> col2 = {1, 2, 3, 4, 5};
304326
std::vector<float> col3 = {1.1, 2.2, 3.3, 4.4, 5.5};
305327

306-
FmtTable table1(titles, 5, fmts, {FmtTable::Align::LEFT, FmtTable::Align::LEFT}, {'+', '?', '*', '.', '^'});
328+
FmtTable table1(titles,
329+
5,
330+
fmts,
331+
0,
332+
{FmtTable::Align::LEFT, FmtTable::Align::LEFT},
333+
{'+', '?', '*', '.', '^'});
307334
table1 << col1 << col2 << col3;
308335
std::string result = table1.str();
309336
std::cout << result << std::endl;
@@ -328,7 +355,10 @@ TEST(FormatterTest, FmtTableCustomArgsAlignFrameDelim)
328355
std::vector<std::string> col1 = {"row1", "row2", "row3", "row4", "row5"};
329356
std::vector<int> col2 = {1, 2, 3, 4, 5};
330357
std::vector<float> col3 = {1.1, 2.2, 3.3, 4.4, 5.5};
331-
FmtTable table1(titles, 5, fmts,
358+
FmtTable table1(titles,
359+
5,
360+
fmts,
361+
0,
332362
{FmtTable::Align::LEFT, FmtTable::Align::LEFT},
333363
{'=', '/', '&', '#', '%'},
334364
{'"', ']'});
@@ -348,6 +378,30 @@ TEST(FormatterTest, FmtTableCustomArgsAlignFrameDelim)
348378
EXPECT_EQ(result, ref);
349379
}
350380

381+
TEST(FormatterTest, FmtTableCustomIndent)
382+
{
383+
const std::vector<std::string> titles = {"title1", "t i t l e 2", "t-i-t-l-e-3"};
384+
const std::vector<std::string> fmts = {"%s", "%d", "%f"};
385+
FmtTable table(titles, 5, fmts, 4);
386+
const std::vector<std::string> col1 = {"row1", "row2", "row3", "row4", "row5"};
387+
const std::vector<int> col2 = {1, 2, 3, 4, 5};
388+
const std::vector<float> col3 = {1.1, 2.2, 3.3, 4.4, 5.5};
389+
table << col1 << col2 << col3;
390+
const std::string result = table.str();
391+
std::cout << result << std::endl;
392+
std::string ref = "";
393+
ref += " --------------------------------\n";
394+
ref += " title1 t i t l e 2 t-i-t-l-e-3 \n";
395+
ref += " --------------------------------\n";
396+
ref += " row1 1 1.100000 \n";
397+
ref += " row2 2 2.200000 \n";
398+
ref += " row3 3 3.300000 \n";
399+
ref += " row4 4 4.400000 \n";
400+
ref += " row5 5 5.500000 \n";
401+
ref += " --------------------------------\n";
402+
EXPECT_EQ(result, ref);
403+
}
404+
351405
int main(int argc, char** argv) {
352406
::testing::InitGoogleTest(&argc, argv);
353407
return RUN_ALL_TESTS();

source/module_base/timer.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -300,7 +300,11 @@ void timer::print_all(std::ofstream &ofs)
300300

301301
std::vector<std::string> titles = {"CLASS_NAME", "NAME", "TIME/s", "CALLS", "AVG/s", "PER/%"};
302302
std::vector<std::string> formats = {"%-10s", "%-10s", "%6.2f", "%8d", "%6.2f", "%6.2f"};
303-
FmtTable time_statistics(titles, pers.size(), formats, {FmtTable::Align::LEFT, FmtTable::Align::CENTER});
303+
FmtTable time_statistics(/*titles=*/titles,
304+
/*nrows=*/pers.size(),
305+
/*formats=*/formats,
306+
/*indent=*/0,
307+
/*align=*/{/*value*/FmtTable::Align::LEFT, /*title*/FmtTable::Align::CENTER});
304308
time_statistics << class_names << names << times << calls << avgs << pers;
305309
const std::string table = "TIME STATISTICS\n" + time_statistics.str();
306310
std::cout<<table<<std::endl;

source/module_basis/module_pw/pw_gatherscatter.h

Lines changed: 24 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ namespace ModulePW
1414
template <typename T>
1515
void PW_Basis::gatherp_scatters(std::complex<T>* in, std::complex<T>* out) const
1616
{
17-
ModuleBase::timer::tick(this->classname, "gatherp_scatters");
17+
//ModuleBase::timer::tick(this->classname, "gatherp_scatters");
1818

1919
if(this->poolnproc == 1) //In this case nst=nstot, nz = nplane,
2020
{
@@ -32,7 +32,7 @@ void PW_Basis::gatherp_scatters(std::complex<T>* in, std::complex<T>* out) const
3232
outp[iz] = inp[iz];
3333
}
3434
}
35-
ModuleBase::timer::tick(this->classname, "gatherp_scatters");
35+
//ModuleBase::timer::tick(this->classname, "gatherp_scatters");
3636
return;
3737
}
3838
#ifdef __MPI
@@ -55,10 +55,15 @@ void PW_Basis::gatherp_scatters(std::complex<T>* in, std::complex<T>* out) const
5555

5656
//exchange data
5757
//(nplane,nstot) to (numz[ip],ns, poolnproc)
58-
if(typeid(T) == typeid(double))
59-
MPI_Alltoallv(out, numr, startr, MPI_DOUBLE_COMPLEX, in, numg, startg, MPI_DOUBLE_COMPLEX, this->pool_world);
60-
else if(typeid(T) == typeid(float))
61-
MPI_Alltoallv(out, numr, startr, MPI_COMPLEX, in, numg, startg, MPI_COMPLEX, this->pool_world);
58+
if(typeid(T) == typeid(double))
59+
{
60+
MPI_Alltoallv(out, numr, startr, MPI_DOUBLE_COMPLEX, in, numg, startg, MPI_DOUBLE_COMPLEX, this->pool_world);
61+
}
62+
else if(typeid(T) == typeid(float))
63+
{
64+
MPI_Alltoallv(out, numr, startr, MPI_COMPLEX, in, numg, startg, MPI_COMPLEX, this->pool_world);
65+
}
66+
6267
// change (nz,ns) to (numz[ip],ns, poolnproc)
6368
#ifdef _OPENMP
6469
#pragma omp parallel for collapse(2)
@@ -80,7 +85,7 @@ void PW_Basis::gatherp_scatters(std::complex<T>* in, std::complex<T>* out) const
8085
}
8186

8287
#endif
83-
ModuleBase::timer::tick(this->classname, "gatherp_scatters");
88+
//ModuleBase::timer::tick(this->classname, "gatherp_scatters");
8489
return;
8590
}
8691

@@ -94,7 +99,7 @@ void PW_Basis::gatherp_scatters(std::complex<T>* in, std::complex<T>* out) const
9499
template <typename T>
95100
void PW_Basis::gathers_scatterp(std::complex<T>* in, std::complex<T>* out) const
96101
{
97-
ModuleBase::timer::tick(this->classname, "gathers_scatterp");
102+
//ModuleBase::timer::tick(this->classname, "gathers_scatterp");
98103

99104
if(this->poolnproc == 1) //In this case nrxx=fftnx*fftny*nz, nst = nstot,
100105
{
@@ -147,10 +152,15 @@ void PW_Basis::gathers_scatterp(std::complex<T>* in, std::complex<T>* out) const
147152

148153
//exchange data
149154
//(numz[ip],ns, poolnproc) to (nplane,nstot)
150-
if(typeid(T) == typeid(double))
151-
MPI_Alltoallv(out, numg, startg, MPI_DOUBLE_COMPLEX, in, numr, startr, MPI_DOUBLE_COMPLEX, this->pool_world);
152-
else if(typeid(T) == typeid(float))
153-
MPI_Alltoallv(out, numg, startg, MPI_COMPLEX, in, numr, startr, MPI_COMPLEX, this->pool_world);
155+
if(typeid(T) == typeid(double))
156+
{
157+
MPI_Alltoallv(out, numg, startg, MPI_DOUBLE_COMPLEX, in, numr, startr, MPI_DOUBLE_COMPLEX, this->pool_world);
158+
}
159+
else if(typeid(T) == typeid(float))
160+
{
161+
MPI_Alltoallv(out, numg, startg, MPI_COMPLEX, in, numr, startr, MPI_COMPLEX, this->pool_world);
162+
}
163+
154164
#ifdef _OPENMP
155165
#pragma omp parallel for schedule(static, 4096/sizeof(T))
156166
#endif
@@ -175,10 +185,10 @@ void PW_Basis::gathers_scatterp(std::complex<T>* in, std::complex<T>* out) const
175185
}
176186

177187
#endif
178-
ModuleBase::timer::tick(this->classname, "gathers_scatterp");
188+
//ModuleBase::timer::tick(this->classname, "gathers_scatterp");
179189
return;
180190
}
181191

182192

183193

184-
}
194+
}

0 commit comments

Comments
 (0)