Skip to content

Commit

Permalink
[pre-commit.ci lite] apply automatic fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
pre-commit-ci-lite[bot] authored Jun 22, 2024
1 parent 74cfeaa commit fa4dfaa
Show file tree
Hide file tree
Showing 72 changed files with 9,816 additions and 7,894 deletions.
54 changes: 29 additions & 25 deletions source/driver_run.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
#include "module_cell/module_neighbor/sltk_atom_arrange.h"
#include "module_hamilt_pw/hamilt_pwdft/global.h"
#include "module_io/input.h"
#include "module_io/para_json.h"
#include "module_io/print_info.h"
#include "module_io/winput.h"
#include "module_md/run_md.h"
#include "module_io/para_json.h"

#ifdef __LCAO
#include "module_beyonddft/esolver_lrtd_lcao.h"
Expand All @@ -17,39 +17,39 @@ extern "C"
/**
* @brief This is the driver function which defines the workflow of ABACUS calculations.
* It relies on the class Esolver, which is a class that organizes workflows of single point calculations.
*
*
* For calculations involving change of configuration (lattice parameter & ionic motion),
* this driver calls Esolver::Run and the configuration-changing subroutine in a alternating manner.
*
*
* Information is passed between the two subroutines by class UnitCell
*
* Esolver::Run takes in a configuration and provides force and stress,
*
* Esolver::Run takes in a configuration and provides force and stress,
* the configuration-changing subroutine takes force and stress and updates the configuration
*/
void Driver::driver_run(void)
{
ModuleBase::TITLE("Driver", "driver_line");
ModuleBase::timer::tick("Driver", "driver_line");

//! 1: initialize the ESolver
ModuleESolver::ESolver *p_esolver = nullptr;
//! 1: initialize the ESolver
ModuleESolver::ESolver* p_esolver = nullptr;
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")
if (GlobalV::BASIS_TYPE == "lcao_in_pw" || GlobalV::BASIS_TYPE == "lcao")
{
ModuleBase::WARNING_QUIT("driver","to use LCAO basis, compile with __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
//! 3: initialize Esolver and fill json-structure
#ifdef __LCAO
if (GlobalV::ESOLVER_TYPE == "lr")
// use constructor rather than Init function to initialize reference (instead of pointers) to ucell
Expand All @@ -61,41 +61,38 @@ void Driver::driver_run(void)
throw std::runtime_error("LR-TDDFT is not implemented for spin polarized case");
else
#endif
p_esolver->before_all_runners(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
// this Json part should be moved to before_all_runners, mohan 2024-05-12
#ifdef __RAPIDJSON
Json::gen_stru_wrapper(&GlobalC::ucell);
#endif

const std::string cal_type = GlobalV::CALCULATION;

//! 4: different types of calculations
if(cal_type == "md")
//! 4: different types of calculations
if (cal_type == "md")
{
Run_MD::md_line(GlobalC::ucell, p_esolver, INPUT.mdp);
}
else if(cal_type == "scf"
|| cal_type == "relax"
|| cal_type == "cell-relax")
else if (cal_type == "scf" || cal_type == "relax" || cal_type == "cell-relax")
{
Relax_Driver rl_driver;
rl_driver.relax_driver(p_esolver);
}
else
{
//! supported "other" functions:
//! nscf(PW,LCAO),
//! get_pchg(LCAO),
//! test_memory(PW,LCAO),
//! nscf(PW,LCAO),
//! get_pchg(LCAO),
//! test_memory(PW,LCAO),
//! test_neighbour(LCAO),
//! get_S(LCAO),
//! get_S(LCAO),
//! gen_bessel(PW), et al.
const int istep = 0;
p_esolver->others(istep);
}


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

Expand All @@ -104,12 +101,19 @@ void Driver::driver_run(void)
if (INPUT.esolver_type == "ks-lr")
{
std::cout << "setting up the esolver for excited state" << std::endl;
// ModuleESolver::ESolver_KS_LCAO* p_esolver_lcao_tmp = dynamic_cast<ModuleESolver::ESolver_KS_LCAO<double, double>*>(p_esolver);
// ModuleESolver::ESolver_KS_LCAO* p_esolver_lcao_tmp = dynamic_cast<ModuleESolver::ESolver_KS_LCAO<double,
// double>*>(p_esolver);
ModuleESolver::ESolver* p_esolver_lr = nullptr;
if (INPUT.gamma_only)
p_esolver_lr = new ModuleESolver::ESolver_LRTD<double, double>(std::move(*dynamic_cast<ModuleESolver::ESolver_KS_LCAO<double, double>*>(p_esolver)), INPUT, GlobalC::ucell);
p_esolver_lr = new ModuleESolver::ESolver_LRTD<double, double>(
std::move(*dynamic_cast<ModuleESolver::ESolver_KS_LCAO<double, double>*>(p_esolver)),
INPUT,
GlobalC::ucell);
else
p_esolver_lr = new ModuleESolver::ESolver_LRTD<std::complex<double>, double>(std::move(*dynamic_cast<ModuleESolver::ESolver_KS_LCAO<std::complex<double>, double>*>(p_esolver)), INPUT, GlobalC::ucell);
p_esolver_lr = new ModuleESolver::ESolver_LRTD<std::complex<double>, double>(
std::move(*dynamic_cast<ModuleESolver::ESolver_KS_LCAO<std::complex<double>, double>*>(p_esolver)),
INPUT,
GlobalC::ucell);
ModuleESolver::clean_esolver(p_esolver);
p_esolver_lr->runner(0, GlobalC::ucell);
p_esolver_lr->after_all_runners();
Expand Down
Loading

0 comments on commit fa4dfaa

Please sign in to comment.