Skip to content

Commit

Permalink
update sKG method
Browse files Browse the repository at this point in the history
  • Loading branch information
Qianruipku committed Sep 3, 2023
1 parent 2df6594 commit 3540258
Show file tree
Hide file tree
Showing 7 changed files with 132 additions and 136 deletions.
4 changes: 0 additions & 4 deletions source/module_esolver/esolver_sdft_pw.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -211,10 +211,6 @@ void ESolver_SDFT_PW::postprocess()
{
cond_nche = set_cond_nche(INPUT.cond_dt, INPUT.cond_dtbatch, 1e-8);
nche_test = std::max(nche_test, cond_nche);
if (this->method_sto == 2)
{
nche_test = std::max(nche_test, this->nche_sto * 2);
}
}
if (nche_test > 0)
check_che(nche_test);
Expand Down
227 changes: 115 additions & 112 deletions source/module_esolver/esolver_sdft_pw_tool.cpp

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions source/module_hamilt_pw/hamilt_stodft/sto_func.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -124,15 +124,15 @@ REAL Sto_Func<REAL>:: n_root_fdlnfd(REAL rawe)
}

template<typename REAL>
REAL Sto_Func<REAL>::n_fd(REAL rawe)
REAL Sto_Func<REAL>::nroot_mfd(REAL rawe)
{
REAL Ebar = (Emin + Emax)/2;
REAL DeltaE = (Emax - Emin)/2;
REAL ne_mu = (rawe * DeltaE + Ebar - mu) / this->tem ;
if(ne_mu > 36)
return 1;
if(ne_mu < -72)
return 0;
else
return 1 - 1 / (1 + exp(ne_mu));
return 1 / sqrt(1 + exp(-ne_mu));
}

template<typename REAL>
Expand Down
2 changes: 1 addition & 1 deletion source/module_hamilt_pw/hamilt_stodft/sto_func.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class Sto_Func
REAL fdlnfd(REAL e);
REAL nfdlnfd(REAL e);
REAL n_root_fdlnfd(REAL e);
REAL n_fd(REAL e);
REAL nroot_mfd(REAL e);

public:
REAL t;
Expand Down
11 changes: 4 additions & 7 deletions source/module_hamilt_pw/hamilt_stodft/sto_iter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -154,16 +154,13 @@ void Stochastic_Iter::checkemm(const int& ik, const int istep, const int iter, S
}
if (ik == nks - 1)
{
stofunc.Emax = stohchi.Emax;
stofunc.Emin = stohchi.Emin;

#ifdef __MPI
MPI_Allreduce(MPI_IN_PLACE, &stofunc.Emax, 1, MPI_DOUBLE, MPI_MAX, MPI_COMM_WORLD);
MPI_Allreduce(MPI_IN_PLACE, &stofunc.Emin, 1, MPI_DOUBLE, MPI_MIN, MPI_COMM_WORLD);
MPI_Allreduce(MPI_IN_PLACE, &stohchi.Emax, 1, MPI_DOUBLE, MPI_MAX, MPI_COMM_WORLD);
MPI_Allreduce(MPI_IN_PLACE, &stohchi.Emin, 1, MPI_DOUBLE, MPI_MIN, MPI_COMM_WORLD);
MPI_Allreduce(MPI_IN_PLACE, &change, 1, MPI_CHAR, MPI_LOR, MPI_COMM_WORLD);
#endif
stohchi.Emin = stofunc.Emin;
stohchi.Emax = stofunc.Emax;
stofunc.Emax = stohchi.Emax;
stofunc.Emin = stohchi.Emin;
if (change)
{
GlobalV::ofs_running << "New Emax " << stohchi.Emax << " ; new Emin " << stohchi.Emin << std::endl;
Expand Down
8 changes: 4 additions & 4 deletions tests/integrate/184_PW_BNDKPAR_SDFT_ALL/result.ref
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
etotref -103.9856616767304018
etotperatomref -51.9928308384
totalforceref 197.980186
totalstressref 257668.675547
etotref -103.9857283719017573
etotperatomref -51.9928641860
totalforceref 197.980360
totalstressref 257668.731244
totaltimeref +1.39407
8 changes: 4 additions & 4 deletions tests/integrate/184_PW_BNDKPAR_SDFT_MALL/result.ref
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
etotref -103.9856591181551977
etotperatomref -51.9928295591
totalforceref 197.979930
totalstressref 257668.804420
etotref -103.9857257248261391
etotperatomref -51.9928628624
totalforceref 197.980106
totalstressref 257668.861146
totaltimeref +5.34573

0 comments on commit 3540258

Please sign in to comment.