|
1 | 1 | #include "esolver_ks_pw.h" |
2 | 2 |
|
3 | | -#include "module_base/global_variable.h" |
4 | | -#include "module_hamilt_pw/hamilt_pwdft/elecond.h" |
5 | | -#include "module_io/input_conv.h" |
6 | | -#include "module_io/nscf_band.h" |
7 | | -#include "module_io/output_log.h" |
8 | | -#include "module_io/write_dos_pw.h" |
9 | | -#include "module_io/write_istate_info.h" |
10 | | -#include "module_io/write_wfc_pw.h" |
11 | | - |
12 | 3 | #include <iostream> |
13 | 4 |
|
14 | 5 | //--------------temporary---------------------------- |
|
22 | 13 | //-----stress------------------ |
23 | 14 | #include "module_hamilt_pw/hamilt_pwdft/stress_pw.h" |
24 | 15 | //--------------------------------------------------- |
| 16 | +#include "module_base/formatter.h" |
| 17 | +#include "module_base/global_variable.h" |
25 | 18 | #include "module_base/memory.h" |
26 | 19 | #include "module_base/module_device/device.h" |
27 | 20 | #include "module_elecstate/elecstate_pw.h" |
28 | 21 | #include "module_hamilt_general/module_vdw/vdw.h" |
| 22 | +#include "module_hamilt_pw/hamilt_pwdft/elecond.h" |
29 | 23 | #include "module_hamilt_pw/hamilt_pwdft/hamilt_pw.h" |
30 | 24 | #include "module_hsolver/diago_iter_assist.h" |
31 | 25 | #include "module_hsolver/hsolver_pw.h" |
|
34 | 28 | #include "module_io/berryphase.h" |
35 | 29 | #include "module_io/cube_io.h" |
36 | 30 | #include "module_io/get_pchg_pw.h" |
| 31 | +#include "module_io/input_conv.h" |
| 32 | +#include "module_io/nscf_band.h" |
37 | 33 | #include "module_io/numerical_basis.h" |
38 | 34 | #include "module_io/numerical_descriptor.h" |
| 35 | +#include "module_io/output_log.h" |
39 | 36 | #include "module_io/to_wannier90_pw.h" |
40 | 37 | #include "module_io/winput.h" |
| 38 | +#include "module_io/write_dos_pw.h" |
41 | 39 | #include "module_io/write_elecstat_pot.h" |
| 40 | +#include "module_io/write_istate_info.h" |
| 41 | +#include "module_io/write_wfc_pw.h" |
42 | 42 | #include "module_io/write_wfc_r.h" |
43 | 43 | #include "module_parameter/parameter.h" |
44 | 44 | #ifdef USE_PAW |
45 | 45 | #include "module_cell/module_paw/paw_cell.h" |
46 | 46 | #endif |
47 | | -#include "module_base/formatter.h" |
48 | 47 |
|
49 | 48 | #include <ATen/kernels/blas.h> |
50 | 49 | #include <ATen/kernels/lapack.h> |
@@ -113,6 +112,21 @@ ESolver_KS_PW<T, Device>::~ESolver_KS_PW() |
113 | 112 | delete this->p_wf_init; |
114 | 113 | } |
115 | 114 |
|
| 115 | +template <typename T, typename Device> |
| 116 | +void ESolver_KS_PW<T, Device>::allocate_hamilt() |
| 117 | +{ |
| 118 | + this->p_hamilt = new hamilt::HamiltPW<T, Device>(this->pelec->pot, this->pw_wfc, &this->kv); |
| 119 | +} |
| 120 | +template <typename T, typename Device> |
| 121 | +void ESolver_KS_PW<T, Device>::deallocate_hamilt() |
| 122 | +{ |
| 123 | + if (this->p_hamilt != nullptr) |
| 124 | + { |
| 125 | + delete reinterpret_cast<hamilt::HamiltPW<T, Device>*>(this->p_hamilt); |
| 126 | + this->p_hamilt = nullptr; |
| 127 | + } |
| 128 | +} |
| 129 | + |
116 | 130 | template <typename T, typename Device> |
117 | 131 | void ESolver_KS_PW<T, Device>::before_all_runners(const Input_para& inp, UnitCell& ucell) |
118 | 132 | { |
@@ -526,6 +540,31 @@ void ESolver_KS_PW<T, Device>::after_scf(const int istep) |
526 | 540 | PARAM.globalv.global_out_dir, |
527 | 541 | PARAM.inp.if_separate_k); |
528 | 542 | } |
| 543 | + |
| 544 | + //! 6) calculate Wannier functions |
| 545 | + if (PARAM.inp.calculation == "nscf" && PARAM.inp.towannier90) |
| 546 | + { |
| 547 | + std::cout << FmtCore::format("\n * * * * * *\n << Start %s.\n", "Wannier functions calculation"); |
| 548 | + toWannier90_PW wan(PARAM.inp.out_wannier_mmn, |
| 549 | + PARAM.inp.out_wannier_amn, |
| 550 | + PARAM.inp.out_wannier_unk, |
| 551 | + PARAM.inp.out_wannier_eig, |
| 552 | + PARAM.inp.out_wannier_wvfn_formatted, |
| 553 | + PARAM.inp.nnkpfile, |
| 554 | + PARAM.inp.wannier_spin); |
| 555 | + |
| 556 | + wan.calculate(this->pelec->ekb, this->pw_wfc, this->pw_big, this->kv, this->psi); |
| 557 | + std::cout << FmtCore::format(" >> Finish %s.\n * * * * * *\n", "Wannier functions calculation"); |
| 558 | + } |
| 559 | + |
| 560 | + //! 7) calculate Berry phase polarization |
| 561 | + if (PARAM.inp.calculation == "nscf" && berryphase::berry_phase_flag && ModuleSymmetry::Symmetry::symm_flag != 1) |
| 562 | + { |
| 563 | + std::cout << FmtCore::format("\n * * * * * *\n << Start %s.\n", "Berry phase polarization"); |
| 564 | + berryphase bp; |
| 565 | + bp.Macroscopic_polarization(this->pw_wfc->npwk_max, this->psi, this->pw_rho, this->pw_wfc, this->kv); |
| 566 | + std::cout << FmtCore::format(" >> Finish %s.\n * * * * * *\n", "Berry phase polarization"); |
| 567 | + } |
529 | 568 | } |
530 | 569 |
|
531 | 570 | template <typename T, typename Device> |
|
0 commit comments