Skip to content

Commit f977c2d

Browse files
authored
Merge branch 'develop' into rdmft_PR
2 parents 5a9febe + 0f44046 commit f977c2d

File tree

92 files changed

+2474
-1964
lines changed

Some content is hidden

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

92 files changed

+2474
-1964
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
# About ABACUS
1414

15-
ABACUS (Atomic-orbital Based Ab-initio Computation at UStc) is an open-source package based on density functional theory (DFT). The package utilizes both plane wave and numerical atomic basis sets with the usage of norm-conserving pseudopotentials to describe the interactions between nuclear ions and valence electrons. ABACUS supports LDA, GGA, meta-GGA, and hybrid functionals. Apart from single-point calculations, the package allows geometry optimizations and ab-initio molecular dynamics with various ensembles. The package also provides a variety of advanced functionalities for simulating materials, including the DFT+U, VdW corrections, and implicit solvation model, etc. In addition, ABACUS strives to provide a general infrastructure to facilitate the developments and applications of novel machine-learning-assisted DFT methods (DeePKS, DP-GEN, DeepH, etc.) in molecular and material simulations.
15+
ABACUS (Atomic-orbital Based Ab-initio Computation at UStc) is an open-source package based on density functional theory (DFT). The package utilizes both plane wave and numerical atomic basis sets with the usage of norm-conserving pseudopotentials to describe the interactions between nuclear ions and valence electrons. ABACUS supports LDA, GGA, meta-GGA, and hybrid functionals. Apart from single-point calculations, the package allows geometry optimizations and ab-initio molecular dynamics with various ensembles. The package also provides a variety of advanced functionalities for simulating materials, including the DFT+U, VdW corrections, and implicit solvation model, etc. In addition, ABACUS strives to provide a general infrastructure to facilitate the developments and applications of novel machine-learning-assisted DFT methods (DeePKS, DP-GEN, DeepH, DeePTB etc.) in molecular and material simulations.
1616

