Skip to content

Commit 7dbf6f4

Browse files
committed
Merge branch 'develop' of https://github.com/sunliang98/abacus-develop into zero_atom
2 parents be0f278 + 7b33110 commit 7dbf6f4

File tree

19 files changed

+108
-73
lines changed

19 files changed

+108
-73
lines changed

docs/quick_start/easy_install.md

Lines changed: 26 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,17 @@
11
# Easy Installation
22

3-
This guide helps you install ABACUS with basic features. **For DeePKS, DeePMD and Libxc support, or building with `make`, please refer to [the advanced installation guide](../advanced/install.md)** after going through this page. We recommend building ABACUS with `cmake` to avoid dependency issues. We recommend compiling ABACUS(and possibly its requirements) from the source code using the latest compiler for the best performace. You can also deploy ABACUS **without building** by [Docker](#container-deployment) or [conda](#install-by-conda). Please note that ABACUS only supports Linux; for Windows users, please consider using [WSL](https://learn.microsoft.com/en-us/windows/wsl/) or docker.
3+
This guide helps you install ABACUS with basic features. **For DeePKS, DeePMD and Libxc support, or building with `make`, please refer to [the advanced installation guide](../advanced/install.md)** after going through this page. We recommend building ABACUS with `cmake` to avoid dependency issues. We recommend compiling ABACUS(and possibly its requirements) from the source code using the latest compiler for the best performace. You can try [toolchain](#install-requirements-by-toolchain) to install ABACUS and dependencies in a source-code compilation way with convience. You can also deploy ABACUS **without building** by [Docker](#container-deployment) or [conda](#install-by-conda). Please note that ABACUS only supports Linux; for Windows users, please consider using [WSL](https://learn.microsoft.com/en-us/windows/wsl/) or docker.
4+
5+
## Get ABACUS source code
6+
7+
ABACUS source code can be obtained via one of the following choices:
8+
9+
- Clone the whole repo with git: `git clone https://github.com/deepmodeling/abacus-develop.git`
10+
- Clone the minimum required part of repo: `git clone https://github.com/deepmodeling/abacus-develop.git --depth=1`
11+
- Download the latest source code without git: `wget https://github.com/deepmodeling/abacus-develop/archive/refs/heads/develop.zip`
12+
- Get the source code of a stable version [here](https://github.com/deepmodeling/abacus-develop/releases)
13+
- If you have connection issues accessing GitHub, please try out our official [Gitee repo](https://gitee.com/deepmodeling/abacus-develop/): e.g. `git clone https://gitee.com/deepmodeling/abacus-develop.git`. This Gitee repo is updated synchronously with GitHub.
14+
415

516
## Prerequisites
617

@@ -43,32 +54,22 @@ Please refer to our [guide](https://github.com/deepmodeling/abacus-develop/wiki/
4354

4455
We offer a set of [toolchain](https://github.com/deepmodeling/abacus-develop/tree/develop/toolchain)
4556
scripts to compile and install all the requirements
46-
automatically and suitable for machine characteristic in an online or offline way.
47-
The toolchain can be downloaded with ABACUS repo, which is easily used and can
48-
have a convenient installation under HPC environment in both `GNU` or `Intel-oneAPI` toolchain.
49-
Sometimes, ABACUS by toolchain installation may have highly efficient performance.
50-
A Tutorial for using this toolchain can be accessed in [bohrium-notebook](https://nb.bohrium.dp.tech/detail/5215742477)
51-
52-
> Notice: the toolchain is under development, please let me know if you encounter any problem in using this toolchain.
57+
automatically and suitable for machine characteristic in an online or offline way.
58+
The toolchain can be downloaded with ABACUS repo, and users can easily compile the requirements by running *toolchain_[gnu,intel].sh* and ABACUS itself by running *build_abacus_[gnu,intel].sh* script in the toolchain directory in both `GNU` and `Intel-oneAPI` toolchain.
59+
Sometimes, ABACUS by toolchain installation may have better efficient performance due to the suitable compiled dependencies.
5360

61+
Users should read the README in toolchain directory for most of the information before use, and a tutorial for using this toolchain can be accessed in [bohrium-notebook](https://nb.bohrium.dp.tech/detail/5215742477) as reference.
5462

55-
## Get ABACUS source code
56-
57-
Of course a copy of ABACUS source code is required, which can be obtained via one of the following choices:
63+
> Notice: the toolchain is under development, please let we know if you encounter any problem in using this toolchain by raising issue or contacting us.
5864
59-
- Clone the whole repo with git: `git clone https://github.com/deepmodeling/abacus-develop.git`
60-
- Clone the minimum required part of repo: `git clone https://github.com/deepmodeling/abacus-develop.git --depth=1`
61-
- Download the latest source code without git: `wget https://github.com/deepmodeling/abacus-develop/archive/refs/heads/develop.zip`
62-
- Get the source code of a stable version [here](https://github.com/deepmodeling/abacus-develop/releases)
63-
- If you have connection issues accessing GitHub, please try out our official [Gitee repo](https://gitee.com/deepmodeling/abacus-develop/): e.g. `git clone https://gitee.com/deepmodeling/abacus-develop.git`
6465

65-
### Update to latest release
66+
## Update to latest release by git
6667

6768
Please check the [release page](https://github.com/deepmodeling/abacus-develop/releases) for the release note of a new version.
6869

6970
It is OK to download the new source code from beginning following the previous step.
7071

71-
To update your cloned git repo in-place:
72+
You can update your cloned git repo (from Github or Gitee) in-place with the following commands:
7273

7374
```bash
7475
git remote -v
@@ -78,7 +79,7 @@ git remote -v
7879

7980
# Replace "origin" with "upstream" or the remote name corresponding to deepmodeling/abacus-develop if necessary
8081
git fetch origin
81-
git checkout v3.2.0 # Replace the tag with the latest version
82+
git checkout v3.8.4 # Replace the tag with the latest version
8283
git describe --tags # Verify if the tag has been successfully checked out
8384
```
8485

@@ -158,6 +159,12 @@ If ABACUS is installed into a custom directory using `CMAKE_INSTALL_PREFIX`, ple
158159
export PATH=/my-install-dir/:$PATH
159160
```
160161

162+
If ABACUS is installed by toolchain, there will be an environment script in the toolchain directory named as *abacus_env.sh*. You can source it to set the environment variables.
163+
164+
```bash
165+
source /path/to/abacus/toolchain/abacus_env.sh
166+
```
167+
161168
Please set OpenMP threads by setting environment variable:
162169

163170
```bash

python/pyabacus/src/hsolver/py_diago_cg.hpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -114,13 +114,13 @@ class PyDiagoCG
114114
);
115115
}
116116

117-
void diag(
118-
std::function<py::array_t<std::complex<double>>(py::array_t<std::complex<double>>)> mm_op,
119-
int diag_ndim,
120-
double tol,
121-
bool need_subspace,
122-
bool scf_type,
123-
int nproc_in_pool = 1
117+
void diag(std::function<py::array_t<std::complex<double>>(py::array_t<std::complex<double>>)> mm_op,
118+
int diag_ndim,
119+
double tol,
120+
const std::vector<double>& diag_ethr,
121+
bool need_subspace,
122+
bool scf_type,
123+
int nproc_in_pool = 1
124124
) {
125125
const std::string basis_type = "pw";
126126
const std::string calculation = scf_type ? "scf" : "nscf";
@@ -171,7 +171,7 @@ class PyDiagoCG
171171
nproc_in_pool
172172
);
173173

174-
cg->diag(hpsi_func, spsi_func, *psi, *eig, *prec);
174+
cg->diag(hpsi_func, spsi_func, *psi, *eig, diag_ethr, *prec);
175175
}
176176

177177
private:

python/pyabacus/src/hsolver/py_hsolver.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,9 @@ void bind_hsolver(py::module& m)
158158
for invoking this class is a function defined in _hsolver.py,
159159
which uses this class to perform the calculations.
160160
)pbdoc")
161-
.def("diag", &py_hsolver::PyDiagoCG::diag, R"pbdoc(
161+
.def("diag",
162+
&py_hsolver::PyDiagoCG::diag,
163+
R"pbdoc(
162164
Diagonalize the linear operator using the Conjugate Gradient Method.
163165
164166
Parameters
@@ -179,6 +181,7 @@ void bind_hsolver(py::module& m)
179181
"mm_op"_a,
180182
"max_iter"_a,
181183
"tol"_a,
184+
"diag_ethr"_a,
182185
"need_subspace"_a,
183186
"scf_type"_a,
184187
"nproc_in_pool"_a)

python/pyabacus/src/pyabacus/hsolver/_hsolver.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,7 @@ def cg(
195195
precondition: NDArray[np.float64],
196196
tol: float = 1e-2,
197197
max_iter: int = 1000,
198+
diag_ethr: Union[List[float], None] = None,
198199
need_subspace: bool = False,
199200
scf_type: bool = False,
200201
nproc_in_pool: int = 1
@@ -244,6 +245,9 @@ def cg(
244245
if init_v.ndim == 2:
245246
init_v = init_v.T
246247
init_v = init_v.flatten().astype(np.complex128, order='C')
248+
249+
if diag_ethr is None:
250+
diag_ethr = [tol] * num_eigs
247251

248252
_diago_obj_cg = diago_cg(dim, num_eigs)
249253
_diago_obj_cg.set_psi(init_v)
@@ -255,6 +259,7 @@ def cg(
255259
mvv_op,
256260
max_iter,
257261
tol,
262+
diag_ethr,
258263
need_subspace,
259264
scf_type,
260265
nproc_in_pool

source/module_esolver/esolver_ks_lcao.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1224,7 +1224,7 @@ void ESolver_KS_LCAO<TK, TR>::after_scf(UnitCell& ucell, const int istep)
12241224
PARAM.inp.out_wannier_wvfn_formatted,
12251225
PARAM.inp.nnkpfile,
12261226
PARAM.inp.wannier_spin);
1227-
1227+
myWannier.set_tpiba_omega(ucell.tpiba, ucell.omega);
12281228
myWannier.calculate(ucell,
12291229
this->pelec->ekb,
12301230
this->pw_wfc,

source/module_hsolver/diago_cg.cpp

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,10 @@ DiagoCG<T, Device>::~DiagoCG()
5454
}
5555

5656
template <typename T, typename Device>
57-
void DiagoCG<T, Device>::diag_mock(const ct::Tensor& prec_in, ct::Tensor& psi, ct::Tensor& eigen)
57+
void DiagoCG<T, Device>::diag_mock(const ct::Tensor& prec_in,
58+
ct::Tensor& psi,
59+
ct::Tensor& eigen,
60+
const std::vector<double>& ethr_band)
5861
{
5962
ModuleBase::TITLE("DiagoCG", "diag_once");
6063
ModuleBase::timer::tick("DiagoCG", "diag_once");
@@ -153,6 +156,7 @@ void DiagoCG<T, Device>::diag_mock(const ct::Tensor& prec_in, ct::Tensor& psi, c
153156
converged = this->update_psi(pphi,
154157
cg,
155158
scg, // const Tensor&
159+
ethr_band[m],
156160
cg_norm,
157161
theta,
158162
eigen_pack[m], // Real&
@@ -392,6 +396,7 @@ template <typename T, typename Device>
392396
bool DiagoCG<T, Device>::update_psi(const ct::Tensor& pphi,
393397
const ct::Tensor& cg,
394398
const ct::Tensor& scg,
399+
const double& ethreshold,
395400
Real& cg_norm,
396401
Real& theta,
397402
Real& eigen,
@@ -441,7 +446,7 @@ bool DiagoCG<T, Device>::update_psi(const ct::Tensor& pphi,
441446
cg.data<T>(),
442447
sint_norm);
443448

444-
if (std::abs(eigen - e0) < pw_diag_thr_)
449+
if (std::abs(eigen - e0) < ethreshold)
445450
{
446451
// ModuleBase::timer::tick("DiagoCG","update");
447452
return true;
@@ -582,6 +587,7 @@ void DiagoCG<T, Device>::diag(const Func& hpsi_func,
582587
const Func& spsi_func,
583588
ct::Tensor& psi,
584589
ct::Tensor& eigen,
590+
const std::vector<double>& ethr_band,
585591
const ct::Tensor& prec)
586592
{
587593
/// record the times of trying iterative diagonalization
@@ -603,7 +609,7 @@ void DiagoCG<T, Device>::diag(const Func& hpsi_func,
603609

604610
++ntry;
605611
avg_iter_ += 1.0;
606-
this->diag_mock(prec, psi_temp, eigen);
612+
this->diag_mock(prec, psi_temp, eigen, ethr_band);
607613
} while (this->test_exit_cond(ntry, this->notconv_));
608614

609615
if (this->notconv_ > std::max(5, this->n_band_ / 4))

source/module_hsolver/diago_cg.h

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,12 @@ class DiagoCG final
4040
// virtual void init(){};
4141
// refactor hpsi_info
4242
// this is the diag() function for CG method
43-
void diag(const Func& hpsi_func, const Func& spsi_func, ct::Tensor& psi, ct::Tensor& eigen, const ct::Tensor& prec = {});
43+
void diag(const Func& hpsi_func,
44+
const Func& spsi_func,
45+
ct::Tensor& psi,
46+
ct::Tensor& eigen,
47+
const std::vector<double>& ethr_band,
48+
const ct::Tensor& prec = {});
4449

4550
private:
4651
Device * ctx_ = {};
@@ -103,6 +108,7 @@ class DiagoCG final
103108
const ct::Tensor& pphi,
104109
const ct::Tensor& cg,
105110
const ct::Tensor& scg,
111+
const double& ethreshold,
106112
Real &cg_norm,
107113
Real &theta,
108114
Real &eigen,
@@ -113,7 +119,10 @@ class DiagoCG final
113119
void schmit_orth(const int& m, const ct::Tensor& psi, const ct::Tensor& sphi, ct::Tensor& phi_m);
114120

115121
// used in diag() for template replace Hamilt with Hamilt_PW
116-
void diag_mock(const ct::Tensor& prec, ct::Tensor& psi, ct::Tensor& eigen);
122+
void diag_mock(const ct::Tensor& prec,
123+
ct::Tensor& psi,
124+
ct::Tensor& eigen,
125+
const std::vector<double>& ethr_band);
117126

118127
bool test_exit_cond(const int& ntry, const int& notconv) const;
119128

source/module_hsolver/hsolver_pw.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -279,7 +279,7 @@ void HSolverPW<T, Device>::solve(hamilt::Hamilt<T, Device>* pHamilt,
279279
// prepare for the precondition of diagonalization
280280
std::vector<Real> precondition(psi.get_nbasis(), 0.0);
281281
std::vector<Real> eigenvalues(this->wfc_basis->nks * psi.get_nbands(), 0.0);
282-
ethr_band.resize(psi.get_nbands(), DiagoIterAssist<T, Device>::PW_DIAG_THR);
282+
ethr_band.resize(psi.get_nbands(), this->diag_thr);
283283

284284
/// Loop over k points for solve Hamiltonian to charge density
285285
for (int ik = 0; ik < this->wfc_basis->nks; ++ik)
@@ -467,7 +467,7 @@ void HSolverPW<T, Device>::hamiltSolvePsiK(hamilt::Hamilt<T, Device>* hm,
467467
.to_device<ct_Device>()
468468
.slice({0}, {psi.get_current_nbas()});
469469

470-
cg.diag(hpsi_func, spsi_func, psi_tensor, eigen_tensor, prec_tensor);
470+
cg.diag(hpsi_func, spsi_func, psi_tensor, eigen_tensor, this->ethr_band, prec_tensor);
471471
// TODO: Double check tensormap's potential problem
472472
ct::TensorMap(psi.get_pointer(), psi_tensor, {psi.get_nbands(), psi.get_nbasis()}).sync(psi_tensor);
473473
}

source/module_hsolver/hsolver_pw.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,12 +84,12 @@ class HSolverPW
8484
int rank_in_pool = 0;
8585
int nproc_in_pool = 1;
8686

87+
std::vector<double> ethr_band;
88+
8789
private:
8890
/// @brief calculate the threshold for iterative-diagonalization for each band
8991
void cal_ethr_band(const double& wk, const double* wg, const double& ethr, std::vector<double>& ethrs);
9092

91-
std::vector<double> ethr_band;
92-
9393
#ifdef USE_PAW
9494
void paw_func_in_kloop(const int ik,
9595
const double tpiba);

source/module_hsolver/hsolver_pw_sdft.cpp

Lines changed: 2 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -29,33 +29,11 @@ void HSolverPW_SDFT<T, Device>::solve(const UnitCell& ucell,
2929
const int nbands = psi.get_nbands();
3030
const int nks = psi.get_nk();
3131

32-
//---------------------------------------------------------------------------------------------------------------
33-
//---------------------------------for psi init guess!!!!--------------------------------------------------------
34-
//---------------------------------------------------------------------------------------------------------------
35-
// if (!PARAM.inp.psi_initializer && !this->initialed_psi && this->basis_type == "pw")
36-
// {
37-
// for (int ik = 0; ik < nks; ++ik)
38-
// {
39-
// /// update H(k) for each k point
40-
// pHamilt->updateHk(ik);
41-
42-
// if (nbands > 0 && GlobalV::MY_STOGROUP == 0)
43-
// {
44-
// /// update psi pointer for each k point
45-
// psi.fix_k(ik);
46-
47-
// /// for psi init guess!!!!
48-
// hamilt::diago_PAO_in_pw_k2(this->ctx, ik, psi, this->wfc_basis, this->pwf, pHamilt);
49-
// }
50-
// }
51-
// }
52-
//---------------------------------------------------------------------------------------------------------------
53-
//---------------------------------------------------------------------------------------------------------------
54-
//---------------------------------------------------------------------------------------------------------------
55-
5632
// prepare for the precondition of diagonalization
5733
std::vector<double> precondition(psi.get_nbasis(), 0.0);
5834

35+
this->ethr_band.resize(psi.get_nbands(), this->diag_thr);
36+
5937
// report if the specified diagonalization method is not supported
6038
const std::initializer_list<std::string> _methods = {"cg", "dav", "dav_subspace", "bpcg"};
6139
if (std::find(std::begin(_methods), std::end(_methods), this->method) == std::end(_methods))

0 commit comments

Comments
 (0)