Skip to content

Commit dd61c2a

Browse files
authored
Merge branch 'develop' into psir_func
2 parents e895a00 + 3984296 commit dd61c2a

Some content is hidden

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

68 files changed

+1684
-1993
lines changed

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

source/Makefile.Objects

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,6 @@ OBJS_ESOLVER=esolver.o\
243243
esolver_of.o\
244244
esolver_of_tool.o\
245245
esolver_of_interface.o\
246-
print_funcs.o\
247246
pw_fun.o\
248247
pw_init_after_vc.o\
249248
pw_init_globalc.o\
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
}

source/module_elecstate/module_charge/symmetry_rho.cpp

Lines changed: 2 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ void Symmetry_rho::psymm(double* rho_part,
9797
rhotot.resize(rho_basis->nxyz);
9898
ModuleBase::GlobalFunc::ZEROS(rhotot.data(), rho_basis->nxyz);
9999
}
100-
Pgrid.reduce_to_fullrho(rhotot.data(), rho_part);
100+
Pgrid.reduce(rhotot.data(), rho_part);
101101

102102
// (2)
103103
if (GlobalV::MY_RANK == 0)
@@ -127,24 +127,7 @@ void Symmetry_rho::psymm(double* rho_part,
127127
}
128128

129129
// (3)
130-
const int ncxy = rho_basis->nx * rho_basis->ny;
131-
std::vector<double> zpiece(ncxy);
132-
for (int iz = 0; iz < rho_basis->nz; iz++)
133-
{
134-
ModuleBase::GlobalFunc::ZEROS(zpiece.data(), ncxy);
135-
if (GlobalV::MY_RANK == 0)
136-
{
137-
for (int ix = 0; ix < rho_basis->nx; ix++)
138-
{
139-
for (int iy = 0; iy < rho_basis->ny; iy++)
140-
{
141-
const int ir = ix * rho_basis->ny + iy;
142-
zpiece[ir] = rhotot[ix * rho_basis->ny * rho_basis->nz + iy * rho_basis->nz + iz];
143-
}
144-
}
145-
}
146-
Pgrid.zpiece_to_all(zpiece.data(), iz, rho_part);
147-
}
130+
Pgrid.bcast(rhotot.data(), rho_part, GlobalV::MY_RANK);
148131
#endif
149132
return;
150133
}

source/module_esolver/CMakeLists.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ list(APPEND objects
1010
esolver_of.cpp
1111
esolver_of_interface.cpp
1212
esolver_of_tool.cpp
13-
print_funcs.cpp
1413
pw_fun.cpp
1514
pw_init_after_vc.cpp
1615
pw_init_globalc.cpp

source/module_esolver/esolver.cpp

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,17 @@ ESolver* init_esolver(const Input_para& inp, UnitCell& ucell)
153153
return new ESolver_KS_PW<std::complex<double>, base_device::DEVICE_CPU>();
154154
}
155155
}
156+
else if (esolver_type == "sdft_pw")
157+
{
158+
// if (PARAM.inp.precision == "single")
159+
// {
160+
// return new ESolver_SDFT_PW<std::complex<float>, base_device::DEVICE_CPU>();
161+
// }
162+
// else
163+
// {
164+
return new ESolver_SDFT_PW<std::complex<double>, base_device::DEVICE_CPU>();
165+
// }
166+
}
156167
#ifdef __LCAO
157168
else if (esolver_type == "ksdft_lip")
158169
{
@@ -230,10 +241,6 @@ ESolver* init_esolver(const Input_para& inp, UnitCell& ucell)
230241
return p_esolver_lr;
231242
}
232243
#endif
233-
else if (esolver_type == "sdft_pw")
234-
{
235-
return new ESolver_SDFT_PW();
236-
}
237244
else if(esolver_type == "ofdft")
238245
{
239246
return new ESolver_OF();

0 commit comments

Comments
 (0)