55 static scalar
minimaxs(
const scalar P)
59 static const scalar a[] =
67 static const scalar
b[] =
79 - (a[0] + t*(a[1] + t*(a[2] + t*a[3])))
80 /(1 + t*(
b[0] + t*(
b[1] + t*(
b[2] + t*
b[3]))));
82 return P < 0.5 ? -
s :
s;
86 static scalar
Sn(
const scalar a,
const scalar
x)
93 for (
int i=1; i<100; i++)
105 static scalar
R(
const scalar a,
const scalar
x)
120 const scalar Q = 1 - P;
131 const scalar Ga = tgamma(a);
132 const scalar
B = Q*Ga;
134 if (
B > 0.6 || (
B >= 0.45 && a >= 0.3))
138 (
B*Q > 1
e-8) ?
pow(P*Ga*a, 1/a) :
exp((-Q/a) -
Eu);
140 x = u/(1 - (u/(a + 1)));
142 else if (a < 0.3 && B >= 0.35)
145 const scalar t =
exp(-
Eu -
B);
146 const scalar u = t*
exp(t);
150 else if (
B > 0.15 || a >= 0.3)
153 const scalar
y = -
log(
B);
154 const scalar u =
y - (1 - a)*
log(
y);
156 x =
y - (1 - a)*
log(u) -
log(1 + (1 - a)/(1 + u));
161 const scalar
y = -
log(
B);
162 const scalar u =
y - (1 - a)*
log(
y);
169 (
sqr(u) + 2*(3 - a)*u + (2 - a)*(3 - a))
170 /(
sqr(u) + (5 - a)*u + 2)
176 const scalar
y = -
log(
B);
177 const scalar
c1 = (a - 1)*
log(
y);
178 const scalar c12 =
c1*
c1;
179 const scalar c13 = c12*
c1;
180 const scalar c14 = c12*c12;
181 const scalar a2 = a*a;
182 const scalar a3 = a2*a;
183 const scalar
c2 = (a - 1)*(1 +
c1);
184 const scalar c3 = (a - 1)*(-(c12/2) + (a - 2)*
c1 + (3*a - 5)/2);
191 + (11*a2 - 46*a + 47)/6
196 + (-3*a2 + 13*a - 13)*c12
197 + (2*a3 - 25*a2 + 72*a - 61)*
c1/2
198 + (25*a3 - 195*a2 + 477*a - 379)/12);
199 const scalar y2 =
y*
y;
200 const scalar y3 = y2*
y;
201 const scalar y4 = y2*y2;
203 x =
y +
c1 + (
c2/
y) + (c3/y2) + (c4/y3) + (c5/y4);
217 const scalar s2 =
sqr(
s);
218 const scalar s3 =
s*s2;
219 const scalar s4 = s2*s2;
220 const scalar s5 =
s*s4;
221 const scalar sqrta =
sqrt(a);
224 a +
s*sqrta + (s2 - 1)/3
225 + (s3 - 7*
s)/(36*sqrta)
226 - (3*s4 + 7*s2 - 16)/(810*a)
227 + (9*s5 + 256*s3 - 433*
s)/(38880*a*sqrta);
230 if (a >= 100 &&
mag(1 - w/a) < 1
e-4)
235 if (a >= 500 &&
mag(1 - w/a) < 1
e-6)
247 const scalar
D =
max(scalar(2), scalar(a*(a - 1)));
248 const scalar lnGa =
lgamma(a);
249 const scalar lnB =
log(Q) + lnGa;
254 const scalar
y = -lnB;
255 const scalar
c1 = (a - 1)*
log(
y);
256 const scalar c12 =
c1*
c1;
257 const scalar c13 = c12*
c1;
258 const scalar c14 = c12*c12;
259 const scalar a2 = a*a;
260 const scalar a3 = a2*a;
262 const scalar
c2 = (a - 1)*(1 +
c1);
276 + (11*a2 - 46*a + 47)/6
283 + (-3*a2 + 13*a - 13)*c12
284 + (2*a3 - 25*a2 + 72*a - 61)*
c1/2
285 + (25*a3 - 195*a2 + 477*a - 379)/12
288 const scalar y2 =
y*
y;
289 const scalar y3 = y2*
y;
290 const scalar y4 = y2*y2;
292 x =
y +
c1 + (
c2/
y) + (c3/y2) + (c4/y3) + (c5/y4);
298 -lnB + (a - 1)*
log(w) -
log(1 + (1 - a)/(1 + w));
300 x = -lnB + (a - 1)*
log(u) -
log(1 + (1 - a)/(1 + u));
307 const scalar ap1 = a + 1;
312 const scalar ap2 = a + 2;
315 s = log1p(z/ap1*(1 + z/ap2));
316 z =
exp((v + z -
s)/a);
317 s = log1p(z/ap1*(1 + z/ap2));
318 z =
exp((v + z -
s)/a);
319 s = log1p(z/ap1*(1 + z/ap2*(1 + z/(a + 3))));
320 z =
exp((v + z -
s)/a);
324 if (z < 0.006*ap1 && (a > 1 || a < 100 ||
mag(1 - w/a) > 1
e-4))
329 if (z <= 0.01*ap1 || z > 0.7*ap1)
336 const scalar lnSn =
log(
Sn(a, z));
338 z =
exp((v + z - lnSn)/a);
340 x = z*(1 - (a*
log(z) - z - v + lnSn)/(a - z));
346 static const label nIter = 20;
347 static const scalar eps = 1
e-10;
348 static const scalar tau = 1
e-5;
350 for (
label iter = 0; iter < nIter; ++ iter)
353 const scalar t = dP/
max(
R(a,
x), vSmall);
354 const scalar w = (a - 1 -
x)/2;
356 bool halley =
mag(t) < 0.1 &&
mag(w*t) < 0.1;
358 const scalar
h = t + halley*w*
sqr(t);
364 (halley &&
mag(w) >= 1 &&
mag(w*
sqr(t)) <= eps)
366 || (
mag(
h) < tau &&
mag(dP) < tau*
max(P, 1 - P))
static const Foam::dimensionedScalar B("B", Foam::dimless, 18.678)
static const Foam::dimensionedScalar D("D", Foam::dimTemperature, 257.14)
gmvFile<< "tracers "<< particles.size()<< nl;forAllConstIter(Cloud< passiveParticle >, particles, iter){ gmvFile<< iter().position().x()<< " ";}gmvFile<< nl;forAllConstIter(Cloud< passiveParticle >, particles, iter){ gmvFile<< iter().position().y()<< " ";}gmvFile<< nl;forAllConstIter(Cloud< passiveParticle >, particles, iter){ gmvFile<< iter().position().z()<< " ";}gmvFile<< nl;forAll(lagrangianScalarNames, i){ word name=lagrangianScalarNames[i];IOField< scalar > s(IOobject(name, runTime.name(), cloud::prefix, mesh, IOobject::MUST_READ, IOobject::NO_WRITE))
const scalar Eu(0.57721566490153286060651209)
Euler's constant.
const dimensionedScalar c1
First radiation constant: default SI units: [W/m^2].
const dimensionedScalar c2
Second radiation constant: default SI units: [m K].
const dimensionedScalar h
Planck constant.
dimensionedScalar exp(const dimensionedScalar &ds)
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
dimensionedScalar lgamma(const dimensionedScalar &ds)
dimensionedSymmTensor sqr(const dimensionedVector &dv)
static scalar minimaxs(const scalar P)
dimensionedScalar log(const dimensionedScalar &ds)
dimensionedScalar pow(const dimensionedScalar &ds, const dimensionedScalar &expt)
scalar invIncGammaRatio_P(const scalar a, const scalar P)
Inverse normalised lower incomplete gamma function.
dimensionedScalar sqrt(const dimensionedScalar &ds)
dimensioned< scalar > mag(const dimensioned< Type > &)
layerAndWeight max(const layerAndWeight &a, const layerAndWeight &b)
static scalar R(const scalar a, const scalar x)
scalar incGammaRatio_P(const scalar a, const scalar x)
Normalised lower incomplete gamma function.
static scalar Sn(const scalar a, const scalar x)