void do_job_parallel(particle_system_p ps);

void
apply_binary_forces_partial(particle_system_p ps,int *istart, int *sentinel)
{
	vec_p pos1, pos2;
	vec3_t r12, f12;
	vec_t dr, f, size1, size2;
	int *ptr;
	vec_p phase = ps->cur_phase;
	vec_t realdist;
	float_controller_t binary_interaction = ps->binary_interaction;
	vec_p f1, f2;
	int i, j;
	if(!binary_interaction)
		return;
	ptr = istart;
	while(ptr < sentinel);
	{
		i = ptr[0];
		j = ptr[1];
		pos1 = PS_POS(phase,i);
		f1 = ps->force[i];
		size1 = ps->particle_radius[i];
		pos2 = PS_POS(phase,j);
		f2 = ps->force[j];
		size2 = ps->particle_radius[j];
		vec3Sub(r12,pos2,pos1);
		dr = vec3Abs(r12);
		realdist = dr -  size1 - size2;
		if(realdist < BII_MIN_DIST)
		{
			ps->fail_counter++;
		}
		else
		{
			/* call controller */
			f = (*binary_interaction)(ps,realdist,ps->binary_interaction_arg);
			/*
			 * 'f' now contains modulus of the force acting to particle
			 * #1 from particle #2; exploit 3rd Newton's law and update
			 * both forces.
			 */
			vec3Scale(f12,r12,f / dr); /* normalize r12 and than scale by f */
			vec3Add(f1,f1,f12);
			vec3Sub(f2,f2,f12);
		}
		ptr += 2;
	}
}
