Skip to content

Commit e1197b3

Browse files
Merge branch 'develop' into drho
2 parents 4ec6f2a + dd862ea commit e1197b3

File tree

12 files changed

+103
-172
lines changed

12 files changed

+103
-172
lines changed

source/module_esolver/esolver.cpp

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,6 @@ extern "C"
2323
namespace ModuleESolver
2424
{
2525

26-
void ESolver::printname()
27-
{
28-
std::cout << classname << std::endl;
29-
}
30-
3126
std::string determine_type()
3227
{
3328
std::string esolver_type = "none";

source/module_esolver/esolver.h

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -41,23 +41,6 @@ class ESolver
4141
//! calcualte stress of given cell
4242
virtual void cal_stress(ModuleBase::matrix& stress) = 0;
4343

44-
45-
// Print current classname.
46-
void printname();
47-
48-
// temporarily
49-
// get iterstep used in current scf
50-
virtual int get_niter()
51-
{
52-
return 0;
53-
}
54-
55-
// get maxniter used in current scf
56-
virtual int get_maxniter()
57-
{
58-
return 0;
59-
}
60-
6144
bool conv_esolver = true; // whether esolver is converged
6245

6346
std::string classname;

source/module_esolver/esolver_fp.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
#include "module_hamilt_pw/hamilt_pwdft/global.h"
66
#include "module_io/cif_io.h"
77
#include "module_io/cube_io.h"
8+
#include "module_io/json_output/init_info.h"
9+
#include "module_io/json_output/output_info.h"
810
#include "module_io/output_log.h"
911
#include "module_io/print_info.h"
1012
#include "module_io/rhog_io.h"
@@ -260,6 +262,14 @@ void ESolver_FP::after_scf(const int istep)
260262
PARAM.inp.out_elf[1]);
261263
}
262264
}
265+
266+
// #ifdef __RAPIDJSON
267+
// // add Json of efermi energy converge
268+
// Json::add_output_efermi_converge(this->pelec->eferm.ef * ModuleBase::Ry_to_eV, this->conv_esolver);
269+
// // add nkstot,nkstot_ibz to output json
270+
// int Jnkstot = this->pelec->klist->get_nkstot();
271+
// Json::add_nkstot(Jnkstot);
272+
// #endif //__RAPIDJSON
263273
}
264274

265275
void ESolver_FP::init_after_vc(const Input_para& inp, UnitCell& cell)

source/module_esolver/esolver_ks.cpp

Lines changed: 10 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#include "esolver_ks.h"
22

33
#include <ctime>
4+
#include <iostream>
45
#ifdef __MPI
56
#include <mpi.h>
67
#else
@@ -9,12 +10,11 @@
910
#include "module_base/timer.h"
1011
#include "module_cell/cal_atoms_info.h"
1112
#include "module_io/json_output/init_info.h"
13+
#include "module_io/json_output/output_info.h"
1214
#include "module_io/output_log.h"
1315
#include "module_io/print_info.h"
1416
#include "module_io/write_istate_info.h"
1517
#include "module_parameter/parameter.h"
16-
17-
#include <iostream>
1818
//--------------Temporary----------------
1919
#include "module_base/global_variable.h"
2020
#include "module_hamilt_lcao/module_dftu/dftu.h"
@@ -24,7 +24,6 @@
2424
#include "module_base/parallel_common.h"
2525
#include "module_cell/module_paw/paw_cell.h"
2626
#endif
27-
#include "module_io/json_output/output_info.h"
2827

2928
namespace ModuleESolver
3029
{
@@ -628,7 +627,7 @@ void ESolver_KS<T, Device>::runner(const int istep, UnitCell& ucell)
628627
{
629628
dkin = p_chgmix->get_dkin(pelec->charge, PARAM.inp.nelec);
630629
}
631-
this->print_iter(iter, drho, dkin, duration, diag_ethr);
630+
this->pelec->print_etot(this->conv_esolver, iter, drho, dkin, duration, PARAM.inp.printe, diag_ethr);
632631

633632
// 12) Json, need to be moved to somewhere else
634633
#ifdef __RAPIDJSON
@@ -659,23 +658,12 @@ void ESolver_KS<T, Device>::runner(const int istep, UnitCell& ucell)
659658
}
660659
} // end scf iterations
661660
std::cout << " >> Leave SCF iteration.\n * * * * * *" << std::endl;
662-
#ifdef __RAPIDJSON
663-
// 14) add Json of efermi energy converge
664-
Json::add_output_efermi_converge(this->pelec->eferm.ef * ModuleBase::Ry_to_eV, this->conv_esolver);
665-
#endif //__RAPIDJSON
666661

667662
// 15) after scf
668663
ModuleBase::timer::tick(this->classname, "after_scf");
669664
this->after_scf(istep);
670665
ModuleBase::timer::tick(this->classname, "after_scf");
671666

