Example #1
0
/* calc scalar functions of (M^inf)^-1 in F for unequal spheres
 * INPUT
 *  r      := x_b - x_a
 *  aa, ab : radius of particle a and b
 * OUTPUT
 *  scalar_f [8] : scalar functions in dimensional form!
 *    0, 1, 2, 3 : (XA11, XA12, XA21, XA22)
 *    4, 5, 6, 7 : (YA11, YA12, YA21, YA22)
 */
void
scalars_minv_f_poly (double r, double aa, double ab,
		     double *scalar_f)
{
  double scalar[11];

  // (12)-interaction
  // scalar[] is in the dimensional form (not the SD scaling)
  scalars_nonewald_poly (0, /* F version */
			 r, aa, ab, scalar);
  double xa12, ya12;
  xa12 = scalar [0];
  ya12 = scalar [1];


  // (21)-interaction
  double xa21, ya21;
  /* note:
   * [xy]a12 = [xy]a21 in dimensional form by symmetry
   * therefore, we do not need to calculate (21)-interaction explicitly
   */
  xa21 = xa12;
  ya21 = ya12;

  // self part
  double xa11, ya11;
  xa11 = 1.0 / aa;
  ya11 = 1.0 / aa;

  double xa22, ya22;
  xa22 = 1.0 / ab;
  ya22 = 1.0 / ab;


  double det;

  // XA part
  double XA11, XA12, XA21, XA22;
  det = xa11*xa22 - xa12*xa21;
  XA11 =  xa22 / det;
  XA12 = -xa12 / det;
  XA21 = -xa21 / det;
  XA22 =  xa11 / det;

  // YA part
  double YA11, YA12, YA21, YA22;
  det = ya11*ya22 - ya12*ya21;
  YA11 =  ya22 / det;
  YA12 = -ya12 / det;
  YA21 = -ya21 / det;
  YA22 =  ya11 / det;

  scalar_f [0] = XA11;
  scalar_f [1] = XA12;
  scalar_f [2] = XA21;
  scalar_f [3] = XA22;
  scalar_f [4] = YA11;
  scalar_f [5] = YA12;
  scalar_f [6] = YA21;
  scalar_f [7] = YA22;
}
Example #2
0
/* calc U_i += M(i,j) . F_j
 * INPUT
 *  sys : struct BD_imp
 *  flag_noHI : 1 == no HI
 *              0 == with HI
 *  i, j : particle indices
 *  f[3] : force on particle j
 * OUTPUT
 *  u[3] := M(i,j).f[], the velocity of particle i
 */
static void
mobility_F_atimes (struct stokes *sys, int flag_noHI,
		   int i, int j,
		   const double *f,
		   double *u)
{
  // zero clear
  u[0] = 0;
  u[1] = 0;
  u[2] = 0;

  double ai;
  double aj;
  if (sys->a == NULL)
    {
      ai = 1.0;
      aj = 1.0;
    }
  else
    {
      ai = sys->a[i];
      aj = sys->a[j];
    }

  if (i == j)
    {
      // self
      double self_a = 1.0;
      matrix_f_atimes (f, u,
		       0.0, 0.0, 0.0,
		       self_a, self_a); // a part
    }
  else if (flag_noHI == 0)
    {
      double mob [22];

      double xx
	= sys->pos [j*3  ]
	- sys->pos [i*3  ];
      double yy
	= sys->pos [j*3+1]
	- sys->pos [i*3+1];
      double zz
	= sys->pos [j*3+2]
	- sys->pos [i*3+2];
      double rr = xx * xx + yy * yy + zz * zz;

      double r = sqrt (rr);
      double rmin = (ai + aj) * sys->rmin;
      if (r < rmin) r = rmin;

      double ex = xx / r;
      double ey = yy / r;
      double ez = zz / r;

      // polydisperse code
      scalars_nonewald_poly (0, // F version
			     r,
			     ai, aj,
			     mob);
      scalars_mob_poly_scale_SD (0, // F version
				 ai,
				 mob);
      // now mob is in the SD form

      // note that interaction (i,j) should be for (U[i], F[j])
      matrix_f_atimes (f, u,
		       ex, ey, ez,
		       mob[0], mob[1]); // xa, ya
    }

  /* convert the resultant velocity into the Global scaling
   */
  u[0] /= ai;
  u[1] /= ai;
  u[2] /= ai;
}
Example #3
0
/* calc scalar functions of (M^inf)^-1 in FT for unequal spheres
 * INPUT
 *  r      := x_b - x_a
 *  aa, ab : radius of particle a and b
 * OUTPUT
 *  scalar_ft [20] : scalar functions in dimensional form!
 *      0, 1, 2, 3 : (XA11, XA12, XA21, XA22)
 *      4, 5, 6, 7 : (YA11, YA12, YA21, YA22)
 *      8, 9,10,11 : (YB11, YB12, YB21, YB22)
 *     12,13,14,15 : (XC11, XC12, XC21, XC22)
 *     16,17,18,19 : (YC11, YC12, YC21, YC22)
 */
