Exemple #1
0
        //--------------------------------------------------------------------
        private void EmtsIniGtb(int Ei)
        {
            int k; double Rr, xx, x; CElement ei = Ev[Ei];

            Rr = Rb * Rb; do
            {
                xx = 0D; for (k = 0; k < Rn; k++)
                {
                    ei.X[k] = x = Rb * 2D * (Rd.NextDouble() - 0.5D);
                    xx     += x * x;
                }
            }while (xx >= Rr);
        }//Set random coordinates of Ex element within bound
Exemple #2
0
 CElement[] Ev; //Elements container
 //--------------------------------------------------------------------
 private void EmtsIni()
 {
     //Allocate resources
     try
     {
         Ev = new CElement[En]; for (int i = 0; i < En; i++)
         {
             Ev[i] = new CElement();
         }
     }
     catch (Exception e)
     {
         e.Source = "EmtsIni";
         Ev       = null;
         return;
     }
     //Allocate resources
     for (int i = 0; i < En; i++)
     {
         if (Ev[i].Dim(Rn))
         {
             //throw exeption
             Ev = null;
             return;
         }
     }
     //init elements
     for (int i = 0; i < En; i++)
     {
         //Set Radius of element
         Ev[i].R = Re * (1D + 0.01 * dR * 2D * (Rd.NextDouble() - 0.5D));
         //Set mass
         Ev[i].M = Vgamma(Rn);
         for (int k = 0; k < Rn; k++)
         {
             Ev[i].M *= Ev[i].R;
         }
         //Set coordinates, random value
         EmtsIniGtb(i);
         //set speed, random value
         double V = 1D / Math.Sqrt(Rn * Ev[i].M);
         for (int k = 0; k < Rn; k++)
         {
             Ev[i].V[k] = V * 2D * (Rd.NextDouble() - 0.5D);
         }
     }
 }