Skip to content

Commit 2d09ea6

Browse files
committed
Refactor: move dftu_cal_occup_m to dftu
1 parent f381836 commit 2d09ea6

File tree

7 files changed

+30
-57
lines changed

7 files changed

+30
-57
lines changed

source/Makefile.Objects

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,6 @@ OBJS_ESOLVER=esolver.o\
253253
OBJS_ESOLVER_LCAO=esolver_ks_lcao.o\
254254
esolver_ks_lcao_tddft.o\
255255
dpks_cal_e_delta_band.o\
256-
dftu_cal_occup_m.o\
257256
set_matrix_grid.o\
258257
lcao_before_scf.o\
259258
lcao_gets.o\

source/module_esolver/CMakeLists.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ if(ENABLE_LCAO)
2020
esolver_ks_lcao_tddft.cpp
2121
dpks_cal_e_delta_band.cpp
2222
set_matrix_grid.cpp
23-
dftu_cal_occup_m.cpp
2423
lcao_before_scf.cpp
2524
lcao_gets.cpp
2625
lcao_others.cpp

source/module_esolver/dftu_cal_occup_m.cpp

Lines changed: 0 additions & 50 deletions
This file was deleted.

source/module_esolver/esolver_ks_lcao.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
#include "module_base/tool_title.h"
66
#include "module_elecstate/module_dm/cal_dm_psi.h"
77
#include "module_hamilt_lcao/module_deltaspin/spin_constrain.h"
8+
#include "module_hamilt_lcao/module_dftu/dftu.h"
89
#include "module_io/berryphase.h"
910
#include "module_io/cube_io.h"
1011
#include "module_io/dos_nao.h"
@@ -873,7 +874,7 @@ void ESolver_KS_LCAO<TK, TR>::iter_finish(const int istep, int& iter)
873874
{
874875
const std::vector<std::vector<TK>>& tmp_dm
875876
= dynamic_cast<elecstate::ElecStateLCAO<TK>*>(this->pelec)->get_DM()->get_DMK_vector();
876-
this->dftu_cal_occup_m(iter, tmp_dm);
877+
ModuleDFTU::dftu_cal_occup_m(iter, tmp_dm, this->kv, this->p_chgmix->get_mixing_beta(), this->p_hamilt);
877878
}
878879
GlobalC::dftu.cal_energy_correction(istep);
879880
}

source/module_esolver/esolver_ks_lcao.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -97,10 +97,6 @@ class ESolver_KS_LCAO : public ESolver_KS<TK> {
9797
#endif
9898

9999
private:
100-
// tmp interfaces before sub-modules are refactored
101-
void dftu_cal_occup_m(const int& iter,
102-
const std::vector<std::vector<TK>>& dm) const;
103-
104100
#ifdef __DEEPKS
105101
void dpks_cal_e_delta_band(const std::vector<std::vector<TK>>& dm) const;
106102

source/module_hamilt_lcao/module_dftu/dftu.cpp

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -419,4 +419,25 @@ const hamilt::HContainer<double>* DFTU::get_dmr(int ispin) const
419419
}
420420
}
421421

422+
//! dftu occupation matrix for gamma only using dm(double)
423+
template <>
424+
void dftu_cal_occup_m(const int iter,
425+
const std::vector<std::vector<double>>& dm,
426+
const K_Vectors& kv,
427+
const double& mixing_beta,
428+
hamilt::Hamilt<double>* p_ham)
429+
{
430+
GlobalC::dftu.cal_occup_m_gamma(iter, dm, mixing_beta, p_ham);
431+
}
432+
433+
//! dftu occupation matrix for multiple k-points using dm(complex)
434+
template <>
435+
void dftu_cal_occup_m(const int iter,
436+
const std::vector<std::vector<std::complex<double>>>& dm,
437+
const K_Vectors& kv,
438+
const double& mixing_beta,
439+
hamilt::Hamilt<std::complex<double>>* p_ham)
440+
{
441+
GlobalC::dftu.cal_occup_m_k(iter, dm, kv, mixing_beta, p_ham);
442+
}
422443
} // namespace ModuleDFTU

source/module_hamilt_lcao/module_dftu/dftu.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -265,6 +265,13 @@ class DFTU
265265
const elecstate::DensityMatrix<std::complex<double>, double>* dm_in_dftu_cd = nullptr;
266266
};
267267

268+
template <typename T>
269+
void dftu_cal_occup_m(const int iter,
270+
const std::vector<std::vector<T>>& dm,
271+
const K_Vectors& kv,
272+
const double& mixing_beta,
273+
hamilt::Hamilt<T>* p_ham);
274+
268275
} // namespace ModuleDFTU
269276

270277
namespace GlobalC

0 commit comments

Comments
 (0)