Skip to content

Commit c3caafa

Browse files
authored
Merge pull request #1040 from sunml99/develop
test: add PW and LCAO tests for implicit solvation model
2 parents e6254bc + a53b7ba commit c3caafa

File tree

30 files changed

+283
-6
lines changed

30 files changed

+283
-6
lines changed

source/module_surchem/corrected_energy.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,17 @@ double surchem::cal_Ael(const UnitCell &cell, ModulePW::PW_Basis* rho_basis)
88
Ael -= TOTN_real[ir] * delta_phi[ir];
99
}
1010
Parallel_Reduce::reduce_double_pool(Ael);
11-
Ael = Ael * cell.omega * 0.5 / rho_basis->nxyz;
12-
cout << "Ael: " << Ael << endl;
11+
Ael = Ael * cell.omega / rho_basis->nxyz; // unit Ry
12+
//cout << "Ael: " << Ael << endl;
1313
return Ael;
1414
}
1515

1616
double surchem::cal_Acav(const UnitCell &cell, ModulePW::PW_Basis* rho_basis)
1717
{
1818
double Acav = 0.0;
1919
Acav = GlobalV::tau * qs;
20-
Acav = Acav * cell.omega * 0.5 / rho_basis->nxyz;
20+
Acav = Acav * cell.omega / rho_basis->nxyz; // unit Ry
2121
Parallel_Reduce::reduce_double_pool(Acav);
22-
cout << "Acav: " << Acav << endl;
22+
//cout << "Acav: " << Acav << endl;
2323
return Acav;
2424
}

source/src_pw/energy.cpp

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
#include "H_Ewald_pw.h"
1818
#include "H_Hartree_pw.h"
1919
#include "../module_surchem/efield.h" // liuyu add 2022-05-06
20+
#include "../module_surchem/surchem.h"
2021
#ifdef __DEEPKS
2122
#include "../module_deepks/LCAO_deepks.h"
2223
#endif
@@ -36,6 +37,8 @@ energy::energy()
3637

3738
this->demet = 0; // correction for metals
3839
this->ef = 0; // the fermi energy
40+
this->esol_el = 0; // the implicit solvation energy Ael
41+
this->esol_cav = 0; // the implicit solvation energy Acav
3942
}
4043

4144
energy::~energy()
@@ -91,7 +94,11 @@ void energy::calculate_etot(void)
9194
+ exx
9295
+ Efield::etotefield
9396
+ evdw; // Peize Lin add evdw 2021.03.09
94-
97+
if (GlobalV::imp_sol)
98+
{
99+
this->etot += GlobalC::solvent_model.cal_Ael(GlobalC::ucell, GlobalC::rhopw)
100+
+ GlobalC::solvent_model.cal_Acav(GlobalC::ucell, GlobalC::rhopw);
101+
}
95102
//Quxin adds for DFT+U energy correction on 20201029
96103

97104
// std::cout << std::resetiosflags(ios::scientific) << std::endl;
@@ -165,7 +172,15 @@ void energy::print_etot(
165172
{
166173
this->print_format("E_vdwD3", evdw);
167174
}
168-
this->print_format("E_exx", exx);
175+
this->print_format("E_exx", exx);
176+
177+
if (GlobalV::imp_sol)
178+
{
179+
esol_el = GlobalC::solvent_model.cal_Ael(GlobalC::ucell, GlobalC::rhopw);
180+
esol_cav = GlobalC::solvent_model.cal_Acav(GlobalC::ucell, GlobalC::rhopw);
181+
this->print_format("E_sol_el", esol_el);
182+
this->print_format("E_sol_cav", esol_cav);
183+
}
169184
#ifdef __DEEPKS
170185
if (GlobalV::deepks_scf) //caoyu add 2021-08-10
171186
{

source/src_pw/energy.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,8 @@ class energy
5151
double deband; // correction for variational energy
5252
double deband_harris;
5353
double descf;
54+
double esol_el; //correction for implicit solvation energy
55+
double esol_cav; //correction for implicit solvation energy
5456

5557
double etxcc; // the nlcc exchange and correlation
5658
double etxc;

source/src_pw/potential.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -362,10 +362,12 @@ ModuleBase::matrix Potential::v_of_rho(const double *const *const rho_in, const
362362
if (GlobalV::imp_sol)
363363
{
364364
v += GlobalC::solvent_model.v_correction(GlobalC::ucell, GlobalC::rhopw, GlobalV::NSPIN, rho_in);
365+
/*
365366
// test energy outside
366367
cout << "energy Outside: " << endl;
367368
GlobalC::solvent_model.cal_Ael(GlobalC::ucell, GlobalC::rhopw);
368369
GlobalC::solvent_model.cal_Acav(GlobalC::ucell, GlobalC::rhopw);
370+
*/
369371
}
370372
}
371373

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
INPUT_PARAMETERS
2+
#Parameters (General)
3+
suffix autotest
4+
pseudo_dir ../tools/PP_ORB/
5+
ntype 1
6+
nbands 2
7+
calculation scf
8+
basis_type pw
9+
10+
#Parameters (Accuracy)
11+
ecutwfc 20
12+
scf_nmax 50
13+
14+
#Parameters (Solvation Model)
15+
imp_sol 1
16+
eb_k 80
17+
tau 0.000010798
18+
sigma_k 0.6
19+
nc_k 0.00037

tests/integrate/115_PW_sol_H2/KPT

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
K_POINTS
2+
0
3+
Gamma
4+
1 1 1 0 0 0
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
This test for: implicit solvation energy correction
2+
*H2
3+
*PW
4+
*kpoints 1*1*1

tests/integrate/115_PW_sol_H2/STRU

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
ATOMIC_SPECIES
2+
H 1.008 H_ONCV_PBE-1.0.upf
3+
4+
NUMERICAL_ORBITAL
5+
H_gga_8au_60Ry_2s1p.orb
6+
7+
LATTICE_CONSTANT
8+
1
9+
10+
LATTICE_VECTORS
11+
10 0 0
12+
0 10 0
13+
0 0 10
14+
15+
ATOMIC_POSITIONS
16+
Cartesian # Cartesian(Unit is LATTICE_CONSTANT)
17+
18+
19+
H
20+
0.0
21+
2
22+
0.00 0.00 -0.70 0 0 0
23+
0.00 0.01 0.70 0 0 0
24+
25+

tests/integrate/115_PW_sol_H2/jd

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
test inplicit solvation model correction for H2
2+
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
etotref -31.89433892278758
2+
etotperatomref -15.9471694614
3+
esolelref -0.806566849545
4+
esolcavref +0.0238601887027
5+
totaltimeref 1.3477

0 commit comments

Comments
 (0)