Skip to content

Commit

Permalink
Add several warning quits in DensityMatrix and Gint when paramete…
Browse files Browse the repository at this point in the history
…rs are not initialized (#4389)

* Add several warning quits when parameters are not initialized

* Change WARNING_QUIT to assert with __DEBUG flag in Gint and DM
  • Loading branch information
AsTonyshment committed Jun 16, 2024
1 parent 3ed543d commit 5413d23
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
12 changes: 12 additions & 0 deletions source/module_elecstate/module_dm/density_matrix.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -458,6 +458,12 @@ template <>
void DensityMatrix<std::complex<double>, double>::cal_DMR()
{
ModuleBase::TITLE("DensityMatrix", "cal_DMR");

// To check whether DMR has been initialized
#ifdef __DEBUG
assert(!this->_DMR.empty() && "DMR has not been initialized!");
#endif

ModuleBase::timer::tick("DensityMatrix", "cal_DMR");
int ld_hk = this->_paraV->nrow;
int ld_hk2 = 2 * ld_hk;
Expand Down Expand Up @@ -615,6 +621,12 @@ template <>
void DensityMatrix<double, double>::cal_DMR()
{
ModuleBase::TITLE("DensityMatrix", "cal_DMR");

// To check whether DMR has been initialized
#ifdef __DEBUG
assert(!this->_DMR.empty() && "DMR has not been initialized!");
#endif

ModuleBase::timer::tick("DensityMatrix", "cal_DMR");
int ld_hk = this->_paraV->nrow;
for (int is = 1; is <= this->_nspin; ++is)
Expand Down
6 changes: 6 additions & 0 deletions source/module_hamilt_lcao/module_gint/gint.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -687,6 +687,12 @@ void Gint::initialize_pvpR(const UnitCell& ucell_in, Grid_Driver* gd)
void Gint::transfer_DM2DtoGrid(std::vector<hamilt::HContainer<double>*> DM2D)
{
ModuleBase::TITLE("Gint", "transfer_DMR");

// To check whether input parameter DM2D has been initialized
#ifdef __DEBUG
assert(!DM2D.empty() && "Input parameter DM2D has not been initialized while calling function transfer_DM2DtoGrid!");
#endif

ModuleBase::timer::tick("Gint", "transfer_DMR");
if (GlobalV::NSPIN != 4)
{
Expand Down

0 comments on commit 5413d23

Please sign in to comment.