|
| 1 | +#include "driver.h" |
| 2 | +#include "src_pw/global.h" |
| 3 | +#include "input.h" |
| 4 | +#include "src_io/winput.h" |
| 5 | +#include "module_neighbor/sltk_atom_arrange.h" |
| 6 | +#include "src_io/print_info.h" |
| 7 | +#include "src_lcao/run_md_lcao.h" |
| 8 | +#include "src_pw/run_md_pw.h" |
| 9 | + |
| 10 | +// This is the driver function which defines the workflow of ABACUS calculations |
| 11 | +// It relies on the class Esolver, which is a class that organizes workflows of single point calculations. |
| 12 | +// For calculations involving change of configuration (lattice parameter & ionic motion), |
| 13 | +// this driver calls Esolver::Run and the configuration-changing subroutine |
| 14 | +// in a alternating manner. |
| 15 | +// Information is passed between the two subroutines by class UnitCell_Pseudo |
| 16 | +// Esolver::Run takes in a configuration and provides force and stress, |
| 17 | +// the configuration-changing subroutine takes force and stress and updates the configuration |
| 18 | +void Driver::driver_run() |
| 19 | +{ |
| 20 | + ModuleBase::TITLE("Driver", "driver_line"); |
| 21 | + ModuleBase::timer::tick("Driver", "driver_line"); |
| 22 | + |
| 23 | + // 1. Initialzie type of Esolver |
| 24 | + ModuleESolver::ESolver *p_esolver = nullptr; |
| 25 | + ModuleESolver::init_esolver(p_esolver); |
| 26 | + |
| 27 | + // 2. Setup cell and atom information |
| 28 | +#ifdef __LCAO |
| 29 | + GlobalC::ucell.setup_cell(GlobalC::ORB, GlobalV::global_pseudo_dir, GlobalV::stru_file, GlobalV::ofs_running); |
| 30 | +#else |
| 31 | + if(GlobalV::BASIS_TYPE == "lcao_in_pw" || GlobalV::BASIS_TYPE == "lcao") |
| 32 | + { |
| 33 | + ModuleBase::WARNING_QUIT("driver","to use LCAO basis, compile with __LCAO"); |
| 34 | + } |
| 35 | + GlobalC::ucell.setup_cell(GlobalV::global_pseudo_dir, GlobalV::stru_file, GlobalV::ofs_running); |
| 36 | +#endif |
| 37 | + |
| 38 | + // 3. For these two types of calculations |
| 39 | + // nothing else need to be initialized |
| 40 | + if(GlobalV::CALCULATION == "test_neighbour" || GlobalV::CALCULATION == "test_memory") |
| 41 | + { |
| 42 | + p_esolver->Run(0, GlobalC::ucell); |
| 43 | + ModuleBase::QUIT(); |
| 44 | + } |
| 45 | + |
| 46 | + // 4. Initialize Esolver |
| 47 | + p_esolver->Init(INPUT, GlobalC::ucell); |
| 48 | + |
| 49 | + //------------------------------------------------------------ |
| 50 | + // This part onward needs to be refactored. |
| 51 | + //---------------------------MD/Relax------------------ |
| 52 | + if(GlobalV::CALCULATION == "md" && GlobalV::BASIS_TYPE=="lcao") |
| 53 | + { |
| 54 | + Run_MD_LCAO run_md_lcao; |
| 55 | + run_md_lcao.opt_ions(p_esolver); |
| 56 | + } |
| 57 | + else if(GlobalV::CALCULATION == "md" || GlobalV::CALCULATION == "sto-md") |
| 58 | + { |
| 59 | + Run_MD_PW run_md_pw; |
| 60 | + run_md_pw.md_ions_pw(p_esolver); |
| 61 | + } |
| 62 | + else // scf; cell relaxation; nscf; etc |
| 63 | + { |
| 64 | + Ions ions; |
| 65 | + ions.opt_ions(p_esolver); |
| 66 | + } |
| 67 | + //---------------------------MD/Relax------------------ |
| 68 | + |
| 69 | + // 6. clean up esolver |
| 70 | + p_esolver->postprocess(); |
| 71 | + ModuleESolver::clean_esolver(p_esolver); |
| 72 | + |
| 73 | + ModuleBase::timer::tick("Driver", "driver_line"); |
| 74 | + return; |
| 75 | +} |
0 commit comments