Skip to content

Commit d17e1e0

Browse files
YuLiu98pre-commit-ci-lite[bot]
authored andcommitted
Refactor: remove GlocalC::ucell in elecstate_energy_terms.cpp (deepmodeling#5630)
* Refactor: remove GlocalC::ucell in elecstate_energy_terms.cpp * [pre-commit.ci lite] apply automatic fixes --------- Co-authored-by: pre-commit-ci-lite[bot] <117423508+pre-commit-ci-lite[bot]@users.noreply.github.com>
1 parent 5c53e5a commit d17e1e0

File tree

7 files changed

+20
-32
lines changed

7 files changed

+20
-32
lines changed

source/Makefile.Objects

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -438,7 +438,6 @@ OBJS_SURCHEM=surchem.o\
438438
cal_totn.o\
439439
cal_vcav.o\
440440
cal_vel.o\
441-
corrected_energy.o\
442441
minimize_cg.o\
443442
sol_force.o\
444443

source/module_elecstate/elecstate_energy_terms.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,12 @@ double ElecState::get_etot_gatefield()
2626

2727
double ElecState::get_solvent_model_Ael()
2828
{
29-
return GlobalC::solvent_model.cal_Ael(GlobalC::ucell, this->charge->nrxx, this->charge->nxyz);
29+
return GlobalC::solvent_model.Ael;
3030
}
3131

3232
double ElecState::get_solvent_model_Acav()
3333
{
34-
return GlobalC::solvent_model.cal_Acav(GlobalC::ucell, this->charge->nxyz);
34+
return GlobalC::solvent_model.Acav;
3535
}
3636

3737
#ifdef __LCAO

source/module_hamilt_general/module_surchem/CMakeLists.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ add_library(
88
cal_totn.cpp
99
cal_vcav.cpp
1010
cal_vel.cpp
11-
corrected_energy.cpp
1211
minimize_cg.cpp
1312
sol_force.cpp
1413
)

source/module_hamilt_general/module_surchem/cal_vcav.cpp

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,18 +10,21 @@ void lapl_rho(const std::complex<double>* rhog, double* lapn, const ModulePW::PW
1010
std::complex<double> *aux = new std::complex<double>[rho_basis->nmaxgr];
1111

1212
// the formula is : rho(r)^prime = \int iG * rho(G)e^{iGr} dG
13-
for (int ig = 0; ig < rho_basis->npw; ig++)
13+
for (int ig = 0; ig < rho_basis->npw; ig++) {
1414
gdrtmpg[ig] = rhog[ig];
15+
}
1516
for(int i = 0 ; i < 3 ; ++i)
1617
{
1718
// calculate the charge density gradient in reciprocal space.
18-
for (int ig = 0; ig < rho_basis->npw; ig++)
19+
for (int ig = 0; ig < rho_basis->npw; ig++) {
1920
aux[ig] = gdrtmpg[ig] * pow(rho_basis->gcar[ig][i], 2);
21+
}
2022
// bring the gdr from G --> R
2123
rho_basis->recip2real(aux, aux);
2224
// remember to multily 2pi/a0, which belongs to G vectors.
23-
for (int ir = 0; ir < rho_basis->nrxx; ir++)
25+
for (int ir = 0; ir < rho_basis->nrxx; ir++) {
2426
lapn[ir] -= aux[ir].real() * GlobalC::ucell.tpiba2;
27+
}
2528
}
2629

2730
delete[] gdrtmpg;
@@ -116,6 +119,8 @@ void surchem::createcavity(const UnitCell& ucell,
116119
//-------------------------------------------------------------
117120
// cavitation energy
118121
//-------------------------------------------------------------
122+
this->Acav = PARAM.inp.tau * qs * ucell.omega / rho_basis->nxyz;
123+
Parallel_Reduce::reduce_pool(this->Acav);
119124

120125
// double Ael = cal_Acav(ucell, pwb);
121126

source/module_hamilt_general/module_surchem/cal_vel.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,13 @@ ModuleBase::matrix surchem::cal_vel(const UnitCell& cell,
109109
}
110110

111111
// calculate Ael
112-
// double Ael = cal_Ael(cell, pwb);
112+
this->Ael = 0.0;
113+
for (int ir = 0; ir < rho_basis->nrxx; ir++)
114+
{
115+
this->Ael -= TOTN_real[ir] * delta_phi[ir];
116+
}
117+
Parallel_Reduce::reduce_pool(this->Ael);
118+
this->Ael *= cell.omega / rho_basis->nxyz;
113119

114120
// the 2nd item of tmp_Vel
115121
eps_pot(PS_TOTN_real, Sol_phi, rho_basis, epsilon, epspot);

source/module_hamilt_general/module_surchem/corrected_energy.cpp

Lines changed: 0 additions & 24 deletions
This file was deleted.

source/module_hamilt_general/module_surchem/surchem.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,9 @@ class surchem
2424
ModuleBase::matrix Vel;
2525
double qs;
2626

27+
double Acav;
28+
double Ael;
29+
2730
// get atom info
2831
atom_in GetAtom;
2932

0 commit comments

Comments
 (0)