Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

more flexible lmax #728

Merged
merged 9 commits into from
Oct 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 8 additions & 36 deletions src/force/nep3.cu
Original file line number Diff line number Diff line change
Expand Up @@ -668,7 +668,7 @@ static __global__ void find_descriptor(
weight_left +
g_gn_angular[(index_right * paramb.num_types_sq + t12) * (paramb.n_max_angular + 1) + n] *
weight_right;
accumulate_s(d12, x12, y12, z12, gn12, s);
accumulate_s(paramb.L_max, d12, x12, y12, z12, gn12, s);
#else
float fc12;
int t2 = g_type[n2];
Expand All @@ -690,16 +690,10 @@ static __global__ void find_descriptor(
c_index += t1 * paramb.num_types + t2 + paramb.num_c_radial;
gn12 += fn12[k] * annmb.c[c_index];
}
accumulate_s(d12, x12, y12, z12, gn12, s);
accumulate_s(paramb.L_max, d12, x12, y12, z12, gn12, s);
#endif
}
if (paramb.num_L == paramb.L_max) {
find_q(paramb.n_max_angular + 1, n, s, q + (paramb.n_max_radial + 1));
} else if (paramb.num_L == paramb.L_max + 1) {
find_q_with_4body(paramb.n_max_angular + 1, n, s, q + (paramb.n_max_radial + 1));
} else {
find_q_with_5body(paramb.n_max_angular + 1, n, s, q + (paramb.n_max_radial + 1));
}
find_q(paramb.L_max, paramb.num_L, paramb.n_max_angular + 1, n, s, q + (paramb.n_max_radial + 1));
for (int abc = 0; abc < NUM_OF_ABC; ++abc) {
g_sum_fxyz[(n * NUM_OF_ABC + abc) * N + n1] = s[abc];
}
Expand Down Expand Up @@ -983,15 +977,7 @@ static __global__ void find_partial_force_angular(
g_gn_angular[index_left_all] * weight_left + g_gn_angular[index_right_all] * weight_right;
float gnp12 = g_gnp_angular[index_left_all] * weight_left +
g_gnp_angular[index_right_all] * weight_right;
if (paramb.num_L == paramb.L_max) {
accumulate_f12(n, paramb.n_max_angular + 1, d12, r12, gn12, gnp12, Fp, sum_fxyz, f12);
} else if (paramb.num_L == paramb.L_max + 1) {
accumulate_f12_with_4body(
n, paramb.n_max_angular + 1, d12, r12, gn12, gnp12, Fp, sum_fxyz, f12);
} else {
accumulate_f12_with_5body(
n, paramb.n_max_angular + 1, d12, r12, gn12, gnp12, Fp, sum_fxyz, f12);
}
accumulate_f12(paramb.L_max, paramb.num_L, n, paramb.n_max_angular + 1, d12, r12, gn12, gnp12, Fp, sum_fxyz, f12);
}
#else
float fc12, fcp12;
Expand Down Expand Up @@ -1019,15 +1005,7 @@ static __global__ void find_partial_force_angular(
gn12 += fn12[k] * annmb.c[c_index];
gnp12 += fnp12[k] * annmb.c[c_index];
}
if (paramb.num_L == paramb.L_max) {
accumulate_f12(n, paramb.n_max_angular + 1, d12, r12, gn12, gnp12, Fp, sum_fxyz, f12);
} else if (paramb.num_L == paramb.L_max + 1) {
accumulate_f12_with_4body(
n, paramb.n_max_angular + 1, d12, r12, gn12, gnp12, Fp, sum_fxyz, f12);
} else {
accumulate_f12_with_5body(
n, paramb.n_max_angular + 1, d12, r12, gn12, gnp12, Fp, sum_fxyz, f12);
}
accumulate_f12(paramb.L_max, paramb.num_L, n, paramb.n_max_angular + 1, d12, r12, gn12, gnp12, Fp, sum_fxyz, f12);
}
#endif
g_f12x[index] = f12[0];
Expand Down Expand Up @@ -1683,7 +1661,7 @@ static __global__ void find_descriptor(
weight_left +
g_gn_angular[(index_right * paramb.num_types_sq + t12) * (paramb.n_max_angular + 1) + n] *
weight_right;
accumulate_s(d12, x12, y12, z12, gn12, s);
accumulate_s(paramb.L_max, d12, x12, y12, z12, gn12, s);
#else
float fc12;
int t2 = g_type[n2];
Expand All @@ -1705,16 +1683,10 @@ static __global__ void find_descriptor(
c_index += t1 * paramb.num_types + t2 + paramb.num_c_radial;
gn12 += fn12[k] * annmb.c[c_index];
}
accumulate_s(d12, x12, y12, z12, gn12, s);
accumulate_s(paramb.L_max, d12, x12, y12, z12, gn12, s);
#endif
}
if (paramb.num_L == paramb.L_max) {
find_q(paramb.n_max_angular + 1, n, s, q + (paramb.n_max_radial + 1));
} else if (paramb.num_L == paramb.L_max + 1) {
find_q_with_4body(paramb.n_max_angular + 1, n, s, q + (paramb.n_max_radial + 1));
} else {
find_q_with_5body(paramb.n_max_angular + 1, n, s, q + (paramb.n_max_radial + 1));
}
find_q(paramb.L_max, paramb.num_L, paramb.n_max_angular + 1, n, s, q + (paramb.n_max_radial + 1));
for (int abc = 0; abc < NUM_OF_ABC; ++abc) {
g_sum_fxyz[(n * NUM_OF_ABC + abc) * N + n1] = s[abc];
}
Expand Down
44 changes: 8 additions & 36 deletions src/force/nep3_multigpu.cu
Original file line number Diff line number Diff line change
Expand Up @@ -942,7 +942,7 @@ static __global__ void find_descriptor(
weight_left +
g_gn_angular[(index_right * paramb.num_types_sq + t12) * (paramb.n_max_angular + 1) + n] *
weight_right;
accumulate_s(d12, x12, y12, z12, gn12, s);
accumulate_s(paramb.L_max, d12, x12, y12, z12, gn12, s);
#else
float fc12;
int t2 = g_type[n2];
Expand All @@ -964,16 +964,10 @@ static __global__ void find_descriptor(
c_index += t1 * paramb.num_types + t2 + paramb.num_c_radial;
gn12 += fn12[k] * annmb.c[c_index];
}
accumulate_s(d12, x12, y12, z12, gn12, s);
accumulate_s(paramb.L_max, d12, x12, y12, z12, gn12, s);
#endif
}
if (paramb.num_L == paramb.L_max) {
find_q(paramb.n_max_angular + 1, n, s, q + (paramb.n_max_radial + 1));
} else if (paramb.num_L == paramb.L_max + 1) {
find_q_with_4body(paramb.n_max_angular + 1, n, s, q + (paramb.n_max_radial + 1));
} else {
find_q_with_5body(paramb.n_max_angular + 1, n, s, q + (paramb.n_max_radial + 1));
}
find_q(paramb.L_max, paramb.num_L, paramb.n_max_angular + 1, n, s, q + (paramb.n_max_radial + 1));
for (int abc = 0; abc < NUM_OF_ABC; ++abc) {
g_sum_fxyz[(n * NUM_OF_ABC + abc) * N + n1] = s[abc];
}
Expand Down Expand Up @@ -1254,15 +1248,7 @@ static __global__ void find_partial_force_angular(
g_gn_angular[index_left_all] * weight_left + g_gn_angular[index_right_all] * weight_right;
float gnp12 = g_gnp_angular[index_left_all] * weight_left +
g_gnp_angular[index_right_all] * weight_right;
if (paramb.num_L == paramb.L_max) {
accumulate_f12(n, paramb.n_max_angular + 1, d12, r12, gn12, gnp12, Fp, sum_fxyz, f12);
} else if (paramb.num_L == paramb.L_max + 1) {
accumulate_f12_with_4body(
n, paramb.n_max_angular + 1, d12, r12, gn12, gnp12, Fp, sum_fxyz, f12);
} else {
accumulate_f12_with_5body(
n, paramb.n_max_angular + 1, d12, r12, gn12, gnp12, Fp, sum_fxyz, f12);
}
accumulate_f12(paramb.L_max, paramb.num_L, n, paramb.n_max_angular + 1, d12, r12, gn12, gnp12, Fp, sum_fxyz, f12);
}
#else
float fc12, fcp12;
Expand Down Expand Up @@ -1290,15 +1276,7 @@ static __global__ void find_partial_force_angular(
gn12 += fn12[k] * annmb.c[c_index];
gnp12 += fnp12[k] * annmb.c[c_index];
}
if (paramb.num_L == paramb.L_max) {
accumulate_f12(n, paramb.n_max_angular + 1, d12, r12, gn12, gnp12, Fp, sum_fxyz, f12);
} else if (paramb.num_L == paramb.L_max + 1) {
accumulate_f12_with_4body(
n, paramb.n_max_angular + 1, d12, r12, gn12, gnp12, Fp, sum_fxyz, f12);
} else {
accumulate_f12_with_5body(
n, paramb.n_max_angular + 1, d12, r12, gn12, gnp12, Fp, sum_fxyz, f12);
}
accumulate_f12(paramb.L_max, paramb.num_L, n, paramb.n_max_angular + 1, d12, r12, gn12, gnp12, Fp, sum_fxyz, f12);
}
#endif
g_f12x[index] = f12[0];
Expand Down Expand Up @@ -2088,7 +2066,7 @@ static __global__ void find_descriptor(
weight_left +
g_gn_angular[(index_right * paramb.num_types_sq + t12) * (paramb.n_max_angular + 1) + n] *
weight_right;
accumulate_s(d12, x12, y12, z12, gn12, s);
accumulate_s(paramb.L_max, d12, x12, y12, z12, gn12, s);
#else
float fc12;
int t2 = g_type[n2];
Expand All @@ -2110,16 +2088,10 @@ static __global__ void find_descriptor(
c_index += t1 * paramb.num_types + t2 + paramb.num_c_radial;
gn12 += fn12[k] * annmb.c[c_index];
}
accumulate_s(d12, x12, y12, z12, gn12, s);
accumulate_s(paramb.L_max, d12, x12, y12, z12, gn12, s);
#endif
}
if (paramb.num_L == paramb.L_max) {
find_q(paramb.n_max_angular + 1, n, s, q + (paramb.n_max_radial + 1));
} else if (paramb.num_L == paramb.L_max + 1) {
find_q_with_4body(paramb.n_max_angular + 1, n, s, q + (paramb.n_max_radial + 1));
} else {
find_q_with_5body(paramb.n_max_angular + 1, n, s, q + (paramb.n_max_radial + 1));
}
find_q(paramb.L_max, paramb.num_L, paramb.n_max_angular + 1, n, s, q + (paramb.n_max_radial + 1));
for (int abc = 0; abc < NUM_OF_ABC; ++abc) {
g_sum_fxyz[(n * NUM_OF_ABC + abc) * N + n1] = s[abc];
}
Expand Down
44 changes: 8 additions & 36 deletions src/force/nep3_small_box.cuh
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ static __global__ void find_descriptor_small_box(
weight_left +
g_gn_angular[(index_right * paramb.num_types_sq + t12) * (paramb.n_max_angular + 1) + n] *
weight_right;
accumulate_s(d12, r12[0], r12[1], r12[2], gn12, s);
accumulate_s(paramb.L_max, d12, r12[0], r12[1], r12[2], gn12, s);
#else
float fc12;
int t2 = g_type[n2];
Expand All @@ -281,16 +281,10 @@ static __global__ void find_descriptor_small_box(
c_index += t1 * paramb.num_types + t2 + paramb.num_c_radial;
gn12 += fn12[k] * annmb.c[c_index];
}
accumulate_s(d12, r12[0], r12[1], r12[2], gn12, s);
accumulate_s(paramb.L_max, d12, r12[0], r12[1], r12[2], gn12, s);
#endif
}
if (paramb.num_L == paramb.L_max) {
find_q(paramb.n_max_angular + 1, n, s, q + (paramb.n_max_radial + 1));
} else if (paramb.num_L == paramb.L_max + 1) {
find_q_with_4body(paramb.n_max_angular + 1, n, s, q + (paramb.n_max_radial + 1));
} else {
find_q_with_5body(paramb.n_max_angular + 1, n, s, q + (paramb.n_max_radial + 1));
}
find_q(paramb.L_max, paramb.num_L, paramb.n_max_angular + 1, n, s, q + (paramb.n_max_radial + 1));
for (int abc = 0; abc < NUM_OF_ABC; ++abc) {
g_sum_fxyz[(n * NUM_OF_ABC + abc) * N + n1] = s[abc];
}
Expand Down Expand Up @@ -454,7 +448,7 @@ static __global__ void find_descriptor_small_box(
weight_left +
g_gn_angular[(index_right * paramb.num_types_sq + t12) * (paramb.n_max_angular + 1) + n] *
weight_right;
accumulate_s(d12, r12[0], r12[1], r12[2], gn12, s);
accumulate_s(paramb.L_max, d12, r12[0], r12[1], r12[2], gn12, s);
#else
float fc12;
int t2 = g_type[n2];
Expand All @@ -476,16 +470,10 @@ static __global__ void find_descriptor_small_box(
c_index += t1 * paramb.num_types + t2 + paramb.num_c_radial;
gn12 += fn12[k] * annmb.c[c_index];
}
accumulate_s(d12, r12[0], r12[1], r12[2], gn12, s);
accumulate_s(paramb.L_max, d12, r12[0], r12[1], r12[2], gn12, s);
#endif
}
if (paramb.num_L == paramb.L_max) {
find_q(paramb.n_max_angular + 1, n, s, q + (paramb.n_max_radial + 1));
} else if (paramb.num_L == paramb.L_max + 1) {
find_q_with_4body(paramb.n_max_angular + 1, n, s, q + (paramb.n_max_radial + 1));
} else {
find_q_with_5body(paramb.n_max_angular + 1, n, s, q + (paramb.n_max_radial + 1));
}
find_q(paramb.L_max, paramb.num_L, paramb.n_max_angular + 1, n, s, q + (paramb.n_max_radial + 1));
for (int abc = 0; abc < NUM_OF_ABC; ++abc) {
g_sum_fxyz[(n * NUM_OF_ABC + abc) * N + n1] = s[abc];
}
Expand Down Expand Up @@ -698,15 +686,7 @@ static __global__ void find_force_angular_small_box(
g_gn_angular[index_left_all] * weight_left + g_gn_angular[index_right_all] * weight_right;
float gnp12 = g_gnp_angular[index_left_all] * weight_left +
g_gnp_angular[index_right_all] * weight_right;
if (paramb.num_L == paramb.L_max) {
accumulate_f12(n, paramb.n_max_angular + 1, d12, r12, gn12, gnp12, Fp, sum_fxyz, f12);
} else if (paramb.num_L == paramb.L_max + 1) {
accumulate_f12_with_4body(
n, paramb.n_max_angular + 1, d12, r12, gn12, gnp12, Fp, sum_fxyz, f12);
} else {
accumulate_f12_with_5body(
n, paramb.n_max_angular + 1, d12, r12, gn12, gnp12, Fp, sum_fxyz, f12);
}
accumulate_f12(paramb.L_max, paramb.num_L, n, paramb.n_max_angular + 1, d12, r12, gn12, gnp12, Fp, sum_fxyz, f12);
}
#else
float fc12, fcp12;
Expand All @@ -733,15 +713,7 @@ static __global__ void find_force_angular_small_box(
gn12 += fn12[k] * annmb.c[c_index];
gnp12 += fnp12[k] * annmb.c[c_index];
}
if (paramb.num_L == paramb.L_max) {
accumulate_f12(n, paramb.n_max_angular + 1, d12, r12, gn12, gnp12, Fp, sum_fxyz, f12);
} else if (paramb.num_L == paramb.L_max + 1) {
accumulate_f12_with_4body(
n, paramb.n_max_angular + 1, d12, r12, gn12, gnp12, Fp, sum_fxyz, f12);
} else {
accumulate_f12_with_5body(
n, paramb.n_max_angular + 1, d12, r12, gn12, gnp12, Fp, sum_fxyz, f12);
}
accumulate_f12(paramb.L_max, paramb.num_L, n, paramb.n_max_angular + 1, d12, r12, gn12, gnp12, Fp, sum_fxyz, f12);
}
#endif
double s_sxx = 0.0;
Expand Down
20 changes: 3 additions & 17 deletions src/main_nep/nep3.cu
Original file line number Diff line number Diff line change
Expand Up @@ -221,15 +221,9 @@ static __global__ void find_descriptors_angular(
c_index += t1 * paramb.num_types + t2 + paramb.num_c_radial;
gn12 += fn12[k] * annmb.c[c_index];
}
accumulate_s(d12, x12, y12, z12, gn12, s);
}
if (paramb.num_L == paramb.L_max) {
find_q(paramb.n_max_angular + 1, n, s, q);
} else if (paramb.num_L == paramb.L_max + 1) {
find_q_with_4body(paramb.n_max_angular + 1, n, s, q);
} else {
find_q_with_5body(paramb.n_max_angular + 1, n, s, q);
accumulate_s(paramb.L_max, d12, x12, y12, z12, gn12, s);
}
find_q(paramb.L_max, paramb.num_L, paramb.n_max_angular + 1, n, s, q);
for (int abc = 0; abc < NUM_OF_ABC; ++abc) {
g_sum_fxyz[(n * NUM_OF_ABC + abc) * N + n1] = s[abc];
}
Expand Down Expand Up @@ -726,15 +720,7 @@ static __global__ void find_force_angular(
gn12 += fn12[k] * annmb.c[c_index];
gnp12 += fnp12[k] * annmb.c[c_index];
}
if (paramb.num_L == paramb.L_max) {
accumulate_f12(n, paramb.n_max_angular + 1, d12, r12, gn12, gnp12, Fp, sum_fxyz, f12);
} else if (paramb.num_L == paramb.L_max + 1) {
accumulate_f12_with_4body(
n, paramb.n_max_angular + 1, d12, r12, gn12, gnp12, Fp, sum_fxyz, f12);
} else {
accumulate_f12_with_5body(
n, paramb.n_max_angular + 1, d12, r12, gn12, gnp12, Fp, sum_fxyz, f12);
}
accumulate_f12(paramb.L_max, paramb.num_L, n, paramb.n_max_angular + 1, d12, r12, gn12, gnp12, Fp, sum_fxyz, f12);
}

