Skip to content

Commit b2cc313

Browse files
committed
Merge branch 'develop' of https://github.com/deepmodeling/abacus-develop into refactor
2 parents b3340bb + 48788b8 commit b2cc313

Some content is hidden

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

57 files changed

+1401
-1576
lines changed

source/Makefile.Objects

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -581,7 +581,6 @@ OBJS_LCAO=evolve_elec.o\
581581
LCAO_set_fs.o\
582582
LCAO_set_st.o\
583583
LCAO_nl_mu.o\
584-
LCAO_nnr.o\
585584
LCAO_set_zero.o\
586585
LCAO_allocate.o\
587586
LCAO_set_mat2d.o\

source/module_base/formatter.h

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,20 @@ class FmtCore
145145
[&delim](const std::string& acc, const std::string& s) { return acc + delim + s; });
146146
}
147147

148+
static std::string upper(const std::string& in)
149+
{
150+
std::string dst = in;
151+
std::transform(dst.begin(), dst.end(), dst.begin(), ::toupper);
152+
return dst;
153+
}
154+
155+
static std::string lower(const std::string& in)
156+
{
157+
std::string dst = in;
158+
std::transform(dst.begin(), dst.end(), dst.begin(), ::tolower);
159+
return dst;
160+
}
161+
148162
private:
149163
std::string fmt_;
150164
template<typename T>

source/module_base/module_mixing/test/mixing_test.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1+
#ifdef _OPENMP
12
#include <omp.h>
3+
#endif
24

35
#include "../broyden_mixing.h"
46
#include "../plain_mixing.h"
@@ -151,7 +153,9 @@ class Mixing_Test : public testing::Test
151153

