Skip to content

Commit fdd65b7

Browse files
committed
avoid equivalent k points
1 parent 0b7bd20 commit fdd65b7

1 file changed

Lines changed: 11 additions & 13 deletions

File tree

src/force/nep_charge.cu

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1263,19 +1263,17 @@ void NEP_Charge::find_k_and_G(const double* box)
12631263
for (int n2 = - n2_max; n2 <= n2_max; ++n2) {
12641264
for (int n3 = - n3_max; n3 <= n3_max; ++n3) {
12651265
const int nsq = n1 * n1 + n2 * n2 + n3 * n3;
1266-
if (nsq > 0) {
1267-
const float kx = n1 * b1[0] + n2 * b2[0] + n3 * b3[0];
1268-
const float ky = n1 * b1[1] + n2 * b2[1] + n3 * b3[1];
1269-
const float kz = n1 * b1[2] + n2 * b2[2] + n3 * b3[2];
1270-
const float ksq = kx * kx + ky * ky + kz * kz;
1271-
if (ksq < ksq_max) {
1272-
cpu_kx.emplace_back(kx);
1273-
cpu_ky.emplace_back(ky);
1274-
cpu_kz.emplace_back(kz);
1275-
float G = abs(two_pi_over_det) / ksq * exp(-ksq * charge_para.alpha_factor);
1276-
const float symmetry_factor = (n1 > 0) ? 2.0f : 1.0f;
1277-
cpu_G.emplace_back(symmetry_factor * G);
1278-
}
1266+
if (nsq == 0 || (n1 == 0 && n2 < 0) || (n1 == 0 && n2 == 0 && n3 < 0)) continue;
1267+
const float kx = n1 * b1[0] + n2 * b2[0] + n3 * b3[0];
1268+
const float ky = n1 * b1[1] + n2 * b2[1] + n3 * b3[1];
1269+
const float kz = n1 * b1[2] + n2 * b2[2] + n3 * b3[2];
1270+
const float ksq = kx * kx + ky * ky + kz * kz;
1271+
if (ksq < ksq_max) {
1272+
cpu_kx.emplace_back(kx);
1273+
cpu_ky.emplace_back(ky);
1274+
cpu_kz.emplace_back(kz);
1275+
const float G = abs(two_pi_over_det) / ksq * exp(-ksq * charge_para.alpha_factor);
1276+
cpu_G.emplace_back(2.0f * G);
12791277
}
12801278
}
12811279
}

0 commit comments

Comments
 (0)