672-
// 16) Json again
673-
#ifdef __RAPIDJSON
674-
// add nkstot,nkstot_ibz to output json
675-
int Jnkstot = this->pelec->klist->get_nkstot();
676-
Json::add_nkstot(Jnkstot);
677-
#endif //__RAPIDJSON
678-
679667
ModuleBase::timer::tick(this->classname, "runner");
680668
return;
681669
};
@@ -707,40 +695,13 @@ void ESolver_KS<T, Device>::after_scf(const int istep)
707695
{
708696
this->pelec->print_eigenvalue(GlobalV::ofs_running);
709697
}
710-
}
711-
712-
//------------------------------------------------------------------------------
713-
//! the 8th function of ESolver_KS: print_iter
714-
//! mohan add 2024-05-12
715-
//------------------------------------------------------------------------------
716-
template <typename T, typename Device>
717-
void ESolver_KS<T, Device>::print_iter(const int iter,
718-
const double drho,
719-
const double dkin,
720-
const double duration,
721-
const double ethr)
722-
{
723-
this->pelec->print_etot(this->conv_esolver, iter, drho, dkin, duration, PARAM.inp.printe, ethr);
724-
}
725-
726-
//------------------------------------------------------------------------------
727-
//! the 10th function of ESolver_KS: getnieter
728-
//! mohan add 2024-05-12
729-
//------------------------------------------------------------------------------
730-
template <typename T, typename Device>
731-
int ESolver_KS<T, Device>::get_niter()
732-
{
733-
return this->niter;
734-
}
735-
736-
//------------------------------------------------------------------------------
737-
//! the 11th function of ESolver_KS: get_maxniter
738-
//! tqzhao add 2024-05-15
739-
//------------------------------------------------------------------------------
740-
template <typename T, typename Device>
741-
int ESolver_KS<T, Device>::get_maxniter()
742-
{
743-
return this->maxniter;
698+
// #ifdef __RAPIDJSON
699+
// // add Json of efermi energy converge
700+
// Json::add_output_efermi_converge(this->pelec->eferm.ef * ModuleBase::Ry_to_eV, this->conv_esolver);
701+
// // add nkstot,nkstot_ibz to output json
702+
// int Jnkstot = this->pelec->klist->get_nkstot();
703+
// Json::add_nkstot(Jnkstot);
704+
// #endif //__RAPIDJSON
744705
}
745706

746707
//------------------------------------------------------------------------------

source/module_esolver/esolver_ks.h

Lines changed: 1 addition & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -50,12 +50,6 @@ class ESolver_KS : public ESolver_FP
5050
// calculate electron states from a specific Hamiltonian
5151
virtual void hamilt2estates(const double ethr){};
5252

53-
// get current step of Ionic simulation
54-
virtual int get_niter() override;
55-
56-
// get maxniter used in current scf
57-
virtual int get_maxniter() override;
58-
5953
protected:
6054
//! Something to do before SCF iterations.
6155
virtual void before_scf(const int istep) {};
@@ -72,19 +66,7 @@ class ESolver_KS : public ESolver_FP
7266
//! <Temporary> It should be replaced by a function in Hamilt Class
7367
virtual void update_pot(const int istep, const int iter) {};
7468

75-
protected:
76-
// Print inforamtion in each iter
77-
// G1 -3.435545e+03 0.000000e+00 3.607e-01 2.862e-01
78-
// for metaGGA
79-
// ITER ETOT(eV) EDIFF(eV) DRHO DKIN TIME(s)
80-
// G1 -3.435545e+03 0.000000e+00 3.607e-01 3.522e-01 2.862e-01
81-
void print_iter(
82-
const int iter,
83-
const double drho,
84-
const double dkin,
85-
const double duration,
86-
const double ethr);
87-
69+
protected:
8870
//! Hamiltonian
8971
hamilt::Hamilt<T, Device>* p_hamilt = nullptr;
9072

source/module_esolver/esolver_ks_lcao.cpp

Lines changed: 4 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -941,76 +941,11 @@ void ESolver_KS_LCAO<TK, TR>::iter_finish(int& iter)
941941

