Skip to content

Commit

Permalink
Merge branch 'develop' into esolver-lip
Browse files Browse the repository at this point in the history
  • Loading branch information
kirk0830 authored Jul 5, 2024
2 parents 4ad528f + 76c62db commit 7be4d2c
Show file tree
Hide file tree
Showing 2 changed files with 114 additions and 73 deletions.
35 changes: 20 additions & 15 deletions source/module_elecstate/elecstate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -264,8 +264,9 @@ void ElecState::cal_nbands()
// calculate number of bands (setup.f90)
//=======================================
double occupied_bands = static_cast<double>(GlobalV::nelec / ModuleBase::DEGSPIN);
if (GlobalV::LSPINORB == 1)
if (GlobalV::LSPINORB == 1) {
occupied_bands = static_cast<double>(GlobalV::nelec);
}

if ((occupied_bands - std::floor(occupied_bands)) > 0.0)
{
Expand All @@ -274,51 +275,45 @@ void ElecState::cal_nbands()

ModuleBase::GlobalFunc::OUT(GlobalV::ofs_running, "occupied bands", occupied_bands);

// mohan add 2010-09-04
// std::cout << "nbands(this-> = " <<GlobalV::NBANDS <<std::endl;
if (GlobalV::NBANDS == occupied_bands)
{
if (Occupy::gauss())
{
ModuleBase::WARNING_QUIT("ElecState::cal_nbands", "for smearing, num. of bands > num. of occupied bands");
}
}

if (GlobalV::NBANDS == 0)
{
if (GlobalV::NSPIN == 1)
{
const int nbands1 = static_cast<int>(occupied_bands) + 10;
const int nbands2 = static_cast<int>(1.2 * occupied_bands) + 1;
GlobalV::NBANDS = std::max(nbands1, nbands2);
if (GlobalV::BASIS_TYPE != "pw")
if (GlobalV::BASIS_TYPE != "pw") {
GlobalV::NBANDS = std::min(GlobalV::NBANDS, GlobalV::NLOCAL);
}
}
else if (GlobalV::NSPIN == 4)
{
const int nbands3 = GlobalV::nelec + 20;
const int nbands4 = static_cast<int>(1.2 * GlobalV::nelec) + 1;
GlobalV::NBANDS = std::max(nbands3, nbands4);
if (GlobalV::BASIS_TYPE != "pw")
if (GlobalV::BASIS_TYPE != "pw") {
GlobalV::NBANDS = std::min(GlobalV::NBANDS, GlobalV::NLOCAL);
}
}
else if (GlobalV::NSPIN == 2)
{
const double max_occ = std::max(this->nelec_spin[0], this->nelec_spin[1]);
const int nbands3 = static_cast<int>(max_occ) + 11;
const int nbands4 = static_cast<int>(1.2 * max_occ) + 1;
GlobalV::NBANDS = std::max(nbands3, nbands4);
if (GlobalV::BASIS_TYPE != "pw")
if (GlobalV::BASIS_TYPE != "pw") {
GlobalV::NBANDS = std::min(GlobalV::NBANDS, GlobalV::NLOCAL);
}
}
ModuleBase::GlobalFunc::AUTO_SET("NBANDS", GlobalV::NBANDS);
}
// else if ( GlobalV::CALCULATION=="scf" || GlobalV::CALCULATION=="md" || GlobalV::CALCULATION=="relax") //pengfei
// 2014-10-13
else
{
if (GlobalV::NBANDS < occupied_bands)
if (GlobalV::NBANDS < occupied_bands) {
ModuleBase::WARNING_QUIT("unitcell", "Too few bands!");
}
if (GlobalV::NSPIN == 2)
{
if (GlobalV::NBANDS < this->nelec_spin[0])
Expand All @@ -334,6 +329,16 @@ void ElecState::cal_nbands()
}
}

// mohan add 2010-09-04
// std::cout << "nbands(this-> = " <<GlobalV::NBANDS <<std::endl;
if (GlobalV::NBANDS == occupied_bands)
{
if (Occupy::gauss())
{
ModuleBase::WARNING_QUIT("ElecState::cal_nbands", "for smearing, num. of bands > num. of occupied bands");
}
}

// mohan update 2021-02-19
// mohan add 2011-01-5
if (GlobalV::BASIS_TYPE == "lcao" || GlobalV::BASIS_TYPE == "lcao_in_pw")
Expand Down
Loading

0 comments on commit 7be4d2c

Please sign in to comment.