diff --git a/source/Makefile.Objects b/source/Makefile.Objects index c26cd1a19f..6e48801c90 100644 --- a/source/Makefile.Objects +++ b/source/Makefile.Objects @@ -438,7 +438,6 @@ OBJS_SURCHEM=surchem.o\ cal_totn.o\ cal_vcav.o\ cal_vel.o\ - corrected_energy.o\ minimize_cg.o\ sol_force.o\ diff --git a/source/module_elecstate/elecstate_energy_terms.cpp b/source/module_elecstate/elecstate_energy_terms.cpp index 3a0fdb4b07..a4d7d98cf3 100644 --- a/source/module_elecstate/elecstate_energy_terms.cpp +++ b/source/module_elecstate/elecstate_energy_terms.cpp @@ -26,12 +26,12 @@ double ElecState::get_etot_gatefield() double ElecState::get_solvent_model_Ael() { - return GlobalC::solvent_model.cal_Ael(GlobalC::ucell, this->charge->nrxx, this->charge->nxyz); + return GlobalC::solvent_model.Ael; } double ElecState::get_solvent_model_Acav() { - return GlobalC::solvent_model.cal_Acav(GlobalC::ucell, this->charge->nxyz); + return GlobalC::solvent_model.Acav; } #ifdef __LCAO diff --git a/source/module_hamilt_general/module_surchem/CMakeLists.txt b/source/module_hamilt_general/module_surchem/CMakeLists.txt index 6d50a8dceb..5d8b9dd9ca 100644 --- a/source/module_hamilt_general/module_surchem/CMakeLists.txt +++ b/source/module_hamilt_general/module_surchem/CMakeLists.txt @@ -8,7 +8,6 @@ add_library( cal_totn.cpp cal_vcav.cpp cal_vel.cpp - corrected_energy.cpp minimize_cg.cpp sol_force.cpp ) diff --git a/source/module_hamilt_general/module_surchem/cal_vcav.cpp b/source/module_hamilt_general/module_surchem/cal_vcav.cpp index 4e53f37d03..5c1de58fb7 100644 --- a/source/module_hamilt_general/module_surchem/cal_vcav.cpp +++ b/source/module_hamilt_general/module_surchem/cal_vcav.cpp @@ -10,18 +10,21 @@ void lapl_rho(const std::complex* rhog, double* lapn, const ModulePW::PW std::complex *aux = new std::complex[rho_basis->nmaxgr]; // the formula is : rho(r)^prime = \int iG * rho(G)e^{iGr} dG - for (int ig = 0; ig < rho_basis->npw; ig++) + for (int ig = 0; ig < rho_basis->npw; ig++) { gdrtmpg[ig] = rhog[ig]; +} for(int i = 0 ; i < 3 ; ++i) { // calculate the charge density gradient in reciprocal space. - for (int ig = 0; ig < rho_basis->npw; ig++) + for (int ig = 0; ig < rho_basis->npw; ig++) { aux[ig] = gdrtmpg[ig] * pow(rho_basis->gcar[ig][i], 2); +} // bring the gdr from G --> R rho_basis->recip2real(aux, aux); // remember to multily 2pi/a0, which belongs to G vectors. - for (int ir = 0; ir < rho_basis->nrxx; ir++) + for (int ir = 0; ir < rho_basis->nrxx; ir++) { lapn[ir] -= aux[ir].real() * GlobalC::ucell.tpiba2; +} } delete[] gdrtmpg; @@ -116,6 +119,8 @@ void surchem::createcavity(const UnitCell& ucell, //------------------------------------------------------------- // cavitation energy //------------------------------------------------------------- + this->Acav = PARAM.inp.tau * qs * ucell.omega / rho_basis->nxyz; + Parallel_Reduce::reduce_pool(this->Acav); // double Ael = cal_Acav(ucell, pwb); diff --git a/source/module_hamilt_general/module_surchem/cal_vel.cpp b/source/module_hamilt_general/module_surchem/cal_vel.cpp index bc4b68295f..e8cd8d30d5 100644 --- a/source/module_hamilt_general/module_surchem/cal_vel.cpp +++ b/source/module_hamilt_general/module_surchem/cal_vel.cpp @@ -109,7 +109,13 @@ ModuleBase::matrix surchem::cal_vel(const UnitCell& cell, } // calculate Ael - // double Ael = cal_Ael(cell, pwb); + this->Ael = 0.0; + for (int ir = 0; ir < rho_basis->nrxx; ir++) + { + this->Ael -= TOTN_real[ir] * delta_phi[ir]; + } + Parallel_Reduce::reduce_pool(this->Ael); + this->Ael *= cell.omega / rho_basis->nxyz; // the 2nd item of tmp_Vel eps_pot(PS_TOTN_real, Sol_phi, rho_basis, epsilon, epspot); diff --git a/source/module_hamilt_general/module_surchem/corrected_energy.cpp b/source/module_hamilt_general/module_surchem/corrected_energy.cpp deleted file mode 100644 index c0dd66f0cf..0000000000 --- a/source/module_hamilt_general/module_surchem/corrected_energy.cpp +++ /dev/null @@ -1,24 +0,0 @@ -#include "surchem.h" - -double surchem::cal_Ael(const UnitCell &cell, const int& nrxx, const int& nxyz) -{ - double Ael = 0.0; - for (int ir = 0; ir < nrxx; ir++) - { - Ael -= TOTN_real[ir] * delta_phi[ir]; - } - Parallel_Reduce::reduce_pool(Ael); - Ael = Ael * cell.omega / nxyz; - // cout << "Ael: " << Ael << endl; - return Ael; -} - -double surchem::cal_Acav(const UnitCell &cell, const int& nxyz) -{ - double Acav = 0.0; - Acav = PARAM.inp.tau * qs; - Acav = Acav * cell.omega / nxyz; // unit Ry - Parallel_Reduce::reduce_pool(Acav); - // cout << "Acav: " << Acav << endl; - return Acav; -} \ No newline at end of file diff --git a/source/module_hamilt_general/module_surchem/surchem.h b/source/module_hamilt_general/module_surchem/surchem.h index 5696157345..b0541c10f9 100644 --- a/source/module_hamilt_general/module_surchem/surchem.h +++ b/source/module_hamilt_general/module_surchem/surchem.h @@ -24,6 +24,9 @@ class surchem ModuleBase::matrix Vel; double qs; + double Acav; + double Ael; + // get atom info atom_in GetAtom;