From 5a6e039e288ba84293332164e7d5f513fb6f02e4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Kn=C3=BCttel?= Date: Mon, 15 Jul 2019 22:27:12 +0200 Subject: [PATCH] potentials work --- c/interaction/interaction.c | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/c/interaction/interaction.c b/c/interaction/interaction.c index 41b0728..7d11dce 100644 --- a/c/interaction/interaction.c +++ b/c/interaction/interaction.c @@ -13,19 +13,22 @@ interaction_force_function { float result = 0; int i; - result = coefficients[0]; + result = coefficients[0] * coefficients[8]; for(i = 1; i < 7; i++) { - result += coefficients[i] * (powf(r, i - 1) + coefficients[8]*powf(r, i)); + result += coefficients[i] * (powf(r, i - 1) / i + coefficients[8]*powf(r, i)); } result *= coefficients[7] * expf(coefficients[8] * (r - coefficients[9])); - result += coefficients[10] * coefficients[11] * expf(coefficients[11] * (r - coefficients[12])); + result += coefficients[10] * coefficients[11] + * expf(coefficients[11] * (r - coefficients[12])); result += coefficients[13] * 2 * (r - coefficients[15]) - * coefficients[14] * expf(coefficients[14] * raise2(r - coefficients[15])); + * coefficients[14] + * expf(coefficients[14] * raise2(r - coefficients[15])); result += coefficients[16] * 2 * (r - coefficients[18]) - * coefficients[17] * expf(coefficients[17] * raise2(r - coefficients[18])); + * coefficients[17] + * expf(coefficients[17] * raise2(r - coefficients[18])); return result; } static float @@ -193,10 +196,10 @@ interaction_ufunc_float2D } #endif //printf("%d, %d: %f, %f\n", i, j, delta_p_x, delta_p_y); - *(float *)(p_x_new + i*p_x_new_steps) += dt*delta_p_x; - *(float *)(p_y_new + i*p_y_new_steps) += dt*delta_p_y; - *(float *)(p_x_new + j*p_x_new_steps) -= dt*delta_p_x; - *(float *)(p_y_new + j*p_y_new_steps) -= dt*delta_p_y; + *(float *)(p_x_new + i*p_x_new_steps) -= dt*delta_p_x; + *(float *)(p_y_new + i*p_y_new_steps) -= dt*delta_p_y; + *(float *)(p_x_new + j*p_x_new_steps) += dt*delta_p_x; + *(float *)(p_y_new + j*p_y_new_steps) += dt*delta_p_y; } } //NPY_END_THREADS;