Skip to content

Commit 8e5677f

Browse files
committed
fix bug in ELF
1 parent 64f1757 commit 8e5677f

File tree

14 files changed

+107
-28
lines changed

14 files changed

+107
-28
lines changed

source/Makefile.Objects

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,7 @@ OBJS_ELECSTAT=elecstate.o\
252252
update_pot.o\
253253

254254
OBJS_ELECSTAT_LCAO=elecstate_lcao.o\
255-
setup_dm.o\
255+
init_dm.o\
256256
density_matrix.o\
257257
density_matrix_io.o\
258258
cal_dm_psi.o\

source/source_esolver/esolver_ks_lcao.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
#endif
1515
#include "source_lcao/module_rdmft/rdmft.h"
1616
#include "source_estate/module_charge/chgmixing.h" // use charge mixing, mohan add 20251006
17-
#include "source_estate/module_dm/setup_dm.h" // setup dm from electronic wave functions
17+
#include "source_estate/module_dm/init_dm.h" // init dm from electronic wave functions
1818
#include "source_io/ctrl_runner_lcao.h" // use ctrl_runner_lcao()
1919
#include "source_io/ctrl_iter_lcao.h" // use ctrl_iter_lcao()
2020
#include "source_io/ctrl_scf_lcao.h" // use ctrl_scf_lcao()
@@ -383,7 +383,7 @@ void ESolver_KS_LCAO<TK, TR>::iter_init(UnitCell& ucell, const int istep, const
383383
this->exx_nao.exd->two_level_step : this->exx_nao.exc->two_level_step;
384384
}
385385
#endif
386-
elecstate::setup_dm<TK>(ucell, estate, this->psi, this->chr, iter, exx_two_level_step);
386+
elecstate::init_dm<TK>(ucell, estate, this->psi, this->chr, iter, exx_two_level_step);
387387
}
388388

389389
#ifdef __EXX

