Skip to content

Commit 4198f33

Browse files
committed
Merge branch 'develop' of https://github.com/deepmodeling/abacus-develop into hotfix
2 parents 1a30fdc + c1cb6ac commit 4198f33

File tree

178 files changed

+1562
-1569
lines changed

Some content is hidden

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

178 files changed

+1562
-1569
lines changed

CMakeLists.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ option(ENABLE_CNPY "Enable cnpy usage." OFF)
4040
option(ENABLE_PEXSI "Enable support for PEXSI." OFF)
4141
option(ENABLE_CUSOLVERMP "Enable cusolvermp." OFF)
4242
option(USE_DSP "Enable DSP usage." OFF)
43+
option(USE_CUDA_ON_DCU "Enable CUDA on DCU" OFF)
4344

4445
# enable json support
4546
if(ENABLE_RAPIDJSON)
@@ -126,6 +127,10 @@ if (USE_DSP)
126127
set(ABACUS_BIN_NAME abacus_dsp)
127128
endif()
128129

130+
if (USE_CUDA_ON_DCU)
131+
add_compile_definitions(__CUDA_ON_DCU)
132+
endif()
133+
129134
list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake)
130135

131136
if(ENABLE_COVERAGE)

docs/advanced/input_files/input-main.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
- [ndx, ndy, ndz](#ndx-ndy-ndz)
3838
- [pw\_seed](#pw_seed)
3939
- [pw\_diag\_thr](#pw_diag_thr)
40+
- [diago\_smooth\_ethr](#diago_smooth_ethr)
4041
- [pw\_diag\_nmax](#pw_diag_nmax)
4142
- [pw\_diag\_ndim](#pw_diag_ndim)
4243
- [erf\_ecut](#erf_ecut)
@@ -777,6 +778,12 @@ These variables are used to control the plane wave related parameters.
777778
- **Description**: Only used when you use `ks_solver = cg/dav/dav_subspace/bpcg`. It indicates the threshold for the first electronic iteration, from the second iteration the pw_diag_thr will be updated automatically. **For nscf calculations with planewave basis set, pw_diag_thr should be <= 1e-3.**
778779
- **Default**: 0.01
779780

781+
### diago_smooth_ethr
782+
783+
- **Type**: bool
784+
- **Description**: If `TRUE`, the smooth threshold strategy, which applies a larger threshold (10e-5) for the empty states, will be implemented in the diagonalization methods. (This strategy should not affect total energy, forces, and other ground-state properties, but computational efficiency will be improved.) If `FALSE`, the smooth threshold strategy will not be applied.
785+
- **Default**: false
786+
780787
### pw_diag_nmax
781788

782789
- **Type**: Integer
@@ -1375,6 +1382,7 @@ These variables are used to control the geometry relaxation.
13751382
- **Description**: The methods to do geometry optimization.
13761383
- cg: using the conjugate gradient (CG) algorithm. Note that there are two implementations of the conjugate gradient (CG) method, see [relax_new](#relax_new).
13771384
- bfgs: using the Broyden–Fletcher–Goldfarb–Shanno (BFGS) algorithm.
1385+
- bfgs_trad: using the traditional Broyden–Fletcher–Goldfarb–Shanno (BFGS) algorithm.
13781386
- cg_bfgs: using the CG method for the initial steps, and switching to BFGS method when the force convergence is smaller than [relax_cg_thr](#relax_cg_thr).
13791387
- sd: using the steepest descent (SD) algorithm.
13801388
- fire: the Fast Inertial Relaxation Engine method (FIRE), a kind of molecular-dynamics-based relaxation algorithm, is implemented in the molecular dynamics (MD) module. The algorithm can be used by setting [calculation](#calculation) to `md` and [md_type](#md_type) to `fire`. Also ionic velocities should be set in this case. See [fire](../md.md#fire) for more details.

docs/advanced/opt.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,9 @@ In the nested procedure mentioned above, we used CG method to perform cell relax
2222

2323
The [BFGS method](https://en.wikipedia.org/wiki/Broyden%E2%80%93Fletcher%E2%80%93Goldfarb%E2%80%93Shanno_algorithm) is a quasi-Newton method for solving nonlinear optimization problem. It belongs to the class of quasi-Newton method where the Hessian matrix is approximated during the optimization process. If the initial point is not far from the extrema, BFGS tends to work better than gradient-based methods.
2424

25-
In ABACUS, we implemented the BFGS method for doing fixed-cell structural relaxation.
25+
There is an alternative traditional BFGS method, which can be called by using the keyword 'bfgs_trad'. The bfgs_trad method is a quasi-Newton method that substitute an approximate matrix B for the Hessian matrix. The main difference between 'bfgs' and 'bfgs_trad' is that 'bfgs' updates the inverse of matrix B while 'bfgs_trad' updates matrix B and obtains the inverse of B by solving the matrix eigenvalues and taking the reciprocal of the eigenvalues. Both methods are mathematically equivalent, but in some cases, 'bfgs_trad' performs better.
26+
27+
In ABACUS, we implemented the BFGS method for doing fixed-cell structural relaxation. Users can choose which implementation of BFGS to call by adding the 'bfgs_trad' or 'bfgs' parameter.
2628

2729
### SD method
2830

source/module_base/module_device/device.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ void record_device_memory(const Device* dev, std::ofstream& ofs_device, std::str
8686
* @brief for compatibility with __CUDA_ARCH__ 600 and earlier
8787
*
8888
*/
89-
#if defined(__CUDA_ARCH__) && __CUDA_ARCH__ < 600
89+
#if defined(__CUDA_ARCH__) && __CUDA_ARCH__ < 600 && !defined(__CUDA_ON_DCU)
9090
static __inline__ __device__ double atomicAdd(double* address, double val)
9191
{
9292
unsigned long long int* address_as_ull = (unsigned long long int*)address;

source/module_cell/module_neighbor/sltk_grid_driver.cpp

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,11 @@ Grid_Driver::~Grid_Driver()
2121
{
2222
}
2323

24-
25-
void Grid_Driver::Find_atom(
26-
const UnitCell &ucell,
27-
const ModuleBase::Vector3<double> &cartesian_pos,
28-
const int &ntype,
29-
const int &nnumber,
30-
AdjacentAtomInfo *adjs)
24+
void Grid_Driver::Find_atom(const UnitCell& ucell,
25+
const ModuleBase::Vector3<double>& cartesian_pos,
26+
const int& ntype,
27+
const int& nnumber,
28+
AdjacentAtomInfo* adjs) const
3129
{
3230
ModuleBase::timer::tick("Grid_Driver","Find_atom");
3331
// std::cout << "lenght in Find atom = " << atomlink[offset].fatom.getAdjacentSet()->getLength() << std::endl;

source/module_cell/module_neighbor/sltk_grid_driver.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ class Grid_Driver : public Grid
7070
const ModuleBase::Vector3<double>& cartesian_posi,
7171
const int& ntype,
7272
const int& nnumber,
73-
AdjacentAtomInfo* adjs = nullptr);
73+
AdjacentAtomInfo* adjs = nullptr) const;
7474

7575
//==========================================================
7676
// EXPLAIN : The adjacent information for the input

source/module_cell/setup_nonlocal.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ void InfoNonlocal::Set_NonLocal(const int& it,
3434
ModuleBase::TITLE("InfoNonlocal", "Set_NonLocal");
3535

3636
// set a pointer
37-
// Atom* atom = &GlobalC::ucell.atoms[it];
37+
// Atom* atom = &ucell.atoms[it];
3838

3939
// get the number of non-local projectors
4040
n_projectors = atom->ncpp.nbeta;

source/module_elecstate/elecstate.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,7 @@ void ElecState::calEBand()
207207

208208

209209
void ElecState::init_scf(const int istep,
210+
const UnitCell& ucell,
210211
const ModuleBase::ComplexMatrix& strucfac,
211212
const bool* numeric,
212213
ModuleSymmetry::Symmetry& symm,
@@ -215,7 +216,7 @@ void ElecState::init_scf(const int istep,
215216
//! core correction potential.
216217
if (!PARAM.inp.use_paw)
217218
{
218-
this->charge->set_rho_core(strucfac, numeric);
219+
this->charge->set_rho_core(ucell,strucfac, numeric);
219220
}
220221
else
221222
{
@@ -226,7 +227,7 @@ void ElecState::init_scf(const int istep,
226227
// choose charge density from ionic step 0.
227228
if (istep == 0)
228229
{
229-
this->charge->init_rho(this->eferm, strucfac, symm, (const void*)this->klist, wfcpw);
230+
this->charge->init_rho(this->eferm,ucell, strucfac, symm, (const void*)this->klist, wfcpw);
230231
this->charge->check_rho(); // check the rho
231232
}
232233

source/module_elecstate/elecstate.h

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,11 +104,13 @@ class ElecState
104104
* @brief Init rho_core, init rho, renormalize rho, init pot
105105
*
106106
* @param istep i-th step
107+
* @param ucell unit cell
107108
* @param strucfac structure factor
108109
* @param symm symmetry
109110
* @param wfcpw PW basis for wave function if needed
110111
*/
111112
void init_scf(const int istep,
113+
const UnitCell& ucell,
112114
const ModuleBase::ComplexMatrix& strucfac,
113115
const bool* numeric,
114116
ModuleSymmetry::Symmetry& symm,
@@ -126,7 +128,7 @@ class ElecState
126128
void cal_bandgap();
127129
void cal_bandgap_updw();
128130

129-
double cal_delta_eband() const;
131+
double cal_delta_eband(const UnitCell& ucell) const;
130132
double cal_delta_escf() const;
131133

132134
ModuleBase::matrix vnew;
@@ -171,7 +173,8 @@ class ElecState
171173
ModuleBase::matrix wg; ///< occupation weight for each k-point and band
172174

173175
public: // print something. See elecstate_print.cpp
174-
void print_etot(const bool converged,
176+
void print_etot(const Magnetism& magnet,
177+
const bool converged,
175178
const int& iter,
176179
const double& scf_thr,
177180
const double& scf_thr_kin,

source/module_elecstate/elecstate_energy.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ void ElecState::cal_bandgap_updw()
9090
}
9191

9292
/// @brief calculate deband
93-
double ElecState::cal_delta_eband() const
93+
double ElecState::cal_delta_eband(const UnitCell& ucell) const
9494
{
9595
// out potentials from potential mixing
9696
// total energy and band energy corrections
@@ -109,7 +109,7 @@ double ElecState::cal_delta_eband() const
109109
{
110110
ModuleBase::matrix v_xc;
111111
const std::tuple<double, double, ModuleBase::matrix> etxc_vtxc_v
112-
= XC_Functional::v_xc(this->charge->nrxx, this->charge, &GlobalC::ucell);
112+
= XC_Functional::v_xc(this->charge->nrxx, this->charge, &ucell);
113113
v_xc = std::get<2>(etxc_vtxc_v);
114114

115115
for (int ir = 0; ir < this->charge->rhopw->nrxx; ir++)

0 commit comments

Comments
 (0)