Solution verification indicators
solution_verification_indicators
¶
Functions:¶
compute_c
¶
compute_c(e_q_j, gamma_j_1, gamma_j, beta)
Compute constant \(C\).
Parameters:
-
e_q_j–The error expansion (\(q_{exact} - q_j\)) for grid j.
-
gamma_j_1–The relative element size for grid j+1.
-
gamma_j–The relative element size for grid j.
-
beta–The convergence order.
Returns:
-
–
The constant \(C\).
Source code in src\vimseo\tools\verification\solution_verification_indicators.py
52 53 54 55 56 57 58 59 60 61 62 63 64 | |
compute_gci
¶
compute_gci(fs, h, q, beta, starting_mesh_id)
The Grid Convergence Index.
Computed from the two finest meshes.
Parameters:
-
fs–The safety factor.
-
h–The element sizes, from coarse to fine.
-
q–The output value corresponding to each element size.
-
beta–The convergence order.
-
starting_mesh_id–The GCI is computed based on q[starting_mesh_id] and
Returns:
-
–
A tuple where first element is the Grid Convergence Index, and second element is the GCI-based error band on the solution.
Source code in src\vimseo\tools\verification\solution_verification_indicators.py
229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 | |
compute_median
¶
compute_median(q: ndarray, q_ref: float)
Estimate the extrapolated value at element size = 0.
The uncertainty is computed from the Median Absolute Deviation (MAD).
Parameters:
-
q(ndarray) –The model output values.
-
q_ref(float) –A reference value in which we have most confidence. The final
Returns:
-
–
A tuple where first element is the estimate of the extrapolated value, and second is the MAD.
Source code in src\vimseo\tools\verification\solution_verification_indicators.py
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 | |
compute_q_extrap
¶
compute_q_extrap(j, c, q, gamma, beta)
Compute the extrapolated value at element size = 0.
Parameters:
-
j–The grid index.
-
c–The \(C\) constant.
-
q–The model solution array indexed for j.
-
gamma–The relative element size array indexed for j.
-
beta–The convergence order.
Returns:
-
–
The extrapolated value of the model solution at element size = 0.
Source code in src\vimseo\tools\verification\solution_verification_indicators.py
67 68 69 70 71 72 73 74 75 76 77 78 79 80 | |
compute_rde
¶
compute_rde(fs, h, q, q_extrap, beta, i)
The Relative Discretisation Index (RDE).
Computed from the two finest meshes.
Parameters:
-
fs–The safety factor.
-
h–The element sizes, from coarse to fine.
-
q–The output value corresponding to each element size.
-
beta–The convergence order.
-
q_extrap–The Richardson extrapolation.
-
i–The index at which RDE is computed, from fine to coarse.
Returns:
-
–
A tuple where first element is the RDE, and second element is the RDE-based error band on the solution for the finest grid.
Source code in src\vimseo\tools\verification\solution_verification_indicators.py
257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 | |
compute_richardson
¶
compute_richardson(h, q)
Compute Richardson extrapolation.
Parameters:
-
h–The array of element sizes.
-
q–The array of model solutions.
Returns:
-
–
The Richardson extrapolation of q at element size = 0.
Source code in src\vimseo\tools\verification\solution_verification_indicators.py
83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 | |
cross_validated_mad
¶
cross_validated_mad(values: ndarray) -> tuple[float, float]
Median and scaled MAD of a set of cross-validation fold estimates.
Non-finite fold estimates (e.g. folds where a palliative could not be
computed) are ignored. Returns (nan, nan) if no finite value is left.
Parameters:
-
values(ndarray) –The per-fold estimates of a converged value.
Returns:
-
tuple[float, float]–The median across folds and the associated uncertainty band (
1.4826 * MAD).
Source code in src\vimseo\tools\verification\solution_verification_indicators.py
207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 | |
fit_power_law
¶
fit_power_law(
h: ndarray,
q: ndarray,
order_bounds: tuple[float, float] = (0.1, 4.0),
) -> tuple[float, float, float, float]
Least-squares power-law fit of the convergence, as a robust alternative to Richardson.
The model :math:q(h) = q_\infty + C\,h^p is fitted over all grids by
least squares, with the convergence order :math:p treated as a fitted
parameter (it is not assumed). Compared with :func:compute_richardson, which
solves an exact three-point equation and returns nan as soon as one triplet
is not power-law convergent, this fit:
- uses every grid, so isolated noise does not destroy the estimate;
- never raises: if the optimisation does not converge (for instance on
strongly non-monotone "sawtooth" data) it returns
nanvalues instead; - reports a residual, which quantifies how power-law the convergence actually is (a large residual flags an unreliable extrapolation).
Parameters:
-
h(ndarray) –The element sizes.
-
q(ndarray) –The model solutions for each element size.
-
order_bounds(tuple[float, float], default:(0.1, 4.0)) –The lower and upper bounds constraining the search for the convergence order
p. These bound the optimisation only; they do not assume a particular order.
Returns:
-
tuple[float, float, float, float]–The converged value :math:
q_\infty, the fitted order :math:p, the coefficient :math:Cand the RMS residual of the fit. Allnanif the fit does not converge.
Source code in src\vimseo\tools\verification\solution_verification_indicators.py
122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 | |
robust_converged_value
¶
robust_converged_value(
q: ndarray, n_finest: int = 3
) -> tuple[float, float]
Model-free estimate of the converged value from the finest grids.
The converged value is taken as the median of the n_finest finest-grid
outputs and its uncertainty as their scaled median absolute deviation (MAD).
This estimate assumes no convergence order at all, never fails, and is well
suited to non-monotone ("sawtooth") convergence: the true value then lies near
the centre of the oscillation envelope, which the median captures while the
spread reports the residual mesh sensitivity.
Parameters:
-
q(ndarray) –The model solutions, ordered from the coarsest to the finest grid (the finest grids are the last entries, following the tool convention).
-
n_finest(int, default:3) –The number of finest grids used for the estimate.
Returns:
-
tuple[float, float]–The converged value and its uncertainty band (
1.4826 * MAD).
Source code in src\vimseo\tools\verification\solution_verification_indicators.py
182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 | |