made some useful changes

This commit is contained in:
2019-07-13 15:20:50 +02:00
parent fb7c109e0b
commit 0a734b8266
2 changed files with 13 additions and 10 deletions

View File

@@ -1,8 +1,8 @@
#include "interaction.h"
#include "math.h"
#define WARN_NAN_OCCUR
#define WARN_CORRECTED_R_0
//#define WARN_NAN_OCCUR
//#define WARN_CORRECTED_R_0
#define raise2(x) (x)*(x)
@@ -87,6 +87,7 @@ interaction_ufunc_float2D
, npy_intp * steps
, void * data)
{
NPY_BEGIN_THREADS_DEF;
npy_intp i;
npy_intp j;
npy_intp n = dimensions[0];
@@ -124,6 +125,7 @@ interaction_ufunc_float2D
float this_x_j;
float this_y_j;
NPY_BEGIN_THREADS;
for(i = 0; i < n; i++)
{
@@ -152,9 +154,9 @@ interaction_ufunc_float2D
else
{
long int rand = random();
float random_angle = (((float)rand) / ((float)LONG_MAX)) * 2 * M_PI;
float random_angle = (((float)rand) / ((float)RAND_MAX)) * 2 * M_PI;
#ifdef WARN_CORRECTED_R_0
printf("Warning: corrected r = 0 with random angle pi*%f (from %ld, %f)\n", random_angle / M_PI, rand, random_angle);
printf("Warning: corrected r = 0 with random angle pi*%f\n", random_angle / M_PI);
#endif
delta_x_e = cosf(random_angle);
delty_y_e = sinf(random_angle);
@@ -181,6 +183,7 @@ interaction_ufunc_float2D
*(float *)(p_y_new + j*p_y_new_steps) -= dt*delta_p_y;
}
}
NPY_END_THREADS;
}
static char interaction_types[] =
{ NPY_FLOAT, NPY_FLOAT, NPY_FLOAT, NPY_FLOAT, NPY_FLOAT, NPY_FLOAT};