Skip to content

Commit e15654f

Browse files
committed
Merge branch 'develop' of github.com:deepmodeling/abacus-develop into HSolver
2 parents 1a548f6 + 0752886 commit e15654f

File tree

20 files changed

+367
-129
lines changed

20 files changed

+367
-129
lines changed

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,7 @@ result.out
1212
html
1313
*.log
1414
STRU_READIN_ADJUST.cif
15+
*.egg
16+
*.egg-info
17+
build
18+
dist

docs/input-main.md

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1051,13 +1051,26 @@ This part of variables are relevant when using hybrid functionals
10511051
10521052
#### exx_hse_omega
10531053
1054-
- **Type**:
1054+
- **Type**: Real
10551055
- **Description**: range-separation parameter in HSE functional, such that $1/r=erfc(\omega r)/r+erf(\omega r)/r$.
10561056
- **Default**: 0.11
10571057
1058-
adial integration for pseudopotentials, in Bohr.
1059-
@@ -214,6 +279,13 @@ This part of variables are used to control general system para
1058+
#### exx_separate_loop
1059+
1060+
- **Type**: Boolean
1061+
- **Description**: There are two types of iterative approach provided by ABACUS to evaluate Fock exchange. If this parameter is set to 0, it will start with a GGA-Loop, and then Hybrid-Loop, in which EXX Hamiltonian $H_{exx}$ is updated with electronic iterations. If this parameter is set to 1, a two-step method is employed, i.e. in the inner iterations, density matrix is updated, while in the outer iterations, $H_{exx}$ is calculated based on density matrix that converges in the inner iteration.
1062+
- **Default**: 1
1063+
1064+
#### exx_hybrid_step
10601065
1066+
- **Type**: Integer
1067+
- **Description**: This variable indicates the maximal electronic iteration number in the evaluation of Fock exchange.
1068+
- **Default**: 100
1069+
1070+
#### exx_lambda
1071+
1072+
- **Type**: Real
1073+
- **Description**: It is used to compensate for divergence points at G=0 in the evaluation of Fock exchange using *lcao_in_pw* method.
10611074
- **Default**: 0.3
10621075
10631076
#### exx_pca_threshold

docs/install.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ If environment variable `MKLROOT` exists, `cmake` will take MKL as a preference,
100100
You can also choose to build with which components, e.g.:
101101

102102
```bash
103-
cmake -B build -DUSE_LIBXC=1 -DUSE_CUDA=1
103+
cmake -B build -DENABLE_LIBXC=1 -DUSE_CUDA=1
104104
```
105105

106106
If Libxc is not installed in standard path (i.e. installed with a custom prefix path), you can set `Libxc_DIR` to the corresponding directory.

source/module_base/blas_connector.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,10 @@ extern "C"
3636
double dznrm2_( const int *n, const std::complex<double> *X, const int *incX );
3737

3838
// level 2: matrix-std::vector operations, O(n^2) data and O(n^2) work.
39-
void dgemv_(const char *transa, const int *m, const int *n, const double *alpha, const double *a,
40-
const int *lda, const double *x, const int *incx, const double *beta, double *y, const int *incy);
41-
39+
void dgemv_(const char*const transa, const int*const m, const int*const n,
40+
const double*const alpha, const double*const a, const int*const lda, const double*const x, const int*const incx,
41+
const double*const beta, double*const y, const int*const incy);
42+
4243
void zgemv_(const char *trans, const int *m, const int *n, const std::complex<double> *alpha,
4344
const std::complex<double> *a, const int *lda, const std::complex<double> *x, const int *incx,
4445
const std::complex<double> *beta, std::complex<double> *y, const int *incy);

source/module_base/lapack_connector.h

