Skip to content

Commit 0752886

Browse files
authored
Merge pull request #1177 from dyzheng/v2.2.3
Merge PR172 PR174 PR175 PR178 from abacusmodeling/develop to deepmodeling/develop
2 parents 85aa162 + db57bfd commit 0752886

File tree

12 files changed

+315
-93
lines changed

12 files changed

+315
-93
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_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"

source/module_orbital/parallel_orbitals.cpp

Lines changed: 26 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,6 @@ Parallel_Orbitals::Parallel_Orbitals()
2020
// default value of nb is 1,
2121
// but can change to larger value from input.
2222
nb = 1;
23-
MatrixInfo.row_set = nullptr;
24-
MatrixInfo.col_set = nullptr;
2523

2624
// in multi-k, 2D-block-division variables for FT (R<->k)
2725
nnr = 1;
@@ -34,18 +32,16 @@ Parallel_Orbitals::~Parallel_Orbitals()
3432
delete[] trace_loc_row;
3533
delete[] trace_loc_col;
3634
delete[] loc_sizes;
37-
38-
if (alloc_Z_LOC) // xiaohui add 2014-12-22
39-
{
40-
for (int is = 0; is < this->nspin; is++)
41-
{
42-
delete[] Z_LOC[is];
43-
}
44-
delete[] Z_LOC;
45-
}
46-
delete[] MatrixInfo.row_set;
47-
delete[] MatrixInfo.col_set;
48-
35+
36+
if (alloc_Z_LOC)//xiaohui add 2014-12-22
37+
{
38+
for(int is=0; is<this->nspin; is++)
39+
{
40+
delete[] Z_LOC[is];
41+
}
42+
delete[] Z_LOC;
43+
}
44+
4945
delete[] nlocdim;
5046
delete[] nlocstart;
5147
}
@@ -287,24 +283,22 @@ void ORB_control::divide_HS_2d(
287283
pv->nloc = nlocal * nlocal;
288284
this->set_parameters(ofs_running, ofs_warning);
289285
pv->MatrixInfo.row_b = 1;
290-
pv->MatrixInfo.row_num = nlocal;
291-
delete[] pv->MatrixInfo.row_set;
292-
pv->MatrixInfo.row_set = new int[nlocal];
293-
for (int i = 0; i < nlocal; i++)
294-
{
295-
pv->MatrixInfo.row_set[i] = i;
296-
}
297-
pv->MatrixInfo.row_pos = 0;
298-
299-
pv->MatrixInfo.col_b = 1;
300-
pv->MatrixInfo.col_num = nlocal;
301-
delete[] pv->MatrixInfo.col_set;
302-
pv->MatrixInfo.col_set = new int[nlocal];
303-
for (int i = 0; i < nlocal; i++)
304-
{
305-
pv->MatrixInfo.col_set[i] = i;
306-
}
307-
pv->MatrixInfo.col_pos = 0;
286+
pv->MatrixInfo.row_num = nlocal;
287+
pv->MatrixInfo.row_set.resize(nlocal);
288+
for(int i=0; i<nlocal; i++)
289+
{
290+
pv->MatrixInfo.row_set[i]=i;
291+
}
292+
pv->MatrixInfo.row_pos=0;
293+
294+
pv->MatrixInfo.col_b = 1;
295+
pv->MatrixInfo.col_num = nlocal;
296+
pv->MatrixInfo.col_set.resize(nlocal);
297+
for(int i=0; i<nlocal; i++)
298+
{
299+
pv->MatrixInfo.col_set[i]=i;
300+
}
301+
pv->MatrixInfo.col_pos=0;
308302
#endif
309303

310304
assert(pv->nloc > 0);

source/src_pdiag/pdiag_common.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,12 @@
66
#endif
77
#include "../module_base/blas_connector.h"
88
#include "../module_base/lapack_connector.h" // Peize Lin add 2016-08-04
9+
#include <vector>
910

1011
struct LocalMatrix
1112
{
12-
int *row_set;
13-
int *col_set;
13+
std::vector<int> row_set; // Peize Lin change int* to vector 2022.08.03
14+
std::vector<int> col_set;
1415

1516
int col_num;
1617
int row_num;

source/src_ri/exx_abfs-inverse_matrix_double.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ void Exx_Abfs::Inverse_Matrix_Double::cal_inverse( const Method &method )
3535

3636
void Exx_Abfs::Inverse_Matrix_Double::using_dpotrf()
3737
{
38-
LapackConnector::dpotrf('U',dim,A,dim,&info);
38+
LapackConnector::dpotrf('U',dim,A,dim,info);
3939

4040
if(info!=0)
4141
{
@@ -45,7 +45,7 @@ void Exx_Abfs::Inverse_Matrix_Double::using_dpotrf()
4545
ModuleBase::QUIT();
4646
}
4747

48-
LapackConnector::dpotri('U',dim,A,dim,&info);
48+
LapackConnector::dpotri('U',dim,A,dim,info);
4949

5050
if(info!=0)
5151
{

0 commit comments

Comments
 (0)