diff --git a/source/module_elecstate/module_dm/density_matrix.cpp b/source/module_elecstate/module_dm/density_matrix.cpp index 269189662c..c80151caeb 100644 --- a/source/module_elecstate/module_dm/density_matrix.cpp +++ b/source/module_elecstate/module_dm/density_matrix.cpp @@ -458,6 +458,12 @@ template <> void DensityMatrix, 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; @@ -615,6 +621,12 @@ template <> void DensityMatrix::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) diff --git a/source/module_hamilt_lcao/module_gint/gint.cpp b/source/module_hamilt_lcao/module_gint/gint.cpp index 0ba40a0b51..affc14cf8a 100644 --- a/source/module_hamilt_lcao/module_gint/gint.cpp +++ b/source/module_hamilt_lcao/module_gint/gint.cpp @@ -687,6 +687,12 @@ void Gint::initialize_pvpR(const UnitCell& ucell_in, Grid_Driver* gd) void Gint::transfer_DM2DtoGrid(std::vector*> 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) {