Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions source/driver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ void Driver::init()
ModuleBase::timer::start();

// (1) read the input parameters.
// INPUT should be initalized here and then pass to atomic world, mohan 2024-05-12
// INPUT should not be GlobalC, mohan 2024-05-12
this->reading();

// (2) welcome to the atomic world!
Expand Down
15 changes: 12 additions & 3 deletions source/driver_run.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,18 +29,23 @@ void Driver::driver_run(void)
ModuleESolver::init_esolver(p_esolver);

//! 2: setup cell and atom information

// this warning should not be here, mohan 2024-05-22
#ifndef __LCAO
if(GlobalV::BASIS_TYPE == "lcao_in_pw" || GlobalV::BASIS_TYPE == "lcao")
{
ModuleBase::WARNING_QUIT("driver","to use LCAO basis, compile with __LCAO");
}
#endif

// the life of ucell should begin here, mohan 2024-05-12
// delete ucell as a GlobalC in near future
GlobalC::ucell.setup_cell(GlobalV::stru_file, GlobalV::ofs_running);

//! 3: initialize Esolver and fill json-structure
p_esolver->init(INPUT, GlobalC::ucell);

p_esolver->before_all_runners(INPUT, GlobalC::ucell);

// this Json part should be moved to before_all_runners, mohan 2024-05-12
Comment thread
mohanchen marked this conversation as resolved.
#ifdef __RAPIDJSON
Json::gen_stru_wrapper(&GlobalC::ucell);
#endif
Expand All @@ -52,6 +57,8 @@ void Driver::driver_run(void)
}
else //! scf; cell relaxation; nscf; etc
{
// mixed-precision should not be like this, mohan 2024-05-12,
// DEVICE should not depend on psi
if (GlobalV::precision_flag == "single")
{
Relax_Driver<float, psi::DEVICE_CPU> rl_driver;
Expand All @@ -63,9 +70,11 @@ void Driver::driver_run(void)
rl_driver.relax_driver(p_esolver);
}
}
// "others" in ESolver should be here.


//! 5: clean up esolver
p_esolver->post_process();
p_esolver->after_all_runners();
ModuleESolver::clean_esolver(p_esolver);

ModuleBase::timer::tick("Driver", "driver_line");
Expand Down
11 changes: 6 additions & 5 deletions source/module_esolver/esolver.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,15 @@ class ESolver
}

//! initialize the energy solver by using input parameters and cell modules
virtual void init(Input& inp, UnitCell& cell) = 0;
virtual void before_all_runners(Input& inp, UnitCell& cell) = 0;

//! run energy solver
virtual void run(int istep, UnitCell& cell) = 0;
virtual void runner(const int istep, UnitCell& cell) = 0;

//! deal with exx and other calculation than scf/md/relax:
//! perform post processing calculations
virtual void after_all_runners(){};

//! deal with exx and other calculation than scf/md/relax/cell-relax:
//! such as nscf, get_wf and get_pchg
virtual void others(const int istep){};

Expand All @@ -38,8 +41,6 @@ class ESolver
//! calcualte stress of given cell
virtual void cal_stress(ModuleBase::matrix& stress) = 0;

//! perform post processing calculations
virtual void post_process(){};

// Print current classname.
void printname();
Expand Down
12 changes: 6 additions & 6 deletions source/module_esolver/esolver_dp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
namespace ModuleESolver
{

void ESolver_DP::init(Input& inp, UnitCell& ucell)
void ESolver_DP::before_all_runners(Input& inp, UnitCell& ucell)
{
ucell_ = &ucell;
dp_potential = 0;
Expand Down Expand Up @@ -59,10 +59,10 @@ namespace ModuleESolver
assert(ucell.nat == iat);
}

void ESolver_DP::run(const int istep, UnitCell& ucell)
void ESolver_DP::runner(const int istep, UnitCell& ucell)
{
ModuleBase::TITLE("ESolver_DP", "Run");
ModuleBase::timer::tick("ESolver_DP", "Run");
ModuleBase::TITLE("ESolver_DP", "runner");
ModuleBase::timer::tick("ESolver_DP", "runner");

cell[0] = ucell.latvec.e11 * ucell.lat0_angstrom;
cell[1] = ucell.latvec.e12 * ucell.lat0_angstrom;
Expand Down Expand Up @@ -119,7 +119,7 @@ namespace ModuleESolver
#else
ModuleBase::WARNING_QUIT("ESolver_DP", "Please recompile with -D__DPMD");
#endif
ModuleBase::timer::tick("ESolver_DP", "Run");
ModuleBase::timer::tick("ESolver_DP", "runner");
}

double ESolver_DP::cal_energy()
Expand Down Expand Up @@ -148,7 +148,7 @@ namespace ModuleESolver
ModuleIO::print_stress("TOTAL-STRESS", stress, true, false);
}

void ESolver_DP::post_process(void)
void ESolver_DP::after_all_runners(void)
{
GlobalV::ofs_running << "\n\n --------------------------------------------" << std::endl;
GlobalV::ofs_running << std::setprecision(16);
Expand Down
6 changes: 3 additions & 3 deletions source/module_esolver/esolver_dp.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,15 +36,15 @@ class ESolver_DP : public ESolver
* @param inp input parameters
* @param cell unitcell information
*/
void init(Input& inp, UnitCell& cell) override;
void before_all_runners(Input& inp, UnitCell& cell) override;

/**
* @brief Run the DP solver for a given ion/md step and unit cell
*
* @param istep the current ion/md step
* @param cell unitcell information
*/
void run(const int istep, UnitCell& cell) override;
void runner(const int istep, UnitCell& cell) override;

/**
* @brief get the total energy without ion kinetic energy
Expand Down Expand Up @@ -73,7 +73,7 @@ class ESolver_DP : public ESolver
*
* This function prints the final total energy of the DP model in eV to the output file along with some formatting.
*/
void post_process() override;
void after_all_runners() override;

private:
/**
Expand Down
4 changes: 2 additions & 2 deletions source/module_esolver/esolver_fp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,9 @@ ESolver_FP::~ESolver_FP()
}


void ESolver_FP::init(Input& inp, UnitCell& cell)
void ESolver_FP::before_all_runners(Input& inp, UnitCell& cell)
{
ModuleBase::TITLE("ESolver_FP", "init");
ModuleBase::TITLE("ESolver_FP", "before_all_runners");

if(!GlobalV::use_paw)
{
Expand Down
2 changes: 1 addition & 1 deletion source/module_esolver/esolver_fp.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ namespace ModuleESolver
virtual ~ESolver_FP();

//! Initialize of the first-principels energy solver
virtual void init(Input& inp, UnitCell& cell) override;
virtual void before_all_runners(Input& inp, UnitCell& cell) override;

virtual void init_after_vc(Input& inp, UnitCell& cell); // liuyu add 2023-03-09

Expand Down
Loading