Lines changed: 23 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,8 @@ extern "C"
6060
// Peize Lin add dsptrf and dsptri 2016-06-21, to compute inverse real symmetry indefinit matrix.
6161
// dpotrf computes the Cholesky factorization of a real symmetric positive definite matrix
6262
// while dpotri taks its output to perform matrix inversion
63-
void dpotrf_(const char* uplo,const int* n, double* A, const int* lda, int *info);
64-
void dpotri_(const char* uplo,const int* n, double* A, const int* lda, int *info);
63+
void dpotrf_(const char*const uplo, const int*const n, double*const A, const int*const lda, int*const info);
64+
void dpotri_(const char*const uplo, const int*const n, double*const A, const int*const lda, int*const info);
6565

6666
// zgetrf computes the LU factorization of a general matrix
6767
// while zgetri takes its output to perform matrix inversion
@@ -345,20 +345,34 @@ class LapackConnector
345345

346346
// Peize Lin add 2016-07-09
347347
static inline
348-
void dpotrf( char uplo, const int n, ModuleBase::matrix &a, const int lda, int *info )
348+
void dpotrf( const char &uplo, const int &n, double*const A, const int &lda, int &info )
349349
{
350350
const char uplo_changed = change_uplo(uplo);
351-
dpotrf_( &uplo_changed, &n, a.c, &lda, info );
352-
}
353-
351+
dpotrf_( &uplo_changed, &n, A, &lda, &info );
352+
}
353+
354354
// Peize Lin add 2016-07-09
355355
static inline
356-
void dpotri( char uplo, const int n, ModuleBase::matrix &a, const int lda, int *info )
356+
void dpotri( const char &uplo, const int &n, double*const A, const int &lda, int &info )
357357
{
358358
const char uplo_changed = change_uplo(uplo);
359-
dpotri_( &uplo_changed, &n, a.c, &lda, info);
360-
}
359+
dpotri_( &uplo_changed, &n, A, &lda, &info);
360+
}
361361

362+
// Peize Lin add 2016-07-09
363+
static inline
364+
void dpotrf( const char &uplo, const int &n, ModuleBase::matrix &A, const int &lda, int &info )
365+
{
366+
dpotrf( uplo, n, A.c, lda, info );
367+
}
368+
369+
// Peize Lin add 2016-07-09
370+
static inline
371+
void dpotri( const char &uplo, const int &n, ModuleBase::matrix &A, const int &lda, int &info )
372+
{
373+
dpotri( uplo, n, A.c, lda, info);
374+
}
375+
362376
// Peize Lin add 2019-04-14
363377
// if trans=='N': C = a * A * A.H + b * C
364378
// if trans=='C': C = a * A.H * A + b * C

source/module_base/tool_quit.cpp

Lines changed: 29 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -129,24 +129,41 @@ void WARNING_QUIT(const std::string &file,const std::string &description)
129129
}
130130

131131

132-
//Input judgement and communicate , if any judgement is true, do WARNING_QUIT
133-
void CHECK_WARNING_QUIT(bool error_in, const std::string &file,const std::string &description)
132+
//Check and print warning information for all cores.
133+
//Maybe in the future warning.log should be replaced by error.log.
134+
void CHECK_WARNING_QUIT(const bool error_in, const std::string &file,const std::string &description)
134135
{
135-
int error = (int)error_in;
136136
#ifdef __NORMAL
137137
// only for UT, do nothing here
138138
#else
139-
#ifdef __MPI
140-
int error_max = error;
141-
MPI_Reduce(&error, &error_max, 1, MPI_INT, MPI_MAX, 0, MPI_COMM_WORLD);
142-
MPI_Bcast(&error_max, 1, MPI_INT, 0, MPI_COMM_WORLD);
143-
error = error_max;
144-
#endif
145-
#endif
146-
if(error)
139+
if(error_in)
147140
{
148-
WARNING_QUIT(file, description);
141+
//All cores will print inforamtion
142+
std::cout.clear();
143+
if(!GlobalV::ofs_running.is_open())
144+
{
145+
std::string logfile = GlobalV::global_out_dir + "running_" + GlobalV::CALCULATION + ".log";
146+
GlobalV::ofs_running.open( logfile.c_str(), std::ios::app );
147+
}
148+
if(!GlobalV::ofs_warning.is_open())
149+
{
150+
std::string warningfile = GlobalV::global_out_dir + "warning.log";
151+
GlobalV::ofs_warning.open( warningfile.c_str(), std::ios::app );
152+
}
153+
154+
//print error information
155+
std::cout << " !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" << std::endl;
156+
std::cout << " ERROR! " << description << std::endl;
157+
std::cout << " CHECK IN FILE : " << GlobalV::global_out_dir << "warning.log" << std::endl;
158+
std::cout << " !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" << std::endl;
159+
GlobalV::ofs_running << " ERROR! CHECK IN FILE : " << GlobalV::global_out_dir << "warning.log" << std::endl;
160+
GlobalV::ofs_warning << std::endl;
161+
GlobalV::ofs_warning << " ERROR! " << file << ", core " << GlobalV::MY_RANK+1 << ": " << description << std::endl;
162+
GlobalV::ofs_warning << std::endl;
163+
exit(0);
149164
}
165+
#endif
166+
return;
150167
}
151168

