Skip to content

Commit 072d03e

Browse files
mohanchenYuLiu98
andauthored
Refactor the LCAO DOS codes (deepmodeling#6127)
* update some timers * update timer * update output formats * update print_cell * add ofs in print_tau * update print_tau * update output formats * update md outputs * beging modifying the autotests * update integrate tests * update some timers * fix total force and total stress * update integrate tests * update print_band * fix print_band * update md print out information * update print_stress * update print_stress in dp, but still has problems in lj * fix dp_test.cpp * update esolver_lj * set mulliken charge accuracy from 4 to 3 * update print force and print stress * delete kv variable in hamilt_lcao * update some operators * update hamiltonian and operator * update updateHk funciton parameters * fix bug * fix bug in updateHk * update updateSk * update read atoms * update SCAN_BEGIN, now the function ignore lines starting with # * update * add SCAN_LINE_BEGIN * fix bug * fix issue * update dos output file name * update dos * update DOS, fix an output bug * update DOS calculations * output format updated * update warning message for reading charge density * fix tool_quit * fix write_dos_pw_test.cpp * update unittests * change Chinese note to English * update some formats * update some outputs * update DOS in integrated tests * update ref data * add prepare_dos in cal_dos.cpp * use prepare_dos in write_dos_lcao.cpp * update LCAO DOS codes * change DOS name * fix DOS name in SDFT * add dat after DOS and TDOS * add pdos * add cal_pdos * update ref for DOS * update cal_pdos_gamma * update timer and quit tests * update pdos multik * fix two issues in unittests * update text in CMakeLists.txt * update dos lcao * update cal_pdos * update dos files * update cal_pdos * move cal_pdos to LCAO codes --------- Co-authored-by: Yu Liu <[email protected]>
1 parent 28d8902 commit 072d03e

12 files changed

+604
-735
lines changed

CMakeLists.txt

+33-27
Original file line numberDiff line numberDiff line change
@@ -10,39 +10,45 @@ project(
1010
HOMEPAGE_URL "https://github.com/deepmodeling/abacus-develop"
1111
LANGUAGES CXX)
1212

13-
option(ENABLE_LCAO "Enable LCAO calculation." ON)
14-
option(ENABLE_DEEPKS "Enable DeePKS functionality" OFF)
15-
option(ENABLE_MLKEDF "Enable Machine Learning based KEDF for OFDFT" OFF)
16-
option(ENABLE_LIBXC "Enable LibXC functionality" OFF)
17-
option(USE_CUDA "Enable support to CUDA for ABACUS." OFF)
18-
option(ENABLE_FLOAT_FFTW "Enable support to single precision FFTW library." OFF)
19-
option(USE_ROCM "Enable support to ROCm." OFF)
20-
option(USE_OPENMP "Enable OpenMP in ABACUS." ON)
13+
option(ENABLE_MPI "Enable MPI" ON)
14+
option(USE_OPENMP "Enable OpenMP" ON)
15+
option(USE_CUDA "Enable CUDA" OFF)
16+
option(USE_CUDA_MPI "Enable CUDA-aware MPI" OFF)
17+
option(USE_CUDA_ON_DCU "Enable CUDA on DCU" OFF)
18+
option(USE_ROCM "Enable ROCm" OFF)
19+
option(USE_DSP "Enable DSP" OFF)
20+
21+
option(USE_ABACUS_LIBM "Build libmath from source to speed up" OFF)
22+
option(ENABLE_LIBXC "Enable using the LibXC package" OFF)
23+
option(ENABLE_FLOAT_FFTW "Enable using single-precision FFTW library." OFF)
24+
option(ENABLE_DEEPKS "Enable the DeePKS algorithm" OFF)
25+
option(ENABLE_MLKEDF "Enable the Machine-Learning-based KEDF for OFDFT" OFF)
26+
27+
option(ENABLE_LCAO "Enable LCAO algorithm" ON)
28+
option(USE_ELPA "Enable ELPA for LCAO" ON)
29+
option(ENABLE_LIBRI "Enable LibRI for hybrid functional" OFF)
30+
option(ENABLE_LIBCOMM "Enable LibComm" OFF)
31+
option(ENABLE_PEXSI "Enable PEXSI for LCAO" OFF)
32+
33+
option(BUILD_TESTING "Build unittests" OFF)
34+
option(DEBUG_INFO "Print message to debug" OFF)
2135
option(ENABLE_ASAN "Enable AddressSanitizer" OFF)
22-
option(BUILD_TESTING "Build ABACUS unit tests" OFF)
23-
option(INFO "Enable gathering of math library information" OFF)
24-
option(ENABLE_COVERAGE "Enable coverage build." OFF)
25-
option(ENABLE_LIBRI "Enable EXX with LibRI." OFF)
26-
option(ENABLE_LIBCOMM "Enable communicate with LibComm." OFF)
27-
option(ENABLE_PAW "Enable PAW calculation" OFF)
28-
option(ENABLE_MPI "Enable compilation with or without MPI." ON)
29-
option(USE_ELPA "Enable ELPA" ON)
30-
option(USE_ABACUS_LIBM "Build libmath from source to speed up." OFF)
36+
option(INFO "Enable gathering math library information" OFF)
37+
option(ENABLE_COVERAGE "Enable coverage build" OFF)
3138
option(GIT_SUBMODULE "Check submodules during build" ON)
32-
option(DEBUG_INFO "Print message for developers to debug." OFF)
39+
40+
option(ENABLE_PAW "Enable PAW method" OFF)
41+
3342
# Do not enable it if generated code will run on different CPUs
3443
option(ENABLE_NATIVE_OPTIMIZATION
3544
"Enable compilation optimization for the native machine's CPU type" OFF)
45+
3646
option(COMMIT_INFO "Print commit information in log" ON)
37-
option(ENABLE_FFT_TWO_CENTER "Enable FFT-based two-center integral method." ON)
38-
option(ENABLE_GOOGLEBENCH "Enable GOOGLE-benchmark usage." OFF)
39-
option(ENABLE_RAPIDJSON "Enable rapid-json usage." OFF)
40-
option(ENABLE_CNPY "Enable cnpy usage." OFF)
41-
option(ENABLE_PEXSI "Enable support for PEXSI." OFF)
42-
option(ENABLE_CUSOLVERMP "Enable cusolvermp." OFF)
43-
option(USE_DSP "Enable DSP usage." OFF)
44-
option(USE_CUDA_ON_DCU "Enable CUDA on DCU" OFF)
45-
option(USE_CUDA_MPI "Enable CUDA-aware MPI" OFF)
47+
option(ENABLE_FFT_TWO_CENTER "Enable FFT-based two-center integral method" ON)
48+
option(ENABLE_GOOGLEBENCH "Enable GOOGLE-benchmark usage" OFF)
49+
option(ENABLE_RAPIDJSON "Enable rapid-json usage" OFF)
50+
option(ENABLE_CNPY "Enable cnpy usage" OFF)
51+
option(ENABLE_CUSOLVERMP "Enable cusolvermp" OFF)
4652

4753
# enable json support
4854
if(ENABLE_RAPIDJSON)

source/Makefile.Objects

+2
Original file line numberDiff line numberDiff line change
@@ -497,6 +497,8 @@ OBJS_IO=input_conv.o\
497497
write_dos_pw.o\
498498
nscf_band.o\
499499
cal_dos.o\
500+
cal_pdos_gamma.o\
501+
cal_pdos_multik.o\
500502
cal_ldos.o\
501503
cif_io.o\
502504
dos_nao.o\

source/module_esolver/esolver_ks_lcao.cpp

+13-13
Original file line numberDiff line numberDiff line change
@@ -405,19 +405,19 @@ void ESolver_KS_LCAO<TK, TR>::after_all_runners(UnitCell& ucell)
405405

406406
// 5) print out density of states (DOS)
407407
if (PARAM.inp.out_dos)
408-
{
409-
ModuleIO::out_dos_nao(this->psi,
410-
this->pv,
411-
this->pelec->ekb,
412-
this->pelec->wg,
413-
PARAM.inp.dos_edelta_ev,
414-
PARAM.inp.dos_scale,
415-
PARAM.inp.dos_sigma,
416-
*(this->pelec->klist),
417-
ucell,
418-
this->pelec->eferm,
419-
PARAM.inp.nbands,
420-
this->p_hamilt);
408+
{
409+
ModuleIO::out_dos_nao(this->psi,
410+
this->p_hamilt,
411+
this->pv,
412+
ucell,
413+
*(this->pelec->klist),
414+
PARAM.inp.nbands,
415+
this->pelec->eferm,
416+
this->pelec->ekb,
417+
this->pelec->wg,
418+
PARAM.inp.dos_edelta_ev,
419+
PARAM.inp.dos_scale,
420+
PARAM.inp.dos_sigma);
421421
}
422422

423423
// out ldos

source/module_io/CMakeLists.txt

+2
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,8 @@ list(APPEND objects_advanced
4848
if(ENABLE_LCAO)
4949
list(APPEND objects
5050
write_dos_lcao.cpp
51+
cal_pdos_gamma.cpp
52+
cal_pdos_multik.cpp
5153
write_orb_info.cpp
5254
write_proj_band_lcao.cpp
5355
nscf_fermi_surf.cpp

source/module_io/cal_pdos_gamma.cpp

+33-16
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,27 @@
1-
#include "cal_pdos.h"
2-
3-
void ModuleIO::cal_pdos_gamma(
1+
#include "cal_pdos_gamma.h"
2+
3+
#include "module_base/parallel_reduce.h"
4+
#include "module_base/blas_connector.h"
5+
#include "module_base/scalapack_connector.h"
6+
#include "write_orb_info.h"
7+
#include "module_base/global_function.h"
8+
#include "module_base/global_variable.h"
9+
#include "module_hamilt_pw/hamilt_pwdft/global.h"
10+
#include "module_hamilt_lcao/hamilt_lcaodft/hamilt_lcao.h"
11+
12+
void ModuleIO::cal_pdos(
13+
const psi::Psi<double>* psi,
14+
hamilt::Hamilt<double>* p_ham,
15+
const Parallel_Orbitals& pv,
16+
const UnitCell& ucell,
17+
const K_Vectors& kv,
418
const int nspin0,
19+
const int nbands,
20+
const ModuleBase::matrix& ekb,
521
const double& emax,
622
const double& emin,
723
const double& dos_edelta_ev,
8-
const double& bcoeff,
9-
const double* sk,
10-
const psi::Psi<double>* psi,
11-
const Parallel_Orbitals& pv)
24+
const double& bcoeff)
1225
{
1326
ModuleBase::TITLE("ModuleIO", "cal_pdos_gamma");
1427

@@ -34,7 +47,8 @@ void ModuleIO::cal_pdos_gamma(
3447
pdos[is].create(nlocal, npoints, true);
3548
}
3649

37-
double b = sqrt(ModuleBase::TWO_PI) * bcoeff;
50+
const double a = bcoeff;
51+
const double b = sqrt(ModuleBase::TWO_PI) * a;
3852

3953
std::complex<double>* waveg = new std::complex<double>[nlocal];
4054

@@ -69,6 +83,9 @@ void ModuleIO::cal_pdos_gamma(
6983
const double zero_float = 0.0;
7084
const int one_int = 1;
7185

86+
const double* sk = dynamic_cast<const hamilt::HamiltLCAO<double, double>*>(p_ham)->getSk();
87+
//const double* sk = nullptr;
88+
7289
#ifdef __MPI
7390
const char T_char = 'T';
7491
const int nlocal = PARAM.globalv.nlocal;
@@ -120,23 +137,23 @@ void ModuleIO::cal_pdos_gamma(
120137

121138
if (GlobalV::MY_RANK == 0)
122139
{
123-
print_tdos_gamma(pdos);
124-
print_pdos_gamma(pdos);
140+
print_tdos_gamma(pdos, nlocal, npoints, emin, dos_edelta_ev);
141+
print_pdos_gamma(ucell, pdos, nlocal, npoints, emin, dos_edelta_ev);
125142
ModuleIO::write_orb_info(&ucell);
126143
}
127144

128145
delete[] pdos;
129146
}
130147

131148

132-
void write_tdos_gamma(
133-
const ModuleBase::matrix& pdos,
149+
void ModuleIO::print_tdos_gamma(
150+
const ModuleBase::matrix* pdos,
134151
const int nlocal,
135152
const int npoints,
136153
const double& emin,
137154
const double& dos_edelta_ev)
138155
{
139-
ModuleBase::TITLE("ModuleIO", "write_tdos_gamma");
156+
ModuleBase::TITLE("ModuleIO", "print_tdos_gamma");
140157

141158
// file name
142159
std::stringstream ps;
@@ -179,15 +196,15 @@ void write_tdos_gamma(
179196
ofs.close();
180197
}
181198

182-
void write_pdos_gamma(
199+
void ModuleIO::print_pdos_gamma(
183200
const UnitCell& ucell,
184-
const ModuleBase::matrix& pdos,
201+
const ModuleBase::matrix* pdos,
185202
const int nlocal,
186203
const int npoints,
187204
const double& emin,
188205
const double& dos_edelta_ev)
189206
{
190-
ModuleBase::TITLE("ModuleIO", "write_pdos_gamma");
207+
ModuleBase::TITLE("ModuleIO", "print_pdos_gamma");
191208

192209
std::stringstream as;
193210
as << PARAM.globalv.global_out_dir << "PDOS.dat";

source/module_io/cal_pdos_gamma.h

+17-9
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,39 @@
1-
#ifndef PDOS_H
2-
#define PDOS_H
1+
#ifndef CAL_PDOS_GAMMA_H
2+
#define CAL_PDOS_GAMMA_H
33

44
#include "module_base/matrix.h"
5+
#include "module_cell/klist.h" // use K_Vectors
6+
#include "module_psi/psi.h" // use psi::Psi<T>
7+
#include "module_hamilt_general/hamilt.h" // use hamilt::Hamilt<T>
8+
#include "module_basis/module_ao/parallel_orbitals.h" // use Parallel_Orbitals
59

610
namespace ModuleIO
711
{
812

9-
void cal_pdos_gamma(
13+
void cal_pdos(
14+
const psi::Psi<double>* psi,
15+
hamilt::Hamilt<double>* p_ham,
16+
const Parallel_Orbitals& pv,
17+
const UnitCell& ucell,
18+
const K_Vectors& kv,
1019
const int nspin0,
20+
const int nbands,
21+
const ModuleBase::matrix& ekb,
1122
const double& emax,
1223
const double& emin,
1324
const double& dos_edelta_ev,
14-
const double& bcoeff,
15-
const double* sk,
16-
const psi::Psi<double>* psi,
17-
const Parallel_Orbitals& pv);
25+
const double& bcoeff);
1826

1927
void print_tdos_gamma(
20-
const ModuleBase::matrix& pdos,
28+
const ModuleBase::matrix* pdos,
2129
const int nlocal,
2230
const int npoints,
2331
const double& emin,
2432
const double& dos_edelta_ev);
2533

2634
void print_pdos_gamma(
2735
const UnitCell& ucell,
28-
const ModuleBase::matrix& pdos,
36+
const ModuleBase::matrix* pdos,
2937
const int nlocal,
3038
const int npoints,
3139
const double& emin,

0 commit comments

Comments
 (0)