942942
#ifdef __EXX
943943
// 3) save exx matrix
944-
int two_level_step = GlobalC::exx_info.info_ri.real_number ? this->exd->two_level_step : this->exc->two_level_step;
945-
946-
if (GlobalC::restart.info_save.save_H && two_level_step > 0
947-
&& (!GlobalC::exx_info.info_global.separate_loop || iter == 1)) // to avoid saving the same value repeatedly
948-
{
949-
////////// for Add_Hexx_Type::k
950-
/*
951-
hamilt::HS_Matrix_K<TK> Hexxk_save(&this->pv, 1);
952-
for (int ik = 0; ik < this->kv.get_nks(); ++ik) {
953-
Hexxk_save.set_zero_hk();
954-
955-
hamilt::OperatorEXX<hamilt::OperatorLCAO<TK, TR>> opexx_save(&Hexxk_save,
956-
nullptr,
957-
this->kv);
958-
959-
opexx_save.contributeHk(ik);
960-
961-
GlobalC::restart.save_disk("Hexx",
962-
ik,
963-
this->pv.get_local_size(),
964-
Hexxk_save.get_hk());
965-
}*/
966-
////////// for Add_Hexx_Type:R
967-
const std::string& restart_HR_path = GlobalC::restart.folder + "HexxR" + std::to_string(GlobalV::MY_RANK);
968-
if (GlobalC::exx_info.info_ri.real_number)
969-
{
970-
ModuleIO::write_Hexxs_csr(restart_HR_path, GlobalC::ucell, this->exd->get_Hexxs());
971-
}
972-
else
973-
{
974-
ModuleIO::write_Hexxs_csr(restart_HR_path, GlobalC::ucell, this->exc->get_Hexxs());
975-
}
976-
if (GlobalV::MY_RANK == 0)
977-
{
978-
GlobalC::restart.save_disk("Eexx", 0, 1, &this->pelec->f_en.exx);
979-
}
980-
}
981-
982-
if (GlobalC::exx_info.info_global.cal_exx && this->conv_esolver)
944+
if (GlobalC::exx_info.info_global.cal_exx)
983945
{
984-
// Kerker mixing does not work for the density matrix.
985-
// In the separate loop case, it can still work in the subsequent inner loops where Hexx(DM) is fixed.
986-
// In the non-separate loop case where Hexx(DM) is updated in every iteration of the 2nd loop, it should be
987-
// closed.
988-
if (!GlobalC::exx_info.info_global.separate_loop)
989-
{
990-
this->p_chgmix->close_kerker_gg0();
991-
}
992-
if (GlobalC::exx_info.info_ri.real_number)
993-
{
994-
this->conv_esolver = this->exd->exx_after_converge(
995-
*this->p_hamilt,
996-
*dynamic_cast<const elecstate::ElecStateLCAO<TK>*>(this->pelec)->get_DM(),
997-
this->kv,
998-
PARAM.inp.nspin,
999-
iter,
1000-
this->pelec->f_en.etot,
1001-
this->scf_ene_thr);
1002-
}
1003-
else
1004-
{
1005-
this->conv_esolver = this->exc->exx_after_converge(
1006-
*this->p_hamilt,
1007-
*dynamic_cast<const elecstate::ElecStateLCAO<TK>*>(this->pelec)->get_DM(),
1008-
this->kv,
1009-
PARAM.inp.nspin,
1010-
iter,
1011-
this->pelec->f_en.etot,
1012-
this->scf_ene_thr);
1013-
}
946+
GlobalC::exx_info.info_ri.real_number ?
947+
this->exd->exx_iter_finish(this->kv, GlobalC::ucell, *this->p_hamilt, *this->pelec, *this->p_chgmix, this->scf_ene_thr, iter, this->conv_esolver) :
948+
this->exc->exx_iter_finish(this->kv, GlobalC::ucell, *this->p_hamilt, *this->pelec, *this->p_chgmix, this->scf_ene_thr, iter, this->conv_esolver);
1014949
}
1015950
#endif
1016951

source/module_esolver/esolver_of.h

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,6 @@ class ESolver_OF : public ESolver_FP
3333

3434
virtual void cal_stress(ModuleBase::matrix& stress) override;
3535

36-
virtual int get_niter() override
37-
{
38-
return this->iter_;
39-
}
40-
4136
private:
4237
// ======================= variables ==========================
4338
// ---------- the kinetic energy density functionals ----------

source/module_hamilt_lcao/module_gint/CMakeLists.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#add_subdirectory(kernels/cuda)
2+
if(ENABLE_LCAO)
23

34
list(APPEND objects
45
gint.cpp
@@ -69,4 +70,6 @@ IF (BUILD_TESTING)
6970
if(ENABLE_MPI)
7071
add_subdirectory(test)
7172
endif()
73+
endif()
74+
7275
endif()

source/module_hamilt_lcao/module_hcontainer/CMakeLists.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
if(ENABLE_LCAO)
2+
13
list(APPEND objects
24
base_matrix.cpp
35
atom_pair.cpp
@@ -22,4 +24,6 @@ IF (BUILD_TESTING)
2224
if(ENABLE_MPI)
2325
add_subdirectory(test)
2426
endif()
27+
endif()
28+
2529
endif()

source/module_hamilt_pw/hamilt_pwdft/operator_pw/CMakeLists.txt

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,13 @@ list(APPEND operator_ks_pw_srcs
77
velocity_pw.cpp
88
)
99

10-
add_library(
11-
operator_ks_pw
12-
OBJECT
13-
${operator_ks_pw_srcs}
14-
)
10+
# this library is included in hamilt_pwdft now
11+
#add_library(
12+
# operator_ks_pw
13+
# OBJECT
14+
# ${operator_ks_pw_srcs}
15+
#)
1516

16-
if(ENABLE_COVERAGE)
17-
add_coverage(operator_ks_pw)
18-
endif()
17+
#if(ENABLE_COVERAGE)
18+
# add_coverage(operator_ks_pw)
19+
#endif()

0 commit comments

Comments
 (0)