1717
# Online Documentation
1818
For detailed documentation, please refer to [our documentation website](https://abacus.deepmodeling.com/).

docs/CITATIONS.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ The following references are required to be cited when using ABACUS. Specificall
2626

2727
- **If DeePKS is used:**
2828

29-
Wenfei Li, Qi Ou, et al. "DeePKS+ABACUS as a Bridge between Expensive Quantum Mechanical Models and Machine Learning Potentials." <https://arxiv.org/abs/2206.10093>.
29+
Wenfei Li, Qi Ou, et al. "DeePKS+ABACUS as a Bridge between Expensive Quantum Mechanical Models and Machine Learning Potentials." J. Phys. Chem. A 126.49 (2022): 9154-9164.
3030

3131
- **If hybrid functional is used:**
3232

docs/advanced/interface/deepks.md

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,14 @@
11
# DeePKS
22

3-
[DeePKS](https://pubs.acs.org/doi/10.1021/acs.jctc.0c00872) is a machine-learning aided density funcitonal model that fits the energy difference between highly accurate but computationally demanding method and effcient but less accurate method via neural-network. As such, the trained DeePKS model can provide highly accurate energetics (and forces) with relatively low computational cost, and can therefore act as a bridge to connect expensive quantum mechanic data and machine-learning-based potentials. While the original framework of DeePKS is for molecular systems, please refer to this [reference](https://arxiv.org/abs/2206.10093) for the application of DeePKS in periodic systems.
3+
[DeePKS](https://pubs.acs.org/doi/10.1021/acs.jctc.0c00872) is a machine-learning (ML) aided density funcitonal model that fits the energy difference between highly accurate but computationally demanding method and effcient but less accurate method via neural-network. Common high-precision methods include hybrid functionals or CCSD-T, while common low-precision methods are LDA/GGA.
44

5-
Detailed instructions on installing and running DeePKS can be found on this [website](https://deepks-kit.readthedocs.io/en/latest/index.html). An [example](https://github.com/deepmodeling/deepks-kit/tree/abacus/examples/water_single_lda2pbe_abacus) for training DeePKS model with ABACUS is also provided. The DeePKS-related keywords in `INPUT` file can be found [here](http://abacus.deepmodeling.com/en/latest/advanced/input_files/input-main.html#deepks).
5+
As such, the trained DeePKS model can provide highly accurate energetics (and forces/band gap/density) with relatively low computational cost, and can therefore act as a bridge to connect expensive quantum mechanic data and machine-learning-based potentials.
6+
While the original framework of DeePKS is for molecular systems, please refer to this [J. Phys. Chem. A 126.49 (2022): 9154-9164](https://pubs.acs.org/doi/abs/10.1021/acs.jpca.2c05000) for the application of DeePKS in periodic systems.
67

7-
> Note: Use the LCAO basis for DeePKS-related calculations
8+
Detailed instructions on installing and running DeePKS can be found on this [website](https://deepks-kit.readthedocs.io/en/latest/index.html). The DeePKS-related keywords in `INPUT` file can be found [here](http://abacus.deepmodeling.com/en/latest/advanced/input_files/input-main.html#deepks). An [example](https://github.com/deepmodeling/deepks-kit/tree/abacus/examples/water_single_lda2pbe_abacus) for training DeePKS model with ABACUS is also provided. For practical applications, users can refer to a series of [Notebooks](https://bohrium.dp.tech/collections/1921409690). These Notebooks provide detailed instructions on how to train and use the DeePKS model using perovskite as an example. Currently, these tutorials are available in Chinese, but we plan to release corresponding English versions in the near future.
9+
10+
11+
12+
> Note: DeePKS calculations can only be performed by the LCAO basis.
813
914

docs/advanced/interface/deeptb.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# DeePTB
2+
3+
[DeePTB](https://github.com/deepmodeling/DeePTB) is an innovative Python package that uses deep learning to accelerate ab initio electronic structure simulations. It offers versatile, accurate, and efficient simulations for a wide range of materials and phenomena. Trained on small systems, DeePTB can predict electronic structures of large systems, handle structural perturbations, and integrate with molecular dynamics for finite temperature simulations, providing comprehensive insights into atomic and electronic behavior. See more details in [DeePTB-SK: Nat Commun 15, 6772 (2024)](https://www.nature.com/articles/s41467-024-51006-4) and [DeePTB-E3: arXiv:2407.06053](https://arxiv.org/pdf/2407.06053).
4+
5+
DeePTB trains the model based on the Structure, Eigenvalues, Hamiltonian, Density matrix, and Overlap matrix from first-principles calcualtions. DeePTB team provides the interfaces [dftio](https://github.com/deepmodeling/dftio) with other first-principles softwares. [dftio](https://github.com/deepmodeling/dftio) fully supports the interfaces with ABACUS, and can transfer the Structure, Eigenvalues, Hamiltonian, Density matrix, and Overlap matrix from ABACUS into the format used in [DeePTB](https://github.com/deepmodeling/DeePTB).

docs/advanced/interface/index.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ Interfaces to Other Softwares
99
deepks
1010
dpgen
1111
deeph
12+
deeptb
1213
Hefei-NAMD
1314
phonopy
1415
Wannier90

docs/conf.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@
3333
extensions = [
3434
'myst_parser',
3535
'deepmodeling_sphinx',
36-
'sphinxcontrib.jquery',
3736
]
3837
myst_enable_extensions = [
3938
"amsmath",
@@ -66,7 +65,7 @@
6665
# The theme to use for HTML and HTML Help pages. See the documentation for
6766
# a list of builtin themes.
6867
#
69-
html_theme = 'sphinx_rtd_theme'
68+
html_theme = 'sphinx_book_theme'
7069
html_logo = 'abacus-logo.svg'
7170

7271

docs/requirements.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
urllib3
22
myst_parser[linkify]
3-
sphinx_rtd_theme
4-
deepmodeling_sphinx
3+
sphinx-book-theme
4+
deepmodeling-sphinx>=0.3.0
Lines changed: 36 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,47 @@
11
#include "./elecstate_pw_sdft.h"
2+
3+
#include "module_base/global_function.h"
24
#include "module_base/global_variable.h"
3-
#include "module_parameter/parameter.h"
45
#include "module_base/timer.h"
5-
#include "module_base/global_function.h"
66
#include "module_hamilt_general/module_xc/xc_functional.h"
7+
#include "module_parameter/parameter.h"
78
namespace elecstate
89
{
9-
void ElecStatePW_SDFT::psiToRho(const psi::Psi<std::complex<double>>& psi)
10+
11+
template <typename T, typename Device>
12+
void ElecStatePW_SDFT<T, Device>::psiToRho(const psi::Psi<T>& psi)
13+
{
14+
ModuleBase::TITLE(this->classname, "psiToRho");
15+
ModuleBase::timer::tick(this->classname, "psiToRho");
16+
for (int is = 0; is < PARAM.inp.nspin; is++)
1017
{
11-
ModuleBase::TITLE(this->classname, "psiToRho");
12-
ModuleBase::timer::tick(this->classname, "psiToRho");
13-
for(int is=0; is < PARAM.inp.nspin; is++)
14-
{
15-
ModuleBase::GlobalFunc::ZEROS(this->charge->rho[is], this->charge->nrxx);
16-
if (XC_Functional::get_func_type() == 3)
17-
{
18-
ModuleBase::GlobalFunc::ZEROS(this->charge->kin_r[is], this->charge->nrxx);
19-
}
20-
}
21-
22-
if(GlobalV::MY_STOGROUP == 0)
23-
{
24-
this->calEBand();
18+
ModuleBase::GlobalFunc::ZEROS(this->charge->rho[is], this->charge->nrxx);
19+
if (XC_Functional::get_func_type() == 3)
20+
{
21+
ModuleBase::GlobalFunc::ZEROS(this->charge->kin_r[is], this->charge->nrxx);
22+
}
23+
}
24+
25+
if (GlobalV::MY_STOGROUP == 0)
26+
{
27+
this->calEBand();
2528

26-
for(int is=0; is<PARAM.inp.nspin; is++)
27-
{
28-
ModuleBase::GlobalFunc::ZEROS(this->charge->rho[is], this->charge->nrxx);
29-
}
29+
for (int is = 0; is < PARAM.inp.nspin; is++)
30+
{
31+
ModuleBase::GlobalFunc::ZEROS(this->charge->rho[is], this->charge->nrxx);
32+
}
3033

31-
for (int ik = 0; ik < psi.get_nk(); ++ik)
32-
{
33-
psi.fix_k(ik);
34-
this->updateRhoK(psi);
35-
}
36-
this->parallelK();
34+
for (int ik = 0; ik < psi.get_nk(); ++ik)
35+
{
36+
psi.fix_k(ik);
37+
this->updateRhoK(psi);
3738
}
38-
ModuleBase::timer::tick(this->classname, "psiToRho");
39-
return;
39+
this->parallelK();
4040
}
41-
}
41+
ModuleBase::timer::tick(this->classname, "psiToRho");
42+
return;
43+
}
44+
45+
// template class ElecStatePW_SDFT<std::complex<float>, base_device::DEVICE_CPU>;
46+
template class ElecStatePW_SDFT<std::complex<double>, base_device::DEVICE_CPU>;
47+
} // namespace elecstate

source/module_elecstate/elecstate_pw_sdft.h

Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -3,22 +3,24 @@
33
#include "elecstate_pw.h"
44
namespace elecstate
55
{
6-
class ElecStatePW_SDFT : public ElecStatePW<std::complex<double>>
6+
template <typename T, typename Device>
7+
class ElecStatePW_SDFT : public ElecStatePW<T, Device>
8+
{
9+
public:
10+
ElecStatePW_SDFT(ModulePW::PW_Basis_K* wfc_basis_in,
11+
Charge* chg_in,
12+
K_Vectors* pkv_in,
13+
UnitCell* ucell_in,
14+
pseudopot_cell_vnl* ppcell_in,
15+
ModulePW::PW_Basis* rhodpw_in,
16+
ModulePW::PW_Basis* rhopw_in,
17+
ModulePW::PW_Basis_Big* bigpw_in)
18+
: ElecStatePW<T,
19+
Device>(wfc_basis_in, chg_in, pkv_in, ucell_in, ppcell_in, rhodpw_in, rhopw_in, bigpw_in)
720
{
8-
public:
9-
ElecStatePW_SDFT(ModulePW::PW_Basis_K* wfc_basis_in,
10-
Charge* chg_in,
11-
K_Vectors* pkv_in,
12-
UnitCell* ucell_in,
13-
pseudopot_cell_vnl* ppcell_in,
14-
ModulePW::PW_Basis* rhodpw_in,
15-
ModulePW::PW_Basis* rhopw_in,
16-
ModulePW::PW_Basis_Big* bigpw_in)
17-
: ElecStatePW(wfc_basis_in, chg_in, pkv_in, ucell_in, ppcell_in, rhodpw_in, rhopw_in, bigpw_in)
18-
{
19-
this->classname = "ElecStatePW_SDFT";
20-
}
21-
virtual void psiToRho(const psi::Psi<std::complex<double>>& psi) override;
22-
};
23-
}
21+
this->classname = "ElecStatePW_SDFT";
22+
}
23+
virtual void psiToRho(const psi::Psi<T>& psi) override;
24+
};
25+
} // namespace elecstate
2426
#endif

source/module_elecstate/module_charge/charge_init.cpp

Lines changed: 22 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -53,61 +53,37 @@ void Charge::init_rho(elecstate::efermi& eferm_iout,
5353
{
5454
std::stringstream ssc;
5555
ssc << PARAM.globalv.global_readin_dir << "SPIN" << is + 1 << "_CHG.cube";
56-
double& ef_tmp = eferm_iout.get_ef(is);
57-
if (ModuleIO::read_cube(
58-
#ifdef __MPI
59-
& (GlobalC::Pgrid),
60-
#endif
56+
if (ModuleIO::read_vdata_palgrid(GlobalC::Pgrid,
6157
(PARAM.inp.esolver_type == "sdft" ? GlobalV::RANK_IN_STOGROUP : GlobalV::MY_RANK),
62-
is,
6358
GlobalV::ofs_running,
64-
PARAM.inp.nspin,
6559
ssc.str(),
6660
this->rho[is],
67-
this->rhopw->nx,
68-
this->rhopw->ny,
69-
this->rhopw->nz,
70-
ef_tmp,
71-
& (GlobalC::ucell),
72-
this->prenspin))
61+
GlobalC::ucell.nat))
7362
{
7463
GlobalV::ofs_running << " Read in the charge density: " << ssc.str() << std::endl;
7564
}
76-
else if (is > 0)
65+
else if (is > 0) // nspin=2 or 4
7766
{
78-
if (prenspin == 1)
67+
if (is == 1) // failed at the second spin
7968
{
80-
GlobalV::ofs_running << " Didn't read in the charge density but autoset it for spin " << is + 1
81-
<< std::endl;
82-
for (int ir = 0; ir < this->rhopw->nrxx; ir++)
83-
{
84-
this->rho[is][ir] = 0.0;
85-
}
69+
std::cout << "Incomplete charge density file!" << std::endl;
70+
read_error = true;
71+
break;
8672
}
87-
//
88-
else if (prenspin == 2)
89-
{ // read up and down , then rearrange them.
90-
if (is == 1)
91-
{
92-
std::cout << "Incomplete charge density file!" << std::endl;
93-
read_error = true;
94-
break;
95-
}
96-
else if (is == 2)
97-
{
98-
GlobalV::ofs_running << " Didn't read in the charge density but would rearrange it later. "
99-
<< std::endl;
100-
}
101-
else if (is == 3)
73+
else if (is == 2) // read 2 files when nspin=4
74+
{
75+
GlobalV::ofs_running << " Didn't read in the charge density but would rearrange it later. "
76+
<< std::endl;
77+
}
78+
else if (is == 3) // read 2 files when nspin=4
79+
{
80+
GlobalV::ofs_running << " rearrange charge density " << std::endl;
81+
for (int ir = 0; ir < this->rhopw->nrxx; ir++)
10282
{
103-
GlobalV::ofs_running << " rearrange charge density " << std::endl;
104-
for (int ir = 0; ir < this->rhopw->nrxx; ir++)
105-
{
106-
this->rho[3][ir] = this->rho[0][ir] - this->rho[1][ir];
107-
this->rho[0][ir] = this->rho[0][ir] + this->rho[1][ir];
108-
this->rho[1][ir] = 0.0;
109-
this->rho[2][ir] = 0.0;
110-
}
83+
this->rho[3][ir] = this->rho[0][ir] - this->rho[1][ir];
84+
this->rho[0][ir] = this->rho[0][ir] + this->rho[1][ir];
85+
this->rho[1][ir] = 0.0;
86+
this->rho[2][ir] = 0.0;
11187
}
11288
}
11389
}
@@ -127,22 +103,12 @@ void Charge::init_rho(elecstate::efermi& eferm_iout,
127103
GlobalV::ofs_running << " try to read kinetic energy density from file : " << ssc.str()
128104
<< std::endl;
129105
// mohan update 2012-02-10, sunliang update 2023-03-09
130-
if (ModuleIO::read_cube(
131-
#ifdef __MPI
132-
& (GlobalC::Pgrid),
133-
#endif
106+
if (ModuleIO::read_vdata_palgrid(GlobalC::Pgrid,
134107
(PARAM.inp.esolver_type == "sdft" ? GlobalV::RANK_IN_STOGROUP : GlobalV::MY_RANK),
135-
is,
136108
GlobalV::ofs_running,
137-
PARAM.inp.nspin,
138109
ssc.str(),
139110
this->kin_r[is],
140-
this->rhopw->nx,
141-
this->rhopw->ny,
142-
this->rhopw->nz,
143-
eferm_iout.ef,
144-
& (GlobalC::ucell),
145-
this->prenspin))
111+
GlobalC::ucell.nat))
146112
{
147113
GlobalV::ofs_running << " Read in the kinetic energy density: " << ssc.str() << std::endl;
148114
}

0 commit comments

Comments
 (0)