merged
This commit is contained in:
commit
9580818204
|
@ -113,17 +113,13 @@ interaction_ufunc_float2D
|
||||||
|
|
||||||
char * x_old = args[0]
|
char * x_old = args[0]
|
||||||
, * y_old = args[1]
|
, * y_old = args[1]
|
||||||
, * p_x_old = args[2]
|
, * p_x_new = args[2]
|
||||||
, * p_y_old = args[3]
|
, * p_y_new = args[3];
|
||||||
, * p_x_new = args[4]
|
|
||||||
, * p_y_new = args[5];
|
|
||||||
|
|
||||||
npy_intp x_old_steps = steps[0]
|
npy_intp x_old_steps = steps[0]
|
||||||
, y_old_steps = steps[1]
|
, y_old_steps = steps[1]
|
||||||
, p_x_old_steps = steps[2]
|
, p_x_new_steps = steps[2]
|
||||||
, p_y_old_steps = steps[3]
|
, p_y_new_steps = steps[3];
|
||||||
, p_x_new_steps = steps[4]
|
|
||||||
, p_y_new_steps = steps[5];
|
|
||||||
|
|
||||||
float * coefficients = (float *) data;
|
float * coefficients = (float *) data;
|
||||||
float dt = coefficients[19];
|
float dt = coefficients[19];
|
||||||
|
@ -151,10 +147,8 @@ interaction_ufunc_float2D
|
||||||
this_x_i = *(float *)(x_old + i*x_old_steps);
|
this_x_i = *(float *)(x_old + i*x_old_steps);
|
||||||
this_y_i = *(float *)(y_old + i*y_old_steps);
|
this_y_i = *(float *)(y_old + i*y_old_steps);
|
||||||
|
|
||||||
// copy current momenta
|
*(float *)(p_x_new + i*p_x_new_steps) = 0;
|
||||||
*(float *)(p_x_new + i*p_x_new_steps) = *(float *)(p_x_old + i*p_x_old_steps);
|
*(float *)(p_y_new + i*p_y_new_steps) = 0;
|
||||||
*(float *)(p_y_new + i*p_y_new_steps) = *(float *)(p_y_old + i*p_y_old_steps);
|
|
||||||
|
|
||||||
// compute and add the momentum offset
|
// compute and add the momentum offset
|
||||||
for(j = 0; j < i; j++)
|
for(j = 0; j < i; j++)
|
||||||
{
|
{
|
||||||
|
@ -205,7 +199,7 @@ interaction_ufunc_float2D
|
||||||
//NPY_END_THREADS;
|
//NPY_END_THREADS;
|
||||||
}
|
}
|
||||||
static char interaction_types[] =
|
static char interaction_types[] =
|
||||||
{ NPY_FLOAT, NPY_FLOAT, NPY_FLOAT, NPY_FLOAT, NPY_FLOAT, NPY_FLOAT};
|
{ NPY_FLOAT, NPY_FLOAT, NPY_FLOAT, NPY_FLOAT};
|
||||||
static char force_types[] =
|
static char force_types[] =
|
||||||
{ NPY_FLOAT, NPY_FLOAT};
|
{ NPY_FLOAT, NPY_FLOAT};
|
||||||
static char potential_types[] =
|
static char potential_types[] =
|
||||||
|
@ -298,9 +292,9 @@ interaction_UFuncWrapper_init
|
||||||
interaction_funcs
|
interaction_funcs
|
||||||
, self->data
|
, self->data
|
||||||
, interaction_types
|
, interaction_types
|
||||||
, 1
|
, 1 // ntypes
|
||||||
, 4
|
, 2 // nin
|
||||||
, 2
|
, 2 // nout
|
||||||
, PyUFunc_None
|
, PyUFunc_None
|
||||||
, "interaction2D"
|
, "interaction2D"
|
||||||
, "Update the momenta according to the given coefficients and positions"
|
, "Update the momenta according to the given coefficients and positions"
|
||||||
|
|
|
@ -15,7 +15,7 @@ borders_x = [-100, 100]
|
||||||
borders_y = [-100, 100]
|
borders_y = [-100, 100]
|
||||||
n_particles = 600
|
n_particles = 600
|
||||||
frames = 100
|
frames = 100
|
||||||
spawn_restriction = 3
|
spawn_restriction = 1.1
|
||||||
dt = 0.1
|
dt = 0.1
|
||||||
c[-1] = dt
|
c[-1] = dt
|
||||||
|
|
||||||
|
|
|
@ -37,7 +37,10 @@ class BrownIterator(object):
|
||||||
if(self._i == 1):
|
if(self._i == 1):
|
||||||
return self.x, self.y
|
return self.x, self.y
|
||||||
|
|
||||||
self.px, self.py = self._interaction(self.x, self.y, self.px, self.py)
|
delta_px, delta_py = self._interaction(self.x, self.y)
|
||||||
|
self.px += delta_px
|
||||||
|
self.py += delta_py
|
||||||
|
print(self.px)
|
||||||
# XXX: We need the (-1)**i to make the problem
|
# XXX: We need the (-1)**i to make the problem
|
||||||
# symmetric.
|
# symmetric.
|
||||||
self.px[np.isnan(self.px)] = self.speed_of_light * (-1)**self._i
|
self.px[np.isnan(self.px)] = self.speed_of_light * (-1)**self._i
|
||||||
|
|
Loading…
Reference in New Issue
Block a user