atomicAdd(&g_fx[n1], f12[0]);
Expand Down
10 changes: 8 additions & 2 deletions src/main_nep/parameters.cu
Original file line number Diff line number Diff line change
Expand Up @@ -727,8 +727,11 @@ void Parameters::parse_l_max(const char** param, int num_param)
if (!is_valid_int(param[1], &L_max)) {
PRINT_INPUT_ERROR("l_max for 3-body descriptors should be an integer.\n");
}
if (L_max != 4) {
PRINT_INPUT_ERROR("l_max for 3-body descriptors should = 4.");
if (L_max < 0) {
PRINT_INPUT_ERROR("l_max for 3-body descriptors should >= 0.");
}
if (L_max > 4) {
PRINT_INPUT_ERROR("l_max for 3-body descriptors should <= 4.");
}

if (num_param >= 3) {
Expand All @@ -738,6 +741,9 @@ void Parameters::parse_l_max(const char** param, int num_param)
if (L_max_4body != 0 && L_max_4body != 2) {
PRINT_INPUT_ERROR("l_max for 4-body descriptors should = 0 or 2.");
}
if (L_max < L_max_4body) {
PRINT_INPUT_ERROR("l_max_4body should <= l_max_3body.");
}
}

if (num_param == 4) {
Expand Down
10 changes: 2 additions & 8 deletions src/mc/nep_energy.cu
Original file line number Diff line number Diff line change
Expand Up @@ -360,15 +360,9 @@ static __global__ void find_energy_nep(
c_index += t1 * paramb.num_types + t2 + paramb.num_c_radial;
gn12 += fn12[k] * annmb.c[c_index];
}
accumulate_s(d12, r12[0], r12[1], r12[2], gn12, s);
}
if (paramb.num_L == paramb.L_max) {
find_q(paramb.n_max_angular + 1, n, s, q + (paramb.n_max_radial + 1));
} else if (paramb.num_L == paramb.L_max + 1) {
find_q_with_4body(paramb.n_max_angular + 1, n, s, q + (paramb.n_max_radial + 1));
} else {
find_q_with_5body(paramb.n_max_angular + 1, n, s, q + (paramb.n_max_radial + 1));
accumulate_s(paramb.L_max, d12, r12[0], r12[1], r12[2], gn12, s);
}
find_q(paramb.L_max, paramb.num_L, paramb.n_max_angular + 1, n, s, q + (paramb.n_max_radial + 1));
}

// nomalize descriptor
Expand Down
Loading
Loading