|
5 | 5 | #include "module_lr/potentials/pot_hxc_lrtd.h" |
6 | 6 | #include "module_lr/operator_casida/operator_lr_hxc.h" |
7 | 7 | #include "module_basis/module_ao/parallel_orbitals.h" |
| 8 | +#ifdef __EXX |
| 9 | +#include "module_lr/operator_casida/operator_lr_exx.h" |
| 10 | +#endif |
8 | 11 | namespace LR |
9 | 12 | { |
10 | 13 | template<typename T> |
11 | 14 | class Z_vector_R : public HamiltLR<T> |
12 | 15 | { |
13 | 16 | using ATYPE = typename OperatorLRHxc<T>::MO_TO_AO_TYPE; |
| 17 | +#ifdef __EXX |
| 18 | + using ATYPE_EXX = typename OperatorLREXX<T>::MO_TO_AO_TYPE; |
| 19 | +#endif |
14 | 20 | public: |
15 | 21 | template<typename TGint> |
16 | 22 | Z_vector_R(const std::string& xc_kernel, |
@@ -42,36 +48,60 @@ namespace LR |
42 | 48 | gint, pot, kv, pX, pc, pmat, spin_type) |
43 | 49 | { |
44 | 50 | ModuleBase::TITLE("Z_vector_R", "Z_vector_R"); |
| 51 | + |
45 | 52 | this->DM_trans = LR_Util::make_unique<elecstate::DensityMatrix<T, T>>(&pmat, 1, kv.kvec_d, this->nk); |
46 | 53 | LR_Util::initialize_DMR(*this->DM_trans, pmat, ucell, gd, orb_cutoff); |
47 | 54 | this->DM_diff = LR_Util::make_unique<elecstate::DensityMatrix<T, T>>(&pmat, 1, kv.kvec_d, this->nk); |
48 | 55 | LR_Util::initialize_DMR(*this->DM_diff, pmat, ucell, gd, orb_cutoff); |
| 56 | + |
| 57 | + // note: calculation_type cannot repeated, or it will be ignored in ops->add() |
49 | 58 | // 1. $2\sum_bX_{ib}K_{ab}[D^X]-2\sum_jX_{ja}K_{ij}[D^X]$ |
50 | 59 | this->ops = new OperatorLRHxc<T>(nspin, naos, nocc, nvirt, psi_ks, |
51 | 60 | *this->DM_trans, gint, pot, ucell, orb_cutoff, gd, kv, pX, pc, pmat, |
52 | 61 | { 0 }, -2.0, ATYPE::CXC); |
| 62 | +#ifdef __EXX |
| 63 | + if (exx_kernel_list().count(xc_kernel)) |
| 64 | + { |
| 65 | + hamilt::Operator<T>* op_hz_exx = new OperatorLREXX<T>(nspin, naos, nocc[0], nvirt[0], ucell, psi_ks, |
| 66 | + *this->DM_trans, exx_lri, kv, pX[0], pc, pmat, |
| 67 | + -2.0 * exx_alpha, //alpha; H=2K when D is symmetrized |
| 68 | + ATYPE_EXX::CXC, {}, hamilt::calculation_type::lr_dmtrans_exx); |
| 69 | + this->ops->add(op_hz_exx); |
| 70 | + } |
| 71 | +#endif |
53 | 72 | // 2. $H_{ia}[T]$, equals to $2K_{ab}[T]$ when $T$ is symmetrized |
54 | 73 | hamilt::Operator<T>* op_ht = new OperatorLRHxc<T>(nspin, naos, nocc, nvirt, psi_ks, |
55 | 74 | *this->DM_diff, gint, pot_hxc_gs, ucell, orb_cutoff, gd, kv, pX, pc, pmat, |
56 | | - { 0 }, T(-2.0), ATYPE::CC_vo, hamilt::calculation_type::lr_dmdiff_vo); |
| 75 | + { 0 }, T(-2.0), ATYPE::CC_vo, hamilt::calculation_type::lr_dmdiff_hxc); |
57 | 76 | this->ops->add(op_ht); |
| 77 | +#ifdef __EXX |
| 78 | + if (exx_kernel_list().count(xc_kernel)) |
| 79 | + { |
| 80 | + hamilt::Operator<T>* op_ht_exx = new OperatorLREXX<T>(nspin, naos, nocc[0], nvirt[0], ucell, psi_ks, |
| 81 | + *this->DM_diff, exx_lri, kv, pX[0], pc, pmat, |
| 82 | + -2.0 * exx_alpha, //alpha; H=2K when D is symmetrized |
| 83 | + ATYPE_EXX::CC_vo, {}, hamilt::calculation_type::lr_dmdiff_exx); |
| 84 | + this->ops->add(op_ht_exx); |
| 85 | + } |
| 86 | +#endif |
| 87 | + |
58 | 88 | // 3. $2\sum_{jb,kc} g^{xc}_{ia, jb, kc}X_{jb}X_{kc}$ |
59 | | - this->pot_grad = std::make_shared<PotGradXCLR>(pot.lock()->xc_kernel_components, pot.lock()->get_rho_basis(), ucell, pot.lock()->nrxx); |
60 | | - // !!op_gxc has some bug |
61 | | - hamilt::Operator<T>* op_gxc = new OperatorLRHxc<T>(nspin, naos, nocc, nvirt, psi_ks, |
62 | | - *this->DM_trans, gint, this->pot_grad, ucell, orb_cutoff, gd, kv, pX, pc, pmat, |
63 | | - { 0 }, T(-2.0), ATYPE::CC_vo, hamilt::calculation_type::lr_dmtrans_vo); |
64 | | - assert(op_gxc != nullptr); |
65 | | - std::cout << "op_gxc=" << op_ht << std::endl; |
66 | | - this->ops->add(op_gxc); |
| 89 | + if (LR_Util::has_local_xc(xc_kernel)) |
| 90 | + { // !! op_gxc has some bug now |
| 91 | + this->pot_grad = std::make_shared<PotGradXCLR>(pot.lock()->xc_kernel_components, pot.lock()->get_rho_basis(), ucell, pot.lock()->nrxx); |
| 92 | + hamilt::Operator<T>* op_gxc = new OperatorLRHxc<T>(nspin, naos, nocc, nvirt, psi_ks, |
| 93 | + *this->DM_trans, gint, this->pot_grad, ucell, orb_cutoff, gd, kv, pX, pc, pmat, |
| 94 | + { 0 }, T(-2.0), ATYPE::CC_vo, hamilt::calculation_type::lr_dmtrans_gxc); |
| 95 | + assert(op_gxc != nullptr); |
| 96 | + std::cout << "op_gxc=" << op_ht << std::endl; |
| 97 | + this->ops->add(op_gxc); |
| 98 | + } |
67 | 99 | // // test: op_ht only |
68 | 100 | // delete this->ops; |
69 | 101 | // this->ops = new OperatorLRHxc<T>(nspin, naos, nocc, nvirt, psi_ks, |
70 | 102 | // *this->DM_diff, gint, pot_hxc_gs, ucell, orb_cutoff, gd, kv, pX, pc, pmat, |
71 | 103 | // { 0 }, T(-2.0), ATYPE::CC_vo); |
72 | | -#ifdef __EXX |
73 | | - // add EXX operators here |
74 | | -#endif |
| 104 | + |
75 | 105 | this->cal_dm_trans = [&, this](const int& is, const T* X)->void |
76 | 106 | { |
77 | 107 | const auto psi_ks_is = LR_Util::get_psi_spin(psi_ks, is, this->nk); |
|
0 commit comments