152154
TEST_F(Mixing_Test, BroydenSolveLinearEq)
153155
{
156+
#ifdef _OPENMP
154157
omp_set_num_threads(1);
158+
#endif
155159
init_method("broyden");
156160
std::vector<double> x_in = xd_ref;
157161
std::vector<double> x_out(3);
@@ -196,7 +200,9 @@ TEST_F(Mixing_Test, BroydenSolveLinearEq)
196200

197201
TEST_F(Mixing_Test, PulaySolveLinearEq)
198202
{
203+
#ifdef _OPENMP
199204
omp_set_num_threads(1);
205+
#endif
200206
init_method("pulay");
201207
std::vector<double> x_in = xd_ref;
202208
std::vector<double> x_out(3);
@@ -242,7 +248,9 @@ TEST_F(Mixing_Test, PulaySolveLinearEq)
242248

243249
TEST_F(Mixing_Test, PlainSolveLinearEq)
244250
{
251+
#ifdef _OPENMP
245252
omp_set_num_threads(1);
253+
#endif
246254
init_method("plain");
247255
std::vector<double> x_in = xd_ref;
248256
std::vector<double> x_out(3);

source/module_basis/module_ao/parallel_orbitals.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,10 @@ int Parallel_Orbitals::set_nloc_wfc_Eij(
247247
}
248248
else
249249
{
250-
ModuleBase::WARNING_QUIT("Parallel_Orbitals::set_nloc_wfc_Eij", "some processor has no bands-row-blocks.");
250+
ModuleBase::WARNING_QUIT("Parallel_Orbitals::set_nloc_wfc_Eij",
251+
"The number of columns of the 2D process grid exceeds the number of bands. "
252+
"Try launching the calculation with fewer MPI processes."
253+
);
251254
}
252255
}
253256
int col_b_bands = block / dim1;

source/module_elecstate/test/charge_mixing_test.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,10 @@
1010
#include "module_basis/module_pw/pw_basis.h"
1111
#include "module_hamilt_general/module_xc/xc_functional.h"
1212
#undef private
13+
14+
#ifdef _OPENMP
1315
#include <omp.h>
16+
#endif
1417

1518
int FUNC_TYPE = 1;
1619

@@ -116,7 +119,9 @@ class ChargeMixingTest : public ::testing::Test
116119

117120
TEST_F(ChargeMixingTest, SetMixingTest)
118121
{
122+
#ifdef _OPENMP
119123
omp_set_num_threads(1);
124+
#endif
120125
PARAM.input.nspin = 1;
121126
Charge_Mixing CMtest;
122127
CMtest.set_rhopw(&pw_basis, &pw_basis);
@@ -214,7 +219,9 @@ TEST_F(ChargeMixingTest, SetMixingTest)
214219

215220
TEST_F(ChargeMixingTest, InitMixingTest)
216221
{
222+
#ifdef _OPENMP
217223
omp_set_num_threads(1);
224+
#endif
218225
PARAM.input.nspin = 1;
219226
FUNC_TYPE = 1;
220227
Charge_Mixing CMtest;

source/module_esolver/esolver_ks_lcao.cpp

Lines changed: 58 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -635,19 +635,22 @@ void ESolver_KS_LCAO<TK, TR>::iter_init(const int istep, const int iter)
635635

636636
#ifdef __EXX
637637
// calculate exact-exchange
638-
if (GlobalC::exx_info.info_ri.real_number)
639-
{
640-
this->exd->exx_eachiterinit(istep,
641-
*dynamic_cast<const elecstate::ElecStateLCAO<TK>*>(this->pelec)->get_DM(),
642-
this->kv,
643-
iter);
644-
}
645-
else
638+
if (PARAM.inp.calculation != "nscf")
646639
{
647-
this->exc->exx_eachiterinit(istep,
648-
*dynamic_cast<const elecstate::ElecStateLCAO<TK>*>(this->pelec)->get_DM(),
649-
this->kv,
650-
iter);
640+
if (GlobalC::exx_info.info_ri.real_number)
641+
{
642+
this->exd->exx_eachiterinit(istep,
643+
*dynamic_cast<const elecstate::ElecStateLCAO<TK>*>(this->pelec)->get_DM(),
644+
this->kv,
645+
iter);
646+
}
647+
else
648+
{
649+
this->exc->exx_eachiterinit(istep,
650+
*dynamic_cast<const elecstate::ElecStateLCAO<TK>*>(this->pelec)->get_DM(),
651+
this->kv,
652+
iter);
653+
}
651654
}
652655
#endif
653656

@@ -729,13 +732,16 @@ void ESolver_KS_LCAO<TK, TR>::hamilt2density_single(int istep, int iter, double
729732

730733
// 5) what's the exd used for?
731734
#ifdef __EXX
732-
if (GlobalC::exx_info.info_ri.real_number)
735+
if (PARAM.inp.calculation != "nscf")
733736
{
734-
this->exd->exx_hamilt2density(*this->pelec, this->pv, iter);
735-
}
736-
else
737-
{
738-
this->exc->exx_hamilt2density(*this->pelec, this->pv, iter);
737+
if (GlobalC::exx_info.info_ri.real_number)
738+
{
739+
this->exd->exx_hamilt2density(*this->pelec, this->pv, iter);
740+
}
741+
else
742+
{
743+
this->exc->exx_hamilt2density(*this->pelec, this->pv, iter);
744+
}
739745
}
740746
#endif
741747

@@ -922,11 +928,29 @@ void ESolver_KS_LCAO<TK, TR>::iter_finish(const int istep, int& iter)
922928

923929
#ifdef __EXX
924930
// 3) save exx matrix
925-
if (GlobalC::exx_info.info_global.cal_exx)
931+
if (PARAM.inp.calculation != "nscf")
926932
{
927-
GlobalC::exx_info.info_ri.real_number ?
928-
this->exd->exx_iter_finish(this->kv, GlobalC::ucell, *this->p_hamilt, *this->pelec, *this->p_chgmix, this->scf_ene_thr, iter, istep, this->conv_esolver) :
929-
this->exc->exx_iter_finish(this->kv, GlobalC::ucell, *this->p_hamilt, *this->pelec, *this->p_chgmix, this->scf_ene_thr, iter, istep, this->conv_esolver);
933+
if (GlobalC::exx_info.info_global.cal_exx)
934+
{
935+
GlobalC::exx_info.info_ri.real_number ? this->exd->exx_iter_finish(this->kv,
936+
GlobalC::ucell,
937+
*this->p_hamilt,
938+
*this->pelec,
939+
*this->p_chgmix,
940+
this->scf_ene_thr,
941+
iter,
942+
istep,
943+
this->conv_esolver)
944+
: this->exc->exx_iter_finish(this->kv,
945+
GlobalC::ucell,
946+
*this->p_hamilt,
947+
*this->pelec,
948+
*this->p_chgmix,
949+
this->scf_ene_thr,
950+
iter,
951+
istep,
952+
this->conv_esolver);
953+
}
930954
}
931955
#endif
932956

@@ -1041,17 +1065,20 @@ void ESolver_KS_LCAO<TK, TR>::after_scf(const int istep)
10411065

10421066
#ifdef __EXX
10431067
// 5) write Hexx matrix for NSCF (see `out_chg` in docs/advanced/input_files/input-main.md)
1044-
if (GlobalC::exx_info.info_global.cal_exx && PARAM.inp.out_chg[0]
1045-
&& istep % PARAM.inp.out_interval == 0) // Peize Lin add if 2022.11.14
1068+
if (PARAM.inp.calculation != "nscf")
10461069
{
1047-
const std::string file_name_exx = PARAM.globalv.global_out_dir + "HexxR" + std::to_string(GlobalV::MY_RANK);
1048-
if (GlobalC::exx_info.info_ri.real_number)
1070+
if (GlobalC::exx_info.info_global.cal_exx && PARAM.inp.out_chg[0]
1071+
&& istep % PARAM.inp.out_interval == 0) // Peize Lin add if 2022.11.14
10491072
{
1050-
ModuleIO::write_Hexxs_csr(file_name_exx, GlobalC::ucell, this->exd->get_Hexxs());
1051-
}
1052-
else
1053-
{
1054-
ModuleIO::write_Hexxs_csr(file_name_exx, GlobalC::ucell, this->exc->get_Hexxs());
1073+
const std::string file_name_exx = PARAM.globalv.global_out_dir + "HexxR" + std::to_string(GlobalV::MY_RANK);
1074+
if (GlobalC::exx_info.info_ri.real_number)
1075+
{
1076+
ModuleIO::write_Hexxs_csr(file_name_exx, GlobalC::ucell, this->exd->get_Hexxs());
1077+
}
1078+
else
1079+
{
1080+
ModuleIO::write_Hexxs_csr(file_name_exx, GlobalC::ucell, this->exc->get_Hexxs());
1081+
}
10551082
}
10561083
}
10571084
#endif

source/module_esolver/lcao_before_scf.cpp

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -210,13 +210,16 @@ void ESolver_KS_LCAO<TK, TR>::before_scf(const int istep)
210210

211211
// Peize Lin add 2016-12-03
212212
#ifdef __EXX // set xc type before the first cal of xc in pelec->init_scf
213-
if (GlobalC::exx_info.info_ri.real_number)
213+
if (PARAM.inp.calculation != "nscf")
214214
{
215-
this->exd->exx_beforescf(istep, this->kv, *this->p_chgmix, GlobalC::ucell, orb_);
216-
}
217-
else
218-
{
219-
this->exc->exx_beforescf(istep, this->kv, *this->p_chgmix, GlobalC::ucell, orb_);
215+
if (GlobalC::exx_info.info_ri.real_number)
216+
{
217+
this->exd->exx_beforescf(istep, this->kv, *this->p_chgmix, GlobalC::ucell, orb_);
218+
}
219+
else
220+
{
221+
this->exc->exx_beforescf(istep, this->kv, *this->p_chgmix, GlobalC::ucell, orb_);
222+
}
220223
}
221224
#endif // __EXX
222225

source/module_esolver/set_matrix_grid.cpp

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ void ESolver_KS_LCAO<TK, TR>::set_matrix_grid(Record_adj& ra)
6868
this->pw_rho->nplane,
6969
this->pw_rho->startz_current,
7070
GlobalC::ucell,
71+
GlobalC::GridD,
7172
dr_uniform,
7273
rcuts,
7374
psi_u,
@@ -85,14 +86,7 @@ void ESolver_KS_LCAO<TK, TR>::set_matrix_grid(Record_adj& ra)
8586
// and allocate the space for H(R) and S(R).
8687
// If k point is used here, allocate HlocR after atom_arrange.
8788
ra.for_2d(this->pv, PARAM.globalv.gamma_only_local, orb_.cutoffs());
88-
89-
if (!PARAM.globalv.gamma_only_local)
90-
{
91-
// need to first calculae lgd.
92-
// using GridT.init.
93-
this->GridT.cal_nnrg(&this->pv, orb_.cutoffs());
94-
}
95-
89+
9690
ModuleBase::timer::tick("ESolver_KS_LCAO", "set_matrix_grid");
9791
return;
9892
}

source/module_hamilt_lcao/hamilt_lcaodft/CMakeLists.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ if(ENABLE_LCAO)
2727
spar_hsr.cpp
2828
spar_st.cpp
2929
spar_u.cpp
30-
LCAO_nnr.cpp
3130
LCAO_set_fs.cpp
3231
LCAO_set_st.cpp
3332
LCAO_nl_mu.cpp

0 commit comments

Comments
 (0)