Skip to content

Commit 683b69f

Browse files
committed
Refactor: add no_subspace judgement in DiagoCG
1 parent d242356 commit 683b69f

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

source/module_hsolver/diago_cg.cpp

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010
namespace hsolver
1111
{
1212

13+
bool DiagoCG::no_subspace = false;
14+
1315
DiagoCG::DiagoCG(Hamilt_PW *hpw_in, const double *precondition_in)
1416
{
1517
this->hpw = hpw_in;
@@ -496,7 +498,10 @@ void DiagoCG::diag(hamilt::Hamilt *phm_in, psi::Psi<std::complex<double>> &psi,
496498
this->notconv = 0;
497499
do
498500
{
499-
DiagoIterAssist::diagH_subspace(this->hpw, psi, psi, eigenvalue_in);
501+
if(!DiagoCG::no_subspace)
502+
{
503+
DiagoIterAssist::diagH_subspace(this->hpw, psi, psi, eigenvalue_in);
504+
}
500505

501506
DiagoIterAssist::avg_iter += 1.0;
502507
this->reorder = true;
@@ -511,6 +516,9 @@ void DiagoCG::diag(hamilt::Hamilt *phm_in, psi::Psi<std::complex<double>> &psi,
511516
std::cout << "\n notconv = " << this->notconv;
512517
std::cout << "\n DiagoCG::diag', too many bands are not converged! \n";
513518
}
519+
520+
if(DiagoCG::no_subspace) DiagoCG::no_subspace = false;
521+
514522
return;
515523
}
516524

source/module_hsolver/diago_cg.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@ class DiagoCG : public DiagH
3535
// this is the override function diag() for CG method
3636
void diag(hamilt::Hamilt *phm_in, psi::Psi<std::complex<double>> &psi, double *eigenvalue_in) override;
3737

38+
static bool no_subspace;
39+
3840
private:
3941
/// static variables, used for passing control variables
4042
/// if eigenvalue and eigenvectors should be reordered after diagonalization, it is always be true.

0 commit comments

Comments
 (0)