HomeFeaturesExamplesTutorialsHelpTheoryVerificationPricingContact
Theory manual

10. Parametric studies and Monte Carlo

Both study engines run the simulation (Chapter 8) or the sizing (Chapter 9) many times on modified copies of the project; they add no physics. The program shows the results as line, heat-map, tornado, histogram, sensitivity and convergence charts and can apply the length at 95 % confidence to the design; the study setups are stored with the project.

10.1 Parameter registry

Every study input is a registered scalar with a stable identifier (ground conductivity, thickness of layer i, borehole spacing, heating-load scale, …), read and written in SI units, with a display unit and sanity bounds. A value outside the bounds makes that run fail with a message, never the study. Parameters that do more than assign a value: the borehole length sets the mean length (unequal lengths scale in proportion); the spacing regenerates a generated layout with B1=B2=B and scales a custom layout about its centroid; the load scales multiply the energies (or all peaks). Applying a parameter's current value leaves the project unchanged bit for bit.

10.2 Parametric study

A range is an explicit list or vk=vmin+kΔv up to vmax. A full grid of up to three parameters runs every combination, the last parameter varying fastest:

k=(i0n1+i1)n2+i2,N=n0n1n2
(10.1)

A one-at-a-time study runs the project itself, then each parameter's values with the others at their project values, N=1+∑ana; the spread of a result over one parameter's runs is its bar in a tornado chart. In Size mode every run is a sizing (Chapter 9), in Simulate mode a simulation at the current lengths. For the example, a conductivity sweep from 1.5 to 4.0 W/(m K) in Size mode gives 178.1 m down to 117.3 m per borehole.

10.3 Sampling

Samples are drawn by inverse transform, x=F−1(u). With Latin-hypercube sampling (McKay et al. 1979), for each input j an independent random permutation πj of 0…N−1 and a uniform jitter vij∈[0,1) place exactly one sample in each of N equally probable strata:

uij=πj(i)+vijN
(10.2)

Truncation to [xlo,xhi] samples the truncated distribution exactly and keeps the strata equiprobable:

x=F−1(F(xlo)+u[F(xhi)−F(xlo)])
(10.3)
Table 17. Distributions of the uncertain inputs. Φ−1: Acklam's rational approximation refined by one Halley step (full double precision). A zero spread is a point mass.
Distributiona, b, cInverse CDF F−1(u)
Normalmean μ, sd σμ+σΦ−1(u)
LogNormalmedian m, σlnmexp(σlnΦ−1(u))
Uniformmin a, max ba+(b−a)u
Triangularmin a, mode b, max ca+u(c−a)(b−a) for u<(b−a)/(c−a), else c−(1−u)(c−a)(c−b)

The N × k matrix of samples is drawn serially from one 64-bit Mersenne Twister seeded by the user before any run starts, with uniform variates from its top 53 bits and integers by rejection (not the implementation-defined distributions of the language's standard library). The samples, and therefore the results, are the same on every compiler and for any number of threads. Target rank correlations between inputs are imposed by the Iman–Conover method (1982): van der Waerden scores are reordered so that their Pearson correlation is

Cij=2sin(πρs,ij6)
(10.4)

and each input column takes the ranks of its score column; the marginal distributions and the LHS strata are unchanged.

10.4 Statistics

Percentiles interpolate linearly between the sorted results x(0)≤…≤x(n−1) (Hyndman & Fan 1996, type 7):

Pp=x(⌊h⌋)+(h−⌊h⌋)(x(⌊h⌋+1)−x(⌊h⌋)),h=p100(n−1)
(10.5)

Mean, sample standard deviation, P5 … P95 are taken over the successful runs. In Size mode P90 and P95 of H are the lengths that meet the limits with 90 % and 95 % confidence under the stated input uncertainty. Histograms use the Freedman–Diaconis bin width 2IQRn−1/3. The sensitivity ranking is Spearman's rank correlation, the Pearson correlation of the ranks r(xi), r(yi) with ties at their average rank:

ρs=∑i(r(xi)−r¯x)(r(yi)−r¯y)∑i(r(xi)−r¯x)2∑i(r(yi)−r¯y)2
(10.6)

A percentile from N runs is itself uncertain. The distribution-free confidence interval between the order statistics x(r) and x(s) (1-based) has the coverage

P(x(r)≤Qp≤x(s))=∑k=rs−1N!k!(N−k)!pk(1−p)N−k
(10.7)

For N = 1000 and p = 0.95 the 95 % interval is x(937) … x(964), that is P93.7 … P96.4.

10.5 Example and cost

The Monte Carlo example of the office project stores a setup of 1000 Latin-hypercube samples (seed 1) in Size mode with four uncertain inputs: the ground conductivity N(2.6, 0.3) W/(m K) truncated to [1.5, 4.0], the heat capacity U(2.0, 2.6) MJ/(m³ K), the surface temperature N(9.0, 0.5) °C and the heating energy T(0.9, 1.0, 1.15) times the design value. Figure 9 shows the result: H has a median of 145.1 m (the mean inputs give 143.7 m), P90 = 158.6 m and P95 = 163.5 m per borehole, with 0 failed runs. The rank correlations with H are −0.70 for λ, −0.51 for Ts, +0.45 for the heating energy and −0.15 for C. In Simulate mode, at the design length of 150 m, the same inputs meet the limits with a probability of 68 %.

Monte Carlo analysis of the office example: (a) histogram of the required length with P50, P90 and P95; (b) Spearman rank correlation of each input with the length.
Figure 9. Monte Carlo analysis of the office example: (a) histogram of the required length with P50, P90 and P95; (b) Spearman rank correlation of each input with the length.

g-function memo. Most inputs (loads, SPF, limits, fluid, pipes, grout, Ts, qgeo) do not change the g-function, which dominates a monthly simulation. In Simulate mode the runner therefore computes each distinct g-function once: runs that share the geometry, the g-function options and the whole ground model share an exactly computed g-function (bit-identical results); runs of one geometry that differ only in α share one g-function tabulated over the union of their ln(t/ts) ranges and rescaled through ts (0.5–2.2 mK difference, measured). The segmented and advective models are excluded. Size mode uses the sizing's own g-function cache. The 1000-sample analysis above took 9.9 s (Size mode, all threads); in Simulate mode it takes a fraction of a second.