@@ -103,34 +103,38 @@ void Potential::poisson_add_pseudo_pw(mdarray<double_complex, 2>& qmt__,
103
103
}
104
104
}
105
105
106
+ double fourpi_omega = fourpi / unit_cell_.omega ();
107
+
106
108
/* add pseudo_density to interstitial charge density so that rho(G) has the correct
107
109
* multipole moments in the muffin-tins */
108
110
#pragma omp parallel for schedule(static)
109
- for (int igloc = 0 ; igloc < ctx_.gvec ().count (); igloc++) {
111
+ for (int igloc = ctx_. gvec (). skip_g0 () ; igloc < ctx_.gvec ().count (); igloc++) {
110
112
int ig = ctx_.gvec ().offset () + igloc;
111
113
112
114
double gR = ctx_.gvec ().gvec_len (ig) * R;
113
115
double gRn = std::pow (2.0 / gR , pseudo_density_order_ + 1 );
114
116
115
117
double_complex rho_G (0 , 0 );
116
- if (ig) { // G!=0
117
- /* loop over atoms of the same type */
118
- for (int l = 0 , lm = 0 ; l <= ctx_.lmax_rho (); l++) {
119
- double_complex zt1 (0 , 0 );
120
- for (int m = -l; m <= l; m++, lm++) {
121
- zt1 += gvec_ylm_ (lm, igloc) * qapf (lm, igloc);
122
- }
123
- rho_G += (fourpi / unit_cell_.omega ()) * std::conj (zil_[l]) * zt1 * gamma_factors_R_ (l, iat) *
124
- sbessel_mt_ (l + pseudo_density_order_ + 1 , igloc, iat) * gRn ;
125
- } // l
126
- } else { // G=0
127
- for (int i = 0 ; i < unit_cell_.atom_type (iat).num_atoms (); i++) {
128
- int ia = unit_cell_.atom_type (iat).atom_id (i);
129
- rho_G += (fourpi / unit_cell_.omega ()) * y00 * (qmt__ (0 , ia) - qit__ (0 , ia));
118
+ /* loop over atoms of the same type */
119
+ for (int l = 0 , lm = 0 ; l <= ctx_.lmax_rho (); l++) {
120
+ double_complex zt1 (0 , 0 );
121
+ for (int m = -l; m <= l; m++, lm++) {
122
+ zt1 += gvec_ylm_ (lm, igloc) * qapf (lm, igloc);
130
123
}
124
+ rho_G += fourpi_omega * std::conj (zil_[l]) * zt1 * gamma_factors_R_ (l, iat) *
125
+ sbessel_mt_ (l + pseudo_density_order_ + 1 , igloc, iat) * gRn ;
131
126
}
132
127
rho_pw__[igloc] += rho_G;
133
128
}
129
+ /* for G=0 case */
130
+ if (ctx_.comm ().rank () == 0 ) {
131
+ double_complex rho_G (0 , 0 );
132
+ for (int i = 0 ; i < unit_cell_.atom_type (iat).num_atoms (); i++) {
133
+ int ia = unit_cell_.atom_type (iat).atom_id (i);
134
+ rho_G += fourpi_omega * y00 * (qmt__ (0 , ia) - qit__ (0 , ia));
135
+ }
136
+ rho_pw__[0 ] += rho_G;
137
+ }
134
138
}
135
139
}
136
140
0 commit comments