Skip to content

Commit 7e035ed

Browse files
authored
Merge branch 'develop' into pulay_fs
2 parents c6f9717 + 7e6eee7 commit 7e035ed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+279
-372
lines changed

.github/workflows/coverage.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,10 @@ jobs:
1515
uses: actions/checkout@v4
1616
- name: Install Requirements for Coverage Testing
1717
run: |
18-
apt update && apt install -y lcov
18+
apt update && apt install -y lcov gpg
1919
- name: Building
2020
run: |
21-
cmake -B build -DENABLE_DEEPKS=ON -DENABLE_LIBXC=ON -DBUILD_TESTING=ON -DENABLE_COVERAGE=ON
21+
cmake -B build -DENABLE_COVERAGE=ON -DBUILD_TESTING=ON -DENABLE_DEEPKS=ON -DENABLE_LIBXC=ON -DENABLE_LIBRI=ON -DENABLE_PAW=ON -DENABLE_GOOGLEBENCH=ON -DENABLE_RAPIDJSON=ON
2222
cmake --build build -j`nproc`
2323
cmake --install build
2424
- name: Testing

.github/workflows/test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ jobs:
3939
--from-ref ${{ github.event.pull_request.base.sha }}
4040
--to-ref ${{ github.event.pull_request.head.sha }}
4141
continue-on-error: true
42-
- uses: pre-commit-ci/lite-action@v1.0.3
42+
- uses: pre-commit-ci/lite-action@v1.1.0
4343

4444
- name: Build
4545
run: |

docs/advanced/install.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,9 +93,9 @@ cmake -B build -DUSE_CUDA=1 -DCMAKE_CUDA_COMPILER=${path to cuda toolkit}/bin/nv
9393

9494
## Build math library from source
9595

96-
> Note: This flag is **enabled by default**. It will get better performance than the standard implementation on `gcc` and `clang`. But it **will be disabled** when using `Intel Compiler` since the math functions will get wrong results and the performance is also unexpectly poor.
96+
> Note: We recommend using the latest available compiler sets, since they offer faster implementations of math functions.
9797
98-
To build math functions from source code, instead of using c++ standard implementation, define `USE_ABACUS_LIBM` flag.
98+
This flag is disabled by default. To build math functions from source code, define `USE_ABACUS_LIBM` flag. It is expected to get a better performance on legacy versions of `gcc` and `clang`.
9999

100100
Currently supported math functions:
101101
`sin`, `cos`, `sincos`, `exp`, `cexp`

source/driver.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ void Driver::init()
4141

4242
// (3) output information
4343
time_t time_finish = std::time(nullptr);
44-
Print_Info::print_time(time_start, time_finish);
44+
ModuleIO::print_time(time_start, time_finish);
4545

4646
// (4) close all of the running logs
4747
ModuleBase::Global_File::close_all_log(GlobalV::MY_RANK, PARAM.inp.out_alllog,PARAM.inp.calculation);

source/module_elecstate/elecstate_lcao_tddft.cpp

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,8 @@ void ElecStateLCAO_TDDFT::psiToRho_td(const psi::Psi<std::complex<double>>& psi)
2222

2323
// this part for calculating DMK in 2d-block format, not used for charge now
2424
// psi::Psi<std::complex<double>> dm_k_2d();
25-
26-
if (PARAM.inp.ks_solver == "genelpa" || PARAM.inp.ks_solver == "scalapack_gvx"
27-
|| PARAM.inp.ks_solver == "lapack") // Peize Lin test 2019-05-15
28-
{
29-
elecstate::cal_dm_psi(this->DM->get_paraV_pointer(), this->wg, psi, *(this->DM));
30-
this->DM->cal_DMR();
31-
}
25+
elecstate::cal_dm_psi(this->DM->get_paraV_pointer(), this->wg, psi, *(this->DM));
26+
this->DM->cal_DMR();
3227

3328
for (int is = 0; is < PARAM.inp.nspin; is++)
3429
{

source/module_elecstate/potentials/H_TDDFT_pw.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,7 @@ int H_TDDFT_pw::check_ncut(int t_type)
227227
break;
228228

229229
case 3:
230-
ncut = 1;
230+
ncut = 2;
231231
break;
232232

233233
// case 4:

source/module_esolver/esolver.h

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -58,11 +58,8 @@ class ESolver
5858
return 0;
5959
}
6060

61-
// get conv_elec used in current scf
62-
virtual bool get_conv_elec()
63-
{
64-
return true;
65-
}
61+
bool conv_esolver = true; // whether esolver is converged
62+
6663
std::string classname;
6764
};
6865

source/module_esolver/esolver_fp.cpp

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -119,23 +119,14 @@ void ESolver_FP::before_all_runners(const Input_para& inp, UnitCell& cell)
119119
return;
120120
}
121121

