/** * Create the testdata used in the benchmark. * * @param nbody the number of bodies to create */ public void createTestData(int nbody) { MathVector cmr = MathVector.makeMathVector(); MathVector cmv = MathVector.makeMathVector(); bodyTab = new List <Body>(); double rsc = 3.0 * 3.1415 / 16.0; double vsc = Math.Sqrt(1.0 / rsc); double seed = 123.0; int k; for (int i = 0; i < nbody; i++) { Body p = Body.makeBody(); bodyTab.Add(p); p.mass = 1.0 / (double)nbody; seed = BH.myRand(seed); double t1 = BH.xRand(0.0, 0.999, seed); t1 = Math.Pow(t1, (-2.0 / 3.0)) - 1.0; double r = 1.0 / Math.Sqrt(t1); double coeff = 4.0; for (k = 0; k < MathVector.NDIM; k++) { seed = BH.myRand(seed); r = BH.xRand(0.0, 0.999, seed); p.pos.setValue(k, coeff * r); } cmr.addition(p.pos); double x = 0.0; double y = 0.0; do { seed = BH.myRand(seed); x = BH.xRand(0.0, 1.0, seed); seed = BH.myRand(seed); y = BH.xRand(0.0, 0.1, seed); } while(y > x * x * Math.Pow(1.0 - x * x, 3.5)); double v = Math.Sqrt(2.0) * x / Math.Pow(1.0 + r * r, 0.25); double rad = vsc * v; double rsq = 0.0; do { for (k = 0; k < MathVector.NDIM; k++) { seed = BH.myRand(seed); p.vel.setValue(k, BH.xRand(-1.0, 1.0, seed)); } rsq = p.vel.dotProduct(); } while(rsq > 1.0); double rsc1 = rad / Math.Sqrt(rsq); p.vel.multScalar1(rsc1); cmv.addition(p.vel); } cmr.divScalar((double)nbody); cmv.divScalar((double)nbody); this.bodyTabRev = new List <Body>(); for (int j = 0; j < this.bodyTab.Count; ++j) { Body b = this.bodyTab[j]; b.pos.subtraction1(cmr); b.vel.subtraction1(cmv); this.bodyTabRev.Add(b); } }