void
scalars_minv_ft_poly (double r, double aa, double ab,
		      double *scalar_ft)
{
  double mat[16];
  double scalar[11];

  // (12)-interaction
  // scalar[] is in the dimensional form (not the SD scaling)
  scalars_nonewald_poly (1, // FT version
			 r, aa, ab, scalar);
  double xa12, ya12;
  double yb12;
  double xc12, yc12;

  double aa2 = aa * aa;
  double aa3 = aa2 * aa;
  xa12 = scalar [0];
  ya12 = scalar [1];
  yb12 = scalar [2];
  xc12 = scalar [3];
  yc12 = scalar [4];


  // (21)-interaction
  double xa21, ya21;
  double yb21;
  double xc21, yc21;
  double ab2 = ab * ab;
  double ab3 = ab2 * ab;
  /* note:
   * [xy]a12 = [xy]a21 in dimensional form by symmetry
   * [xy]c12 = [xy]c21 in dimensional form by symmetry
   * yb12 = yb21 in dimensional form for M^infty (lack of a dependence)
   * therefore, we do not need to calculate (21)-interaction explicitly
  */
  xa21 = xa12;
  ya21 = ya12;
  yb21 = yb12;
  xc21 = xc12;
  yc21 = yc12;

  double xa11, ya11;
  xa11 = 1.0 / aa;
  ya11 = 1.0 / aa;

  double xa22, ya22;
  xa22 = 1.0 / ab;
  ya22 = 1.0 / ab;

  double xc11, yc11;
  xc11 = 0.75 / aa3;
  yc11 = 0.75 / aa3;

  double xc22, yc22;
  xc22 = 0.75 / ab3;
  yc22 = 0.75 / ab3;

  double det;

  // XA part
  double XA11, XA12, XA21, XA22;
  det = xa11*xa22 - xa12*xa21;
  XA11 =  xa22 / det;
  XA12 = -xa12 / det;
  XA21 = -xa21 / det;
  XA22 =  xa11 / det;

  // XC part
  double XC11, XC12, XC21, XC22;
  det = xc11*xc22 - xc12*xc21;
  XC11 =  xc22 / det;
  XC12 = -xc12 / det;
  XC21 = -xc21 / det;
  XC22 =  xc11 / det;

  // Y part
  double YA11, YA12, YA21, YA22;
  double YB11, YB12, YB21, YB22;
  double YC11, YC12, YC21, YC22;
  mat [0] = ya11; //  ya11
  mat [1] = ya12; //  ya12
  mat [2] = 0.0;  // -yb11
  mat [3] = yb21; //  yb21

  mat [4] = ya21;  //  ya21
  mat [5] = ya22;  //  ya22
  mat [6] = -yb12; // -yb12
  mat [7] = 0.0;   //  yb22

  mat [8] = 0.0;   // -yb11
  mat [9] = -yb12; // -yb12
  mat[10] = yc11;  //  yc11
  mat[11] = yc12;  //  yc12

  mat[12] = yb21; // yb21
  mat[13] = 0.0;  // yb22
  mat[14] = yc21; // yc21
  mat[15] = yc22; // yc22

  lapack_inv_ (4, mat);
  YA11 =  mat [0];
  YA12 =  mat [1];
  YA21 =  mat [4];
  YA22 =  mat [5];
  YB11 = -mat [8];
  YB12 = -mat [9];
  YB21 =  mat[12];
  YB22 =  mat[13];
  YC11 =  mat[10];
  YC12 =  mat[11];
  YC21 =  mat[14];
  YC22 =  mat[15];

  scalar_ft [0] = XA11;
  scalar_ft [1] = XA12;
  scalar_ft [2] = XA21;
  scalar_ft [3] = XA22;
  scalar_ft [4] = YA11;
  scalar_ft [5] = YA12;
  scalar_ft [6] = YA21;
  scalar_ft [7] = YA22;
  scalar_ft [8] = YB11;
  scalar_ft [9] = YB12;
  scalar_ft[10] = YB21;
  scalar_ft[11] = YB22;
  scalar_ft[12] = XC11;
  scalar_ft[13] = XC12;
  scalar_ft[14] = XC21;
  scalar_ft[15] = XC22;
  scalar_ft[16] = YC11;
  scalar_ft[17] = YC12;
  scalar_ft[18] = YC21;
  scalar_ft[19] = YC22;
}