SHARE
TWEET

Untitled

a guest May 5th, 2012 17 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. double f2(double u, double z, double r, double z0, double h)
  2. {
  3.         double Kp, Ep; // Elliptic
  4.         double p, x;
  5.         double sechsqr, zz0;
  6.         x = (r * r + u * u + z * z) / (2.0 * r * u);
  7.         p = x - sqrt(x*x - 1.0);
  8.         zz0 = z / z0;
  9.         sechsqr = 2.0 / (Exp(zz0) + Exp(-zz0))
  10.         sechsqr *= sechsqr;
  11.        
  12.         // Kp, Ep = ? (alglib)
  13.         // ...
  14.         //
  15.        
  16.     return (u * sechsqr * (Kp - Ep) / sqrt(u * p));
  17. }
  18.  
  19. // x = du, y = dz, z = f
  20. double MMC2D(double N, double r, double z0, double h, double XBEGINVALUE, double YBEGINVALUE, double ZBEGINVALUE, double XENDVALUE, double YENDVALUE, double ZENDVALUE)
  21. {
  22.                
  23.         double du, dz, f;
  24.         double result;
  25.  
  26.         double r = 0;
  27.         double ratio = 0.0;
  28.                 Random rndt= new Random(1243);
  29.                 rndt.Next();
  30.                 Random rnd = new Random(rndt);
  31.  
  32.         for(double i = 0; i < N; i++)
  33.         {
  34.                                
  35.                 du = XBEGINVALUE + Math.Tan(XENDVALUE*rnd.NextDouble());
  36.                 dz = YBEGINVALUE + Math.Tan(YENDVALUE*rnd.NextDouble());
  37.                                 f  = ZBEGINVALUE + ZENDVALUE*rnd.NextDouble();
  38.  
  39.                 r += (f <= f2(du, dz, r, z0, h)) ? 1.0 : 0.0;
  40.  
  41.                 //uncomment below to enter the matrix!
  42.                 //ratio = (double)r/(double)i;
  43.                 //std::cout << "Iteration: " << i << "\tArea: " << ratio*2.0 << "\tRatio: " << ratio << "\tx: " << x << "\ty: " << y << std::endl;
  44.         }
  45.         ratio = r/N;
  46. //              cout.precision(12);
  47. //        std::cout << "Ratio: " << ratio << std::endl;
  48. //        std::cout << "\nResult: " << (DIMENSIONS-1)*ratio*(XENDVALUE-XBEGINVALUE)*(YENDVALUE-YBEGINVALUE) << std::endl;
  49.                 result = ratio * (XENDVALUE - XBEGINVALUE) * (YENDVALUE - YBEGINVALUE) * (ZENDVALUE - ZBEGINVALUE);
  50.  
  51.         return result;
  52. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top