Skip to content

Commit dd862ea

Browse files
authored
Refactor: remove useless functions in esolver (#5416)
* Refactor: remove useless functions in esolver * add head files * test rapidjson * test
1 parent 27075c1 commit dd862ea

File tree

6 files changed

+21
-95
lines changed

6 files changed

+21
-95
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
{
@@ -626,7 +625,7 @@ void ESolver_KS<T, Device>::runner(const int istep, UnitCell& ucell)
626625
{
627626
dkin = p_chgmix->get_dkin(pelec->charge, PARAM.inp.nelec);
628627
}
629-
this->print_iter(iter, drho, dkin, duration, diag_ethr);
628+
this->pelec->print_etot(this->conv_esolver, iter, drho, dkin, duration, PARAM.inp.printe, diag_ethr);
630629

631630
// 12) Json, need to be moved to somewhere else
632631
#ifdef __RAPIDJSON
@@ -653,23 +652,12 @@ void ESolver_KS<T, Device>::runner(const int istep, UnitCell& ucell)
653652
}
654653
} // end scf iterations
655654
std::cout << " >> Leave SCF iteration.\n * * * * * *" << std::endl;
656-
#ifdef __RAPIDJSON
657-
// 14) add Json of efermi energy converge
658-
Json::add_output_efermi_converge(this->pelec->eferm.ef * ModuleBase::Ry_to_eV, this->conv_esolver);
659-
#endif //__RAPIDJSON
660655

661656
// 15) after scf
662657
ModuleBase::timer::tick(this->classname, "after_scf");
663658
this->after_scf(istep);
664659
ModuleBase::timer::tick(this->classname, "after_scf");
665660

666-
// 16) Json again
667-
#ifdef __RAPIDJSON
668-
// add nkstot,nkstot_ibz to output json
669-
int Jnkstot = this->pelec->klist->get_nkstot();
670-
Json::add_nkstot(Jnkstot);
671-
#endif //__RAPIDJSON
672-
673661
ModuleBase::timer::tick(this->classname, "runner");
674662
return;
675663
};
@@ -701,40 +689,13 @@ void ESolver_KS<T, Device>::after_scf(const int istep)
701689
{
702690
this->pelec->print_eigenvalue(GlobalV::ofs_running);
703691
}
704-
}
705-
706-
//------------------------------------------------------------------------------
707-
//! the 8th function of ESolver_KS: print_iter
708-
//! mohan add 2024-05-12
709-
//------------------------------------------------------------------------------
710-
template <typename T, typename Device>
711-
void ESolver_KS<T, Device>::print_iter(const int iter,
712-
const double drho,
713-
const double dkin,
714-
const double duration,
715-
const double ethr)
716-
{
717-
this->pelec->print_etot(this->conv_esolver, iter, drho, dkin, duration, PARAM.inp.printe, ethr);
718-
}
719-
720-
//------------------------------------------------------------------------------
721-
//! the 10th function of ESolver_KS: getnieter
722-
//! mohan add 2024-05-12
723-
//------------------------------------------------------------------------------
724-
template <typename T, typename Device>
725-
int ESolver_KS<T, Device>::get_niter()
726-
{
727-
return this->niter;
728-
}
729-
730-
//------------------------------------------------------------------------------
731-
//! the 11th function of ESolver_KS: get_maxniter
732-
//! tqzhao add 2024-05-15
733-
//------------------------------------------------------------------------------
734-
template <typename T, typename Device>
735-
int ESolver_KS<T, Device>::get_maxniter()
736-
{
737-
return this->maxniter;
692+
// #ifdef __RAPIDJSON
693+
// // add Json of efermi energy converge
694+
// Json::add_output_efermi_converge(this->pelec->eferm.ef * ModuleBase::Ry_to_eV, this->conv_esolver);
695+
// // add nkstot,nkstot_ibz to output json
696+
// int Jnkstot = this->pelec->klist->get_nkstot();
697+
// Json::add_nkstot(Jnkstot);
698+
// #endif //__RAPIDJSON
738699
}
739700

740701
//------------------------------------------------------------------------------

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_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 ----------

0 commit comments

Comments
 (0)