122-
//------------------------------------------------------------------------------
123-
//! the 12th function of ESolver_KS: get_conv_elec
124-
//! tqzhao add 2024-05-15
125-
//------------------------------------------------------------------------------
126-
bool ESolver_FP::get_conv_elec()
127-
{
128-
return this->conv_elec;
129-
}
130-
131122
//! Something to do after SCF iterations when SCF is converged or comes to the max iter step.
132123
void ESolver_FP::after_scf(const int istep)
133124
{
134125
// 0) output convergence information
135-
ModuleIO::output_convergence_after_scf(this->conv_elec, this->pelec->f_en.etot);
126+
ModuleIO::output_convergence_after_scf(this->conv_esolver, this->pelec->f_en.etot);
136127

137128
// 1) write fermi energy
138-
ModuleIO::output_efermi(this->conv_elec, this->pelec->eferm.ef);
129+
ModuleIO::output_efermi(this->conv_esolver, this->pelec->eferm.ef);
139130

140131
// 2) update delta rho for charge extrapolation
141132
CE.update_delta_rho(GlobalC::ucell, &(this->chr), &(this->sf));

source/module_esolver/esolver_fp.h

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,6 @@ namespace ModuleESolver
4444
//! Initialize of the first-principels energy solver
4545
virtual void before_all_runners(const Input_para& inp, UnitCell& cell) override;
4646

47-
// get conv_elec used in current scf
48-
virtual bool get_conv_elec() override;
49-
5047
virtual void init_after_vc(const Input_para& inp, UnitCell& cell); // liuyu add 2023-03-09
5148

5249
//! Electronic states
@@ -64,8 +61,6 @@ namespace ModuleESolver
6461
//! K points in Brillouin zone
6562
K_Vectors kv;
6663

67-
bool conv_elec; // If electron density is converged in scf.
68-
6964
protected:
7065
//! Something to do after SCF iterations when SCF is converged or comes to the max iter step.
7166
virtual void after_scf(const int istep);

source/module_esolver/esolver_ks.cpp

Lines changed: 16 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,12 @@
77
#include <chrono>
88
#endif
99
#include "module_base/timer.h"
10+
#include "module_cell/cal_atoms_info.h"
1011
#include "module_io/json_output/init_info.h"
12+
#include "module_io/output_log.h"
1113
#include "module_io/print_info.h"
1214
#include "module_io/write_istate_info.h"
1315
#include "module_parameter/parameter.h"
14-
#include "module_cell/cal_atoms_info.h"
1516

1617
#include <iostream>
1718
//--------------Temporary----------------
@@ -221,7 +222,7 @@ void ESolver_KS<T, Device>::before_all_runners(const Input_para& inp, UnitCell&
221222
ModuleBase::GlobalFunc::DONE(GlobalV::ofs_running, "INIT K-POINTS");
222223

223224
//! 7) print information
224-
Print_Info::setup_parameters(ucell, this->kv);
225+
ModuleIO::setup_parameters(ucell, this->kv);
225226

226227
//! 8) new plane wave basis, fft grids, etc.
227228
#ifdef __MPI
@@ -419,7 +420,7 @@ void ESolver_KS<T, Device>::runner(const int istep, UnitCell& ucell)
419420
ModuleBase::GlobalFunc::DONE(GlobalV::ofs_running, "INIT SCF");
420421

421422
bool firstscf = true;
422-
this->conv_elec = false;
423+
this->conv_esolver = false;
423424
this->niter = this->maxniter;
424425

425426
// 4) SCF iterations
@@ -429,7 +430,7 @@ void ESolver_KS<T, Device>::runner(const int istep, UnitCell& ucell)
429430
for (int iter = 1; iter <= this->maxniter; ++iter)
430431
{
431432
// 5) write head
432-
this->write_head(GlobalV::ofs_running, istep, iter);
433+
ModuleIO::write_head(GlobalV::ofs_running, istep, iter, this->basisname);
433434

434435
#ifdef __MPI
435436
auto iterstart = MPI_Wtime();
@@ -496,9 +497,9 @@ void ESolver_KS<T, Device>::runner(const int istep, UnitCell& ucell)
496497
PARAM.inp.esolver_type,
497498
diag_ethr,
498499
PARAM.inp.nelec);
499-
500+
500501
// The error of HSolver is larger than drho,
501-
// so a more precise HSolver should be excuconv_elected.
502+
// so a more precise HSolver should be executed.
502503
if (hsolver_error > drho)
503504
{
504505
diag_ethr = hsolver::reset_diag_ethr(GlobalV::ofs_running,
@@ -540,11 +541,11 @@ void ESolver_KS<T, Device>::runner(const int istep, UnitCell& ucell)
540541
}
541542
#endif
542543

543-
this->conv_elec = (drho < this->scf_thr && not_restart_step && is_U_converged);
544+
this->conv_esolver = (drho < this->scf_thr && not_restart_step && is_U_converged);
544545

545546
// If drho < hsolver_error in the first iter or drho < scf_thr, we
546547
// do not change rho.
547-
if (drho < hsolver_error || this->conv_elec)
548+
if (drho < hsolver_error || this->conv_esolver)
548549
{
549550
if (drho < hsolver_error)
550551
{
@@ -577,13 +578,13 @@ void ESolver_KS<T, Device>::runner(const int istep, UnitCell& ucell)
577578
}
578579
#ifdef __MPI
579580
MPI_Bcast(&drho, 1, MPI_DOUBLE, 0, PARAPW_WORLD);
580-
MPI_Bcast(&this->conv_elec, 1, MPI_DOUBLE, 0, PARAPW_WORLD);
581+
MPI_Bcast(&this->conv_esolver, 1, MPI_DOUBLE, 0, PARAPW_WORLD);
581582
MPI_Bcast(pelec->charge->rho[0], this->pw_rhod->nrxx, MPI_DOUBLE, 0, PARAPW_WORLD);
582583
#endif
583584

584585
// 9) update potential
585586
// Hamilt should be used after it is constructed.
586-
// this->phamilt->update(conv_elec);
587+
// this->phamilt->update(conv_esolver);
587588
this->update_pot(istep, iter);
588589

589590
// 10) finish scf iterations
@@ -617,7 +618,7 @@ void ESolver_KS<T, Device>::runner(const int istep, UnitCell& ucell)
617618
#endif //__RAPIDJSON
618619

619620
// 13) check convergence
620-
if (this->conv_elec)
621+
if (this->conv_esolver)
621622
{
622623
this->niter = iter;
623624
break;
@@ -632,7 +633,7 @@ void ESolver_KS<T, Device>::runner(const int istep, UnitCell& ucell)
632633
std::cout << " >> Leave SCF iteration.\n * * * * * *" << std::endl;
633634
#ifdef __RAPIDJSON
634635
// 14) add Json of efermi energy converge
635-
Json::add_output_efermi_converge(this->pelec->eferm.ef * ModuleBase::Ry_to_eV, this->conv_elec);
636+
Json::add_output_efermi_converge(this->pelec->eferm.ef * ModuleBase::Ry_to_eV, this->conv_esolver);
636637
#endif //__RAPIDJSON
637638

638639
// 15) after scf
@@ -666,9 +667,9 @@ void ESolver_KS<T, Device>::iter_finish(int& iter)
666667
this->pelec->f_en.etot_old = this->pelec->f_en.etot;
667668

668669
// add a energy threshold for SCF convergence
669-
if (this->conv_elec == 0) // only check when density is not converged
670+
if (this->conv_esolver == 0) // only check when density is not converged
670671
{
671-
this->conv_elec
672+
this->conv_esolver
672673
= (iter != 1 && std::abs(this->pelec->f_en.etot_delta * ModuleBase::Ry_to_eV) < this->scf_ene_thr);
673674
}
674675
}
@@ -687,33 +688,6 @@ void ESolver_KS<T, Device>::after_scf(const int istep)
687688
}
688689
}
689690

690-
//------------------------------------------------------------------------------
691-
//! the 8th function of ESolver_KS: print_head
692-
//! mohan add 2024-05-12
693-
//------------------------------------------------------------------------------
694-
template <typename T, typename Device>
695-
void ESolver_KS<T, Device>::print_head()
696-
{
697-
std::cout << " " << std::setw(7) << "ITER";
698-
699-
if (PARAM.inp.nspin == 2)
700-
{
701-
std::cout << std::setw(10) << "TMAG";
702-
std::cout << std::setw(10) << "AMAG";
703-
}
704-
705-
std::cout << std::setw(15) << "ETOT(eV)";
706-
std::cout << std::setw(15) << "EDIFF(eV)";
707-
std::cout << std::setw(11) << "DRHO";
708-
709-
if (XC_Functional::get_func_type() == 3 || XC_Functional::get_func_type() == 5)
710-
{
711-
std::cout << std::setw(11) << "DKIN";
712-
}
713-
714-
std::cout << std::setw(11) << "TIME(s)" << std::endl;
715-
}
716-
717691
//------------------------------------------------------------------------------
718692
//! the 8th function of ESolver_KS: print_iter
719693
//! mohan add 2024-05-12
@@ -725,18 +699,7 @@ void ESolver_KS<T, Device>::print_iter(const int iter,
725699
const double duration,
726700
const double ethr)
727701
{
728-
this->pelec->print_etot(this->conv_elec, iter, drho, dkin, duration, PARAM.inp.printe, ethr);
729-
}
730-
731-
//------------------------------------------------------------------------------
732-
//! the 9th function of ESolver_KS: write_head
733-
//! mohan add 2024-05-12
734-
//------------------------------------------------------------------------------
735-
template <typename T, typename Device>
736-
void ESolver_KS<T, Device>::write_head(std::ofstream& ofs_running, const int istep, const int iter)
737-
{
738-
ofs_running << "\n " << this->basisname << " ALGORITHM --------------- ION=" << std::setw(4) << istep + 1
739-
<< " ELEC=" << std::setw(4) << iter << "--------------------------------\n";
702+
this->pelec->print_etot(this->conv_esolver, iter, drho, dkin, duration, PARAM.inp.printe, ethr);
740703
}
741704

742705
//------------------------------------------------------------------------------

0 commit comments

Comments
 (0)