|
| 1 | +// ============================================================ |
| 2 | +// This code is added by Mohan Chen on 2026-05-18. |
| 3 | +// This code is currently in the design phase and has not been |
| 4 | +// put into production yet. It may change in the future. |
| 5 | +// Please use this code with caution. Only developers who know |
| 6 | +// what they are doing should use this code. |
| 7 | +// ============================================================ |
| 8 | + |
| 9 | +#include "esolver_dfpt_pw.h" |
| 10 | +#include "source_base/tool_quit.h" |
| 11 | + |
| 12 | +namespace ModuleESolver { |
| 13 | + |
| 14 | +ESolver_DFPT_PW::ESolver_DFPT_PW() { |
| 15 | + this->classname = "ESolver_DFPT_PW"; |
| 16 | + this->basisname = "PW"; |
| 17 | + gs_done_ = false; |
| 18 | + dfpt_ = nullptr; |
| 19 | +} |
| 20 | + |
| 21 | +ESolver_DFPT_PW::~ESolver_DFPT_PW() { |
| 22 | + if (dfpt_ != nullptr) { |
| 23 | + delete dfpt_; |
| 24 | + dfpt_ = nullptr; |
| 25 | + } |
| 26 | +} |
| 27 | + |
| 28 | +void ESolver_DFPT_PW::before_all_runners(UnitCell& ucell, const Input_para& inp) { |
| 29 | + ModuleBase::TITLE("ESolver_DFPT_PW", "before_all_runners"); |
| 30 | + |
| 31 | + ESolver_KS_PW<std::complex<double>, base_device::DEVICE_CPU>::before_all_runners(ucell, inp); |
| 32 | + |
| 33 | + init_dfpt(ucell); |
| 34 | +} |
| 35 | + |
| 36 | +void ESolver_DFPT_PW::runner(UnitCell& ucell, const int istep) { |
| 37 | + ModuleBase::TITLE("ESolver_DFPT_PW", "runner"); |
| 38 | + |
| 39 | + if (!gs_done_) { |
| 40 | + run_gs(ucell); |
| 41 | + gs_done_ = true; |
| 42 | + } |
| 43 | + |
| 44 | + if (dfpt_ != nullptr) { |
| 45 | + dfpt_->run(); |
| 46 | + } |
| 47 | + |
| 48 | + run_post_process(ucell); |
| 49 | +} |
| 50 | + |
| 51 | +void ESolver_DFPT_PW::after_all_runners(UnitCell& ucell) { |
| 52 | + ModuleBase::TITLE("ESolver_DFPT_PW", "after_all_runners"); |
| 53 | + |
| 54 | + ESolver_KS_PW<std::complex<double>, base_device::DEVICE_CPU>::after_all_runners(ucell); |
| 55 | +} |
| 56 | + |
| 57 | +void ESolver_DFPT_PW::run_gs(UnitCell& ucell) { |
| 58 | + ModuleBase::TITLE("ESolver_DFPT_PW", "run_gs"); |
| 59 | + |
| 60 | + ESolver_KS_PW<std::complex<double>, base_device::DEVICE_CPU>::runner(ucell, 0); |
| 61 | +} |
| 62 | + |
| 63 | +void ESolver_DFPT_PW::init_dfpt(UnitCell& ucell) { |
| 64 | + ModuleBase::TITLE("ESolver_DFPT_PW", "init_dfpt"); |
| 65 | + |
| 66 | + dfpt_ = new ModuleDFPT::DFPT_PW(); |
| 67 | + |
| 68 | +// dfpt_->init(ucell, *this->stp.psi, this->pelec->nelec, PARAM.inp.ecutwfc); |
| 69 | + |
| 70 | + dfpt_->set_parameters("dfpt.in"); |
| 71 | + |
| 72 | + dfpt_->set_qmesh(1, 1, 1); |
| 73 | + |
| 74 | + dfpt_->set_conv_thr(1e-8); |
| 75 | + dfpt_->set_max_iter(100); |
| 76 | +} |
| 77 | + |
| 78 | +void ESolver_DFPT_PW::run_post_process(UnitCell& ucell) { |
| 79 | + ModuleBase::TITLE("ESolver_DFPT_PW", "run_post_process"); |
| 80 | +} |
| 81 | + |
| 82 | +} // namespace ModuleESolver |
0 commit comments