@@ -22,27 +22,34 @@ void write_elf(
22
22
std::vector<std::vector<double >> elf (nspin, std::vector<double >(rho_basis->nrxx , 0 .));
23
23
// 1) calculate the kinetic energy density of vW KEDF
24
24
std::vector<std::vector<double >> tau_vw (nspin, std::vector<double >(rho_basis->nrxx , 0 .));
25
+ std::vector<double > phi (rho_basis->nrxx , 0 .); // phi = sqrt(rho)
26
+
25
27
for (int is = 0 ; is < nspin; ++is)
26
28
{
27
- std::vector<std::vector<double >> gradient_rho (3 , std::vector<double >(rho_basis->nrxx , 0 .));
28
-
29
- std::vector<std::complex<double >> recip_rho (rho_basis->npw , 0.0 );
30
- std::vector<std::complex<double >> recip_gradient_rho (rho_basis->npw , 0.0 );
31
- rho_basis->real2recip (rho[is], recip_rho.data ());
29
+ for (int ir = 0 ; ir < rho_basis->nrxx ; ++ir)
30
+ {
31
+ phi[ir] = std::sqrt (std::abs (rho[is][ir]));
32
+ }
33
+
34
+ std::vector<std::vector<double >> gradient_phi (3 , std::vector<double >(rho_basis->nrxx , 0 .));
35
+ std::vector<std::complex<double >> recip_phi (rho_basis->npw , 0.0 );
36
+ std::vector<std::complex<double >> recip_gradient_phi (rho_basis->npw , 0.0 );
37
+
38
+ rho_basis->real2recip (phi.data (), recip_phi.data ());
32
39
33
40
std::complex<double > img (0.0 , 1.0 );
34
41
for (int j = 0 ; j < 3 ; ++j)
35
42
{
36
43
for (int ip = 0 ; ip < rho_basis->npw ; ++ip)
37
44
{
38
- recip_gradient_rho [ip] = img * rho_basis->gcar [ip][j] * recip_rho [ip] * rho_basis->tpiba ;
45
+ recip_gradient_phi [ip] = img * rho_basis->gcar [ip][j] * recip_phi [ip] * rho_basis->tpiba ;
39
46
}
40
47
41
- rho_basis->recip2real (recip_gradient_rho .data (), gradient_rho [j].data ());
48
+ rho_basis->recip2real (recip_gradient_phi .data (), gradient_phi [j].data ());
42
49
43
50
for (int ir = 0 ; ir < rho_basis->nrxx ; ++ir)
44
51
{
45
- tau_vw[is][ir] += gradient_rho [j][ir] * gradient_rho [j][ir] / ( 8 . * rho[is][ir]) * 2.0 ; // convert Ha to Ry.
52
+ tau_vw[is][ir] += gradient_phi [j][ir] * gradient_phi [j][ir] / 2 . * 2 . ; // convert Ha to Ry.
46
53
}
47
54
}
48
55
}
0 commit comments