Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions source/source_estate/elecstate_lcao.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#include "source_io/module_parameter/parameter.h"

#include "source_lcao/module_gint/gint_interface.h"
#include "source_lcao/rho_tau_lcao.h"

#include <vector>

Expand Down Expand Up @@ -84,6 +85,15 @@ void ElecStateLCAO<std::complex<double>>::dm2rho(std::vector<std::complex<double
}


template <typename TK>
void ElecStateLCAO<TK>::dmToRho(std::vector<hamilt::HContainer<double>*>& dmr,
int nspin,
Charge* chr,
bool skip_charge)
{
LCAO_domain::dm2rho(dmr, nspin, chr, skip_charge);
}

template class ElecStateLCAO<double>; // Gamma_only case
template class ElecStateLCAO<std::complex<double>>; // multi-k case

Expand Down
17 changes: 15 additions & 2 deletions source/source_estate/elecstate_lcao.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,23 @@ class ElecStateLCAO : public ElecState
* @param pexsi_EDM: pointers of energy-weighed density matrix (EDMK) calculated by pexsi, needed by MD, will be
* stored in DensityMatrix::pexsi_EDM
*/
void dm2rho(std::vector<TK*> pexsi_DM,
std::vector<TK*> pexsi_EDM,
void dm2rho(std::vector<TK*> pexsi_DM,
std::vector<TK*> pexsi_EDM,
DensityMatrix<TK, double>* dm);

/**
* @brief calculate electronic charge density from the density matrix (DMR)
*
* Thin wrapper over LCAO_domain::dm2rho so that HSolverLCAO delegates the
* charge-density calculation through the ElecState interface, mirroring the
* plane-wave path (ElecStatePW::psiToRho) and the pexsi branch above. This
* keeps the source_lcao dependency out of source_hsolver.
*/
void dmToRho(std::vector<hamilt::HContainer<double>*>& dmr,
int nspin,
Charge* chr,
bool skip_charge = false);

};

template <typename TK>
Expand Down
6 changes: 3 additions & 3 deletions source/source_hsolver/hsolver_lcao.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,6 @@
#include "source_hsolver/parallel_k2d.h"
#include "source_io/module_parameter/parameter.h"

#include "source_lcao/rho_tau_lcao.h" // mohan add 20251024

namespace hsolver
{

Expand Down Expand Up @@ -103,7 +101,9 @@ void HSolverLCAO<TK, Device>::solve(hamilt::Hamilt<TK>* pHamilt,
if (!skip_charge)
{
// compute charge density from density matrix, mohan update 20251024
LCAO_domain::dm2rho(dm.get_DMR_vector(), nspin, &chr);
// delegate to ElecStateLCAO to keep the source_lcao dependency out of
// source_hsolver (mirrors the pexsi branch below and the PW psiToRho path)
dynamic_cast<elecstate::ElecStateLCAO<TK>*>(pes)->dmToRho(dm.get_DMR_vector(), nspin, &chr);
}
else
{
Expand Down
Loading