source/source_esolver/esolver_ks_pw.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -359,6 +359,7 @@ void ESolver_KS_PW<T, Device>::after_scf(UnitCell& ucell, const int istep, const
359359
if (PARAM.inp.out_elf[0] > 0)
360360
{
361361
this->ESolver_KS<T, Device>::psi = new psi::Psi<T>(this->stp.psi_cpu[0]);
362+
this->pelec->cal_tau(*(this->psi));
362363
}
363364

364365
// Call 'after_scf' of ESolver_KS

source/source_estate/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ if(ENABLE_LCAO)
4646
list(APPEND objects
4747
elecstate_lcao.cpp
4848
module_pot/H_TDDFT_pw.cpp
49-
module_dm/setup_dm.cpp
49+
module_dm/init_dm.cpp
5050
module_dm/density_matrix.cpp
5151
module_dm/density_matrix_io.cpp
5252
module_dm/cal_dm_psi.cpp

source/source_estate/elecstate_lcao.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ void ElecStateLCAO<double>::dm2Rho(std::vector<double*> pexsi_DM, std::vector<do
8181
}
8282

8383
template <>
84-
void ElecStateLCAO<std::complex<double>>::dm2Rho(std::vector<std::complex<double>*> pexsi_DM,
84+
void ElecStateLCAO<std::complex<double>>::dm2rho(std::vector<std::complex<double>*> pexsi_DM,
8585
std::vector<std::complex<double>*> pexsi_EDM)
8686
{
8787
ModuleBase::WARNING_QUIT("ElecStateLCAO", "pexsi is not completed for multi-k case");

source/source_estate/elecstate_lcao.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ class ElecStateLCAO : public ElecState
5656
* @param pexsi_EDM: pointers of energy-weighed density matrix (EDMK) calculated by pexsi, needed by MD, will be
5757
* stored in DensityMatrix::pexsi_EDM
5858
*/
59-
void dm2Rho(std::vector<TK*> pexsi_DM, std::vector<TK*> pexsi_EDM);
59+
void dm2rho(std::vector<TK*> pexsi_DM, std::vector<TK*> pexsi_EDM);
6060
#endif
6161

6262
DensityMatrix<TK, double>* DM = nullptr;

source/source_estate/module_dm/setup_dm.cpp renamed to source/source_estate/module_dm/init_dm.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
1-
#include "source_estate/module_dm/setup_dm.h"
1+
#include "source_estate/module_dm/init_dm.h"
22
#include "source_estate/module_dm/cal_dm_psi.h"
33
#include "source_estate/elecstate_tools.h"
44
#include "source_estate/cal_ux.h"
55

66
template <typename TK>
7-
void elecstate::setup_dm(UnitCell& ucell,
7+
void elecstate::init_dm(UnitCell& ucell,
88
elecstate::ElecStateLCAO<TK>* pelec,
99
psi::Psi<TK>* psi,
1010
Charge &chr,
1111
const int iter,
1212
const int exx_two_level_step)
1313
{
14-
ModuleBase::TITLE("elecstate", "setup_dm");
14+
ModuleBase::TITLE("elecstate", "init_dm");
1515

1616
if (iter == 1 && exx_two_level_step == 0)
1717
{
@@ -49,14 +49,14 @@ void elecstate::setup_dm(UnitCell& ucell,
4949
}
5050

5151

52-
template void elecstate::setup_dm<double>(UnitCell& ucell,
52+
template void elecstate::init_dm<double>(UnitCell& ucell,
5353
elecstate::ElecStateLCAO<double>* pelec,
5454
psi::Psi<double>* psi,
5555
Charge &chr,
5656
const int iter,
5757
const int exx_two_level_step);
5858

59-
template void elecstate::setup_dm<std::complex<double>>(UnitCell& ucell,
59+
template void elecstate::init_dm<std::complex<double>>(UnitCell& ucell,
6060
elecstate::ElecStateLCAO<std::complex<double>>* pelec,
6161
psi::Psi<std::complex<double>>* psi,
6262
Charge &chr,

source/source_estate/module_dm/setup_dm.h renamed to source/source_estate/module_dm/init_dm.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
#ifndef SETUP_DM_H
2-
#define SETUP_DM_H
1+
#ifndef INIT_DM_H
2+
#define INIT_DM_H
33

44
#include "source_cell/unitcell.h" // use unitcell
55
#include "source_estate/elecstate_lcao.h"// use ElecStateLCAO
@@ -10,7 +10,7 @@ namespace elecstate
1010
{
1111

1212
template <typename TK>
13-
void setup_dm(UnitCell& ucell,
13+
void init_dm(UnitCell& ucell,
1414
ElecStateLCAO<TK>* pelec,
1515
psi::Psi<TK>* psi,
1616
Charge &chr,

source/source_hsolver/hsolver_lcao.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ void HSolverLCAO<T, Device>::solve(hamilt::Hamilt<T>* pHamilt,
124124
auto _pes = dynamic_cast<elecstate::ElecStateLCAO<T>*>(pes);
125125
pes->f_en.eband = pe.totalFreeEnergy;
126126
// maybe eferm could be dealt with in the future
127-
_pes->dmToRho(pe.DM, pe.EDM);
127+
_pes->dm2rho(pe.DM, pe.EDM);
128128
#endif
129129
}
130130

source/source_io/ctrl_scf_lcao.cpp

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
#endif
3030
#include "source_lcao/module_rdmft/rdmft.h" // use RDMFT codes
3131
#include "source_io/to_qo.h" // use toQO
32+
#include "source_lcao/rho_tau_lcao.h" // mohan add 2025-10-24
3233

3334

3435
template <typename TK, typename TR>
@@ -368,10 +369,16 @@ void ModuleIO::ctrl_scf_lcao(UnitCell& ucell,
368369
std::cout << FmtCore::format(" >> Finish %s.\n * * * * * *\n", "Wave function to Wannier90");
369370
}
370371

372+
// 14) calculate the kinetic energy density tau
373+
// mohan add 2025-10-24
374+
if (inp.out_elf[0] > 0)
375+
{
376+
LCAO_domain::dm2tau(pelec->DM->get_DMR_vector(), inp.nspin, pelec->charge);
377+
}
371378

372379
#ifdef __EXX
373380
//------------------------------------------------------------------
374-
//! 14) Output Hexx matrix in LCAO basis
381+
//! 15) Output Hexx matrix in LCAO basis
375382
// (see `out_chg` in docs/advanced/input_files/input-main.md)
376383
//------------------------------------------------------------------
377384
if (inp.out_chg[0])
@@ -392,7 +399,7 @@ void ModuleIO::ctrl_scf_lcao(UnitCell& ucell,
392399
}
393400

394401
//------------------------------------------------------------------
395-
//! 15) Write RPA information in LCAO basis
402+
//! 16) Write RPA information in LCAO basis
396403
//------------------------------------------------------------------
397404
if (inp.rpa)
398405
{
@@ -408,7 +415,7 @@ void ModuleIO::ctrl_scf_lcao(UnitCell& ucell,
408415
#endif
409416

410417
//------------------------------------------------------------------
411-
//! 16) Perform RDMFT calculations, added by jghan, 2024-10-17
418+
//! 17) Perform RDMFT calculations, added by jghan, 2024-10-17
412419
//------------------------------------------------------------------
413420
if (inp.rdmft == true)
414421
{

0 commit comments

Comments
 (0)