152169
}

source/module_base/tool_quit.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ void WARNING_QUIT(const std::string &file, const std::string &description);
4949
* @param file The file where warning happens
5050
* @param description The warning information
5151
*/
52-
void CHECK_WARNING_QUIT(bool error, const std::string &file,const std::string &description);
52+
void CHECK_WARNING_QUIT(const bool error, const std::string &file,const std::string &description);
5353

5454
} // namespace ModuleBase
5555

source/module_hamilt/ks_pw/meta_pw.cpp

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -61,11 +61,13 @@ void Meta<OperatorPW>::act
6161
}
6262

6363
wfcpw->recip2real(porter, porter, ik);
64-
65-
const double* pvk = &(this->vk[0](current_spin, 0));
66-
for (int ir = 0; ir < this->vk->nc; ir++)
64+
if(this->vk->nc != 0)
6765
{
68-
porter[ir] *= pvk[ir];
66+
const double* pvk = &(this->vk[0](current_spin, 0));
67+
for (int ir = 0; ir < this->vk->nc; ir++)
68+
{
69+
porter[ir] *= pvk[ir];
70+
}
6971
}
7072
wfcpw->real2recip(porter, porter, ik);
7173

source/module_orbital/ORB_control.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -416,8 +416,7 @@ int ORB_control::mat_2d(MPI_Comm vu,
416416
// (5) row_set, it's a global index :
417417
// save explicitly : every row in this processor
418418
// belongs to which row in the global matrix.
419-
delete[] LM.row_set;
420-
LM.row_set = new int[LM.row_num];
419+
LM.row_set.resize(LM.row_num);
421420
j = 0;
422421
for (i = 0; i < LM.row_b; i++)
423422
{
@@ -475,8 +474,7 @@ int ORB_control::mat_2d(MPI_Comm vu,
475474

476475
if (pv->testpb)ModuleBase::GlobalFunc::OUT(ofs_running, "Local columns (including nb)", LM.row_num);
477476

478-
delete[] LM.col_set;
479-
LM.col_set = new int[LM.col_num];
477+
LM.col_set.resize(LM.col_num);
480478

481479
j = 0;
482480
for (i = 0; i < LM.col_b; i++)

source/module_orbital/ORB_table_phi.cpp

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@
55
#include "../module_base/constants.h"
66
#include "../module_base/timer.h"
77

8+
#ifdef _OPENMP
9+
#include <omp.h>
10+
#endif
11+
812
double ORB_table_phi::dr = -1.0;
913

1014
ORB_table_phi::ORB_table_phi()
@@ -128,9 +132,7 @@ void ORB_table_phi::cal_ST_Phi12_R
128132
{
129133
ModuleBase::timer::tick("ORB_table_phi", "cal_ST_Phi12_R");
130134

131-
double* k1_dot_k2 = new double[kmesh];
132-
double* k1_dot_k2_dot_kpoint = new double[kmesh];
133-
135+
std::vector<double> k1_dot_k2(kmesh);
134136
// Peize Lin change 2017-12-12
135137
switch(job)
136138
{
@@ -166,6 +168,7 @@ void ORB_table_phi::cal_ST_Phi12_R
166168
break;
167169
}
168170

171+
std::vector<double> k1_dot_k2_dot_kpoint(kmesh);
169172
for (int ik = 0; ik < kmesh; ik++)
170173
{
171174
k1_dot_k2_dot_kpoint[ik] = k1_dot_k2[ik] * this->kpoint[ik];
@@ -176,7 +179,7 @@ void ORB_table_phi::cal_ST_Phi12_R
176179

177180
//previous version
178181

179-
double* integrated_func = new double[kmesh];
182+
//double* integrated_func = new double[kmesh];
180183

181184
int ll;
182185
if(l==0) ll=0;
@@ -186,8 +189,12 @@ void ORB_table_phi::cal_ST_Phi12_R
186189
const std::vector<std::vector<double>> &jl = pSB->get_jlx()[l];
187190
const std::vector<std::vector<double>> &jlp1 = pSB->get_jlx()[l+1];
188191

192+
#ifdef _OPENMP
193+
#pragma omp parallel for schedule(static)
194+
#endif
189195
for (int ir = 0; ir < rmesh; ir++)
190196
{
197+
std::vector<double> integrated_func(kmesh);
191198
const std::vector<double> &jl_r = jl[ir];
192199
for (int ik=0; ik<kmesh; ++ik)
193200
{
@@ -196,7 +203,7 @@ void ORB_table_phi::cal_ST_Phi12_R
196203
// Call simpson integration
197204
double temp = 0.0;
198205

199-
ModuleBase::Integral::Simpson_Integral(kmesh,integrated_func,dk,temp);
206+
ModuleBase::Integral::Simpson_Integral(kmesh, integrated_func.data(), dk, temp);
200207
rs[ir] = temp * ModuleBase::FOUR_PI ;
201208

202209
// Peize Lin accelerate 2017-10-02
@@ -218,7 +225,7 @@ void ORB_table_phi::cal_ST_Phi12_R
218225
}
219226
}
220227

221-
ModuleBase::Integral::Simpson_Integral(kmesh,integrated_func,dk,temp);
228+
ModuleBase::Integral::Simpson_Integral(kmesh, integrated_func.data(), dk, temp);
222229
drs[ir] = -ModuleBase::FOUR_PI*(l+1)/(2.0*l+1) * temp;
223230
}
224231

@@ -228,25 +235,19 @@ void ORB_table_phi::cal_ST_Phi12_R
228235

229236
if (l > 0)
230237
{
231-
ModuleBase::GlobalFunc::ZEROS(integrated_func,kmesh);
238+
std::vector<double> integrated_func(kmesh);
232239
double temp = 0.0;
233240

234241
for (int ik = 0; ik < kmesh; ik++)
235242
{
236-
integrated_func[ik] = k1_dot_k2[ik] * pow (kpoint[ik], l);
243+
integrated_func[ik] = k1_dot_k2[ik] * std::pow (kpoint[ik], l);
237244
}
238245

239-
ModuleBase::Integral::Simpson_Integral(kmesh,integrated_func,kab,temp);
246+
ModuleBase::Integral::Simpson_Integral(kmesh, integrated_func.data(), kab, temp);
240247
rs[0] = ModuleBase::FOUR_PI / ModuleBase::Mathzone_Add1::dualfac (2*l+1) * temp;
241248
}
242249

243-
delete [] integrated_func;
244-
delete [] k1_dot_k2;
245-
delete [] k1_dot_k2_dot_kpoint;
246-
247250
ModuleBase::timer::tick("ORB_table_phi", "cal_ST_Phi12_R");
248-
249-
return;
250251
}
251252

252253
#include "../module_base/constants.h"

0 commit comments

Comments
 (0)