hydr-structures 0.2.0

Hydraulic structures for the hydr simulation crates
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
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
114
115
116
117
118
119
120
121
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
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
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
255
256
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
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
//! Constructors of the barrels built from tangent circular arcs.
//!
//! Each derived radius follows from tangency of neighbouring arcs. The closed forms keep every
//! difference between positive terms:
//!
//! | Shape | Derived radius |
//! | --- | --- |
//! | Horizontal ellipse | `R = r_c + (x_c^2 + e^2) / (2 e)`, `x_c = B/2 - r_c`, `e = D/2 - r_c` |
//! | Vertical ellipse | `r_c = r + (f^2 + e^2) / (2 f)`, `f = B/2 - r`, `e = D/2 - r` |
//! | Pipe-arch | `r_t = r_c + (x_c^2 + g^2) / (2 g)`, `g = D - y_c - r_c`, `y_c = r_b - h` |
//! | Flat-floor arch | `r = (B^2/4 + D^2) / (2 D)` |
//!
//! The pipe-arch corner centres sit at height `y_c`, with
//! `h^2 = (r_b - B/2) (r_b + B/2 - 2 r_c)`. Its rules on `y_c` hold for the exact section:
//! the host enclosure certifies them, so the kernel enclosures of the same forms agree.
//!
//! The rules and derived radii are evaluated in a [`Frame`] that scales the rise into `[1, 2)`
//! by a power of two. Every rule is homogeneous in length, so it holds in the frame exactly when
//! it holds in metres, and no square or product underflows or overflows there.

use super::enclosure::Enclosure;
use super::frame::Frame;
use super::{CulvertBarrel, CulvertBarrelShape, dimension, scales};
use crate::structures::StructureError;

impl CulvertBarrel {
    /// Admits a four-arc horizontal ellipse of span `span_m`, rise `rise_m` and side radius
    /// `side_radius_m`.
    ///
    /// The invert and crown arcs share one radius, derived from tangency. Rejects a span at or
    /// below the rise and a side radius at or above half the rise. Also rejects as the box
    /// constructor does, and when a radius cubed, scaled by 64, overflows F64.
    pub fn horizontal_ellipse(
        span_m: f64,
        rise_m: f64,
        side_radius_m: f64,
    ) -> Result<Self, StructureError> {
        dimension("span_m", "span", span_m)?;
        dimension("rise_m", "rise", rise_m)?;
        dimension("side_radius_m", "side radius", side_radius_m)?;
        if span_m <= rise_m {
            return Err(StructureError::definition(format!(
                "span_m={span_m:?},rise_m={rise_m:?}: a horizontal ellipse needs span above rise. Use vertical_ellipse for a rise above the span"
            )));
        }
        if side_radius_m >= 0.5 * rise_m {
            return Err(StructureError::definition(format!(
                "rise_m={rise_m:?},side_radius_m={side_radius_m:?}: a horizontal ellipse needs a side radius below half the rise. Supply a smaller side radius"
            )));
        }
        let fields = format!("span_m={span_m:?},rise_m={rise_m:?},side_radius_m={side_radius_m:?}");
        scales(span_m, rise_m, &[("side", side_radius_m)], &fields)?;
        let frame = Frame::new(rise_m, &[span_m, side_radius_m], &fields)?;
        let radius = ellipse_radius(
            frame.scaled(span_m),
            frame.scaled(rise_m),
            frame.scaled(side_radius_m),
        );
        scales(
            span_m,
            rise_m,
            &[("invert and crown", frame.back(radius.upper))],
            &fields,
        )?;
        Ok(Self::new(
            CulvertBarrelShape::HorizontalEllipse,
            span_m,
            rise_m,
            &[side_radius_m],
        ))
    }

    /// Admits a four-arc vertical ellipse of span `span_m`, rise `rise_m` and end radius
    /// `end_radius_m`.
    ///
    /// The two side arcs share one radius, derived from tangency. Rejects a rise at or below
    /// the span and an end radius at or above half the span. Also rejects as the box
    /// constructor does, and when a radius cubed, scaled by 64, overflows F64.
    pub fn vertical_ellipse(
        span_m: f64,
        rise_m: f64,
        end_radius_m: f64,
    ) -> Result<Self, StructureError> {
        dimension("span_m", "span", span_m)?;
        dimension("rise_m", "rise", rise_m)?;
        dimension("end_radius_m", "end radius", end_radius_m)?;
        if rise_m <= span_m {
            return Err(StructureError::definition(format!(
                "span_m={span_m:?},rise_m={rise_m:?}: a vertical ellipse needs rise above span. Use horizontal_ellipse for a span above the rise"
            )));
        }
        if end_radius_m >= 0.5 * span_m {
            return Err(StructureError::definition(format!(
                "span_m={span_m:?},end_radius_m={end_radius_m:?}: a vertical ellipse needs an end radius below half the span. Supply a smaller end radius"
            )));
        }
        let fields = format!("span_m={span_m:?},rise_m={rise_m:?},end_radius_m={end_radius_m:?}");
        scales(span_m, rise_m, &[("end", end_radius_m)], &fields)?;
        let frame = Frame::new(rise_m, &[span_m, end_radius_m], &fields)?;
        // The side radius is the horizontal-ellipse radius of the section turned a quarter turn.
        let radius = ellipse_radius(
            frame.scaled(rise_m),
            frame.scaled(span_m),
            frame.scaled(end_radius_m),
        );
        scales(
            span_m,
            rise_m,
            &[("side", frame.back(radius.upper))],
            &fields,
        )?;
        Ok(Self::new(
            CulvertBarrelShape::VerticalEllipse,
            span_m,
            rise_m,
            &[end_radius_m],
        ))
    }

    /// Admits a pipe-arch of span `span_m`, rise `rise_m`, corner radius `corner_radius_m` and
    /// bottom radius `bottom_radius_m`.
    ///
    /// The top radius is derived from tangency. Rejects a corner radius at or above half the
    /// span, a bottom radius at or below half the span, a rise at or below the corner-centre
    /// height plus the corner radius, and a rise above the corner centres of more than half
    /// the span, which would put the widest point on the top arc. Also rejects as the box
    /// constructor does, and when a radius cubed, scaled by 64, overflows F64.
    pub fn pipe_arch(
        span_m: f64,
        rise_m: f64,
        corner_radius_m: f64,
        bottom_radius_m: f64,
    ) -> Result<Self, StructureError> {
        dimension("span_m", "span", span_m)?;
        dimension("rise_m", "rise", rise_m)?;
        dimension("corner_radius_m", "corner radius", corner_radius_m)?;
        dimension("bottom_radius_m", "bottom radius", bottom_radius_m)?;
        if corner_radius_m >= 0.5 * span_m {
            return Err(StructureError::definition(format!(
                "span_m={span_m:?},corner_radius_m={corner_radius_m:?}: a pipe-arch needs a corner radius below half the span. Supply a smaller corner radius"
            )));
        }
        if bottom_radius_m <= 0.5 * span_m {
            return Err(StructureError::definition(format!(
                "span_m={span_m:?},bottom_radius_m={bottom_radius_m:?}: a pipe-arch needs a bottom radius above half the span. Supply a larger bottom radius"
            )));
        }
        let fields = format!(
            "span_m={span_m:?},rise_m={rise_m:?},corner_radius_m={corner_radius_m:?},bottom_radius_m={bottom_radius_m:?}"
        );
        let given = [("corner", corner_radius_m), ("bottom", bottom_radius_m)];
        scales(span_m, rise_m, &given, &fields)?;
        let frame = Frame::new(rise_m, &[span_m, corner_radius_m, bottom_radius_m], &fields)?;
        let rise = frame.scaled(rise_m);
        let corner = frame.scaled(corner_radius_m);
        let layout = PipeArch::new(
            frame.scaled(span_m),
            rise,
            corner,
            frame.scaled(bottom_radius_m),
        );
        if layout.gap.lower.is_nan() || layout.gap.lower <= 0.0 {
            let top = Enclosure::exact(corner).add(layout.corner_height);
            let top = frame.back_enclosure(top);
            return Err(StructureError::definition(format!(
                "{fields}: a pipe-arch needs a rise above the corner-centre height plus the corner radius, [{:?}, {:?}] m. Supply a larger rise or a larger bottom radius",
                top.lower, top.upper
            )));
        }
        if layout.reach.lower.is_nan() || layout.reach.lower < 0.0 {
            let above = Enclosure::exact(rise).sub(layout.corner_height);
            let above = frame.back_enclosure(above);
            return Err(StructureError::definition(format!(
                "{fields}: a pipe-arch needs the rise above the corner centres, [{:?}, {:?}] m, at most half the span. Supply a smaller rise or a smaller bottom radius",
                above.lower, above.upper
            )));
        }
        let top = layout.top_radius();
        scales(span_m, rise_m, &[("top", frame.back(top.upper))], &fields)?;
        Ok(Self::new(
            CulvertBarrelShape::PipeArch,
            span_m,
            rise_m,
            &[corner_radius_m, bottom_radius_m],
        ))
    }

    /// Admits a flat-floor arch of floor chord `span_m` and rise `rise_m`.
    ///
    /// The arc radius is derived. Rejects a rise above the span or below a quarter of the
    /// span. Also rejects as the box constructor does.
    pub fn arch(span_m: f64, rise_m: f64) -> Result<Self, StructureError> {
        dimension("span_m", "span", span_m)?;
        dimension("rise_m", "rise", rise_m)?;
        if rise_m > span_m {
            return Err(StructureError::definition(format!(
                "span_m={span_m:?},rise_m={rise_m:?}: a flat-floor arch needs a rise of at most the span. Supply a rise between a quarter of the span and the span"
            )));
        }
        if rise_m < 0.25 * span_m {
            return Err(StructureError::definition(format!(
                "span_m={span_m:?},rise_m={rise_m:?}: a flat-floor arch needs a rise of at least a quarter of the span. Supply a rise between a quarter of the span and the span"
            )));
        }
        let fields = format!("span_m={span_m:?},rise_m={rise_m:?}");
        scales(span_m, rise_m, &[], &fields)?;
        let frame = Frame::new(rise_m, &[span_m], &fields)?;
        let radius = arch_radius(frame.scaled(span_m), frame.scaled(rise_m));
        scales(
            span_m,
            rise_m,
            &[("arc", frame.back(radius.upper))],
            &fields,
        )?;
        Ok(Self::new(CulvertBarrelShape::Arch, span_m, rise_m, &[]))
    }
}

/// Encloses `R = r_c + (x_c^2 + e^2) / (2 e)` of a horizontal ellipse.
fn ellipse_radius(span_m: f64, rise_m: f64, side_m: f64) -> Enclosure {
    let half = Enclosure::exact(span_m).mul(Enclosure::exact(0.5));
    let half_rise = Enclosure::exact(rise_m).mul(Enclosure::exact(0.5));
    let side = Enclosure::exact(side_m);
    let offset = half.sub(side);
    let lift = half_rise.sub(side);
    let sum = offset.mul(offset).add(lift.mul(lift));
    let twice = Enclosure::exact(2.0).mul(lift);
    side.add(sum.div(twice))
}

/// Encloses `r = (B^2/4 + D^2) / (2 D)` of a flat-floor arch.
fn arch_radius(span_m: f64, rise_m: f64) -> Enclosure {
    let half = Enclosure::exact(span_m).mul(Enclosure::exact(0.5));
    let rise = Enclosure::exact(rise_m);
    let sum = half.mul(half).add(rise.mul(rise));
    sum.div(Enclosure::exact(2.0).mul(rise))
}

/// Pipe-arch quantities that decide admission.
struct PipeArch {
    offset: Enclosure,
    corner: Enclosure,
    /// `y_c = r_b - h`.
    corner_height: Enclosure,
    /// `g = D - y_c - r_c`, positive when the top arc closes above the corner arcs.
    gap: Enclosure,
    /// `B/2 - (D - y_c)`, nonnegative when the widest point lies on the corner arcs.
    reach: Enclosure,
}

impl PipeArch {
    fn new(span_m: f64, rise_m: f64, corner_m: f64, bottom_m: f64) -> Self {
        let half = Enclosure::exact(span_m).mul(Enclosure::exact(0.5));
        let corner = Enclosure::exact(corner_m);
        let bottom = Enclosure::exact(bottom_m);
        let offset = half.sub(corner);
        let doubled = Enclosure::exact(2.0).mul(corner);
        let lift = bottom.sub(half).mul(bottom.add(half).sub(doubled));
        let rise_to_centre = lift.nonnegative().sqrt();
        let corner_height = bottom.sub(rise_to_centre);
        let above = Enclosure::exact(rise_m).sub(corner_height);
        Self {
            offset,
            corner,
            corner_height,
            gap: above.sub(corner),
            reach: half.sub(above),
        }
    }

    /// `r_t = r_c + (x_c^2 + g^2) / (2 g)`.
    fn top_radius(&self) -> Enclosure {
        let sum = self.offset.mul(self.offset).add(self.gap.mul(self.gap));
        let twice = Enclosure::exact(2.0).mul(self.gap);
        self.corner.add(sum.div(twice))
    }
}

#[cfg(test)]
mod tests {
    use super::*;
    use crate::structures::StructureInputErrorKind;

    fn message(result: Result<CulvertBarrel, StructureError>) -> Option<String> {
        match result {
            Err(StructureError::InvalidInput {
                kind: StructureInputErrorKind::Definition,
                context,
                element: None,
            }) => Some(context),
            _ => None,
        }
    }

    #[test]
    fn every_rule_rejects_with_its_values_and_action() {
        let cases = [
            (
                CulvertBarrel::horizontal_ellipse(1.2, 1.5, 0.3),
                "span_m=1.2,rise_m=1.5: a horizontal ellipse needs span above rise. Use vertical_ellipse for a rise above the span",
            ),
            (
                CulvertBarrel::horizontal_ellipse(2.0, 1.0, 0.5),
                "rise_m=1.0,side_radius_m=0.5: a horizontal ellipse needs a side radius below half the rise. Supply a smaller side radius",
            ),
            (
                CulvertBarrel::horizontal_ellipse(2.0, 1.0, -0.1),
                "side_radius_m=-0.1: supply a finite positive barrel side radius in metres",
            ),
            (
                CulvertBarrel::vertical_ellipse(1.5, 1.2, 0.3),
                "span_m=1.5,rise_m=1.2: a vertical ellipse needs rise above span. Use horizontal_ellipse for a span above the rise",
            ),
            (
                CulvertBarrel::vertical_ellipse(1.0, 2.0, 0.5),
                "span_m=1.0,end_radius_m=0.5: a vertical ellipse needs an end radius below half the span. Supply a smaller end radius",
            ),
            (
                CulvertBarrel::vertical_ellipse(1.0, 2.0, f64::NAN),
                "end_radius_m=NaN: supply a finite positive barrel end radius in metres",
            ),
            (
                CulvertBarrel::pipe_arch(2.0, 1.5, 1.0, 2.0),
                "span_m=2.0,corner_radius_m=1.0: a pipe-arch needs a corner radius below half the span. Supply a smaller corner radius",
            ),
            (
                CulvertBarrel::pipe_arch(2.0, 1.5, 0.5, 1.0),
                "span_m=2.0,bottom_radius_m=1.0: a pipe-arch needs a bottom radius above half the span. Supply a larger bottom radius",
            ),
            (
                CulvertBarrel::pipe_arch(2.0, 1.0, 0.5, 1.01),
                "span_m=2.0,rise_m=1.0,corner_radius_m=0.5,bottom_radius_m=1.01: a pipe-arch needs a rise above the corner-centre height plus the corner radius",
            ),
            (
                CulvertBarrel::pipe_arch(2.0, 1.8, 0.5, 2.0),
                "span_m=2.0,rise_m=1.8,corner_radius_m=0.5,bottom_radius_m=2.0: a pipe-arch needs the rise above the corner centres",
            ),
            (
                CulvertBarrel::pipe_arch(2.0, 1.5, 0.0, 2.0),
                "corner_radius_m=0.0: supply a finite positive barrel corner radius in metres",
            ),
            (
                CulvertBarrel::pipe_arch(2.0, 1.5, 0.5, f64::INFINITY),
                "bottom_radius_m=inf: supply a finite positive barrel bottom radius in metres",
            ),
            (
                CulvertBarrel::arch(2.0, 2.5),
                "span_m=2.0,rise_m=2.5: a flat-floor arch needs a rise of at most the span. Supply a rise between a quarter of the span and the span",
            ),
            (
                CulvertBarrel::arch(2.0, 0.4),
                "span_m=2.0,rise_m=0.4: a flat-floor arch needs a rise of at least a quarter of the span. Supply a rise between a quarter of the span and the span",
            ),
            (
                CulvertBarrel::arch(-2.0, 0.4),
                "span_m=-2.0: supply a finite positive barrel span in metres",
            ),
        ];
        for (result, expected) in cases {
            let text = message(result);
            assert!(
                text.as_deref().is_some_and(|t| t.contains(expected)),
                "{text:?} lacks {expected:?}"
            );
        }
    }

    #[test]
    fn radius_and_scale_overflow_reject() {
        let cases = [
            (
                CulvertBarrel::pipe_arch(2.0, 1.5, 0.5, 1e110),
                "the bottom radius cubed times 64 overflows F64",
            ),
            (
                CulvertBarrel::horizontal_ellipse(1e100, 1e-100, 4e-101),
                "the invert and crown radius cubed times 64 overflows F64",
            ),
            (
                CulvertBarrel::vertical_ellipse(1e-100, 1e100, 4e-101),
                "the side radius cubed times 64 overflows F64",
            ),
            (
                CulvertBarrel::arch(1e300, 1e300),
                "B D times 64 overflows F64",
            ),
            (
                CulvertBarrel::arch(1e-300, 1e-300),
                "rise times 2^-30 is subnormal",
            ),
        ];
        for (result, expected) in cases {
            let text = message(result);
            assert!(
                text.as_deref().is_some_and(|t| t.contains(expected)),
                "{text:?} lacks {expected:?}"
            );
        }
    }

    #[test]
    fn rule_limits_admit_the_nearest_valid_dimensions() -> Result<(), StructureError> {
        // Exact comparisons: the nearest F64 inside each limit admits.
        CulvertBarrel::horizontal_ellipse(1.0_f64.next_up(), 1.0, 0.25)?;
        CulvertBarrel::horizontal_ellipse(2.0, 1.0, 0.5_f64.next_down())?;
        CulvertBarrel::vertical_ellipse(1.0, 1.0_f64.next_up(), 0.25)?;
        CulvertBarrel::vertical_ellipse(1.0, 2.0, 0.5_f64.next_down())?;
        // A bottom radius just above half the span lifts the corner centres to B/2.
        CulvertBarrel::pipe_arch(2.0, 1.8, 0.5, 1.0_f64.next_up())?;
        CulvertBarrel::arch(2.0, 2.0)?;
        CulvertBarrel::arch(2.0, 0.5)?;
        Ok(())
    }

    /// Frozen criterion: every evidence barrel scaled by `2^-900` or `2^300` admits, and each
    /// rule rejects at those scales as it does in metres.
    #[test]
    fn admission_holds_at_every_representable_scale() {
        type Build = fn(f64) -> Result<CulvertBarrel, StructureError>;
        let admitted: [Build; 4] = [
            |k| CulvertBarrel::horizontal_ellipse(1.524 * k, 0.9652 * k, 0.419_475_92 * k),
            |k| CulvertBarrel::vertical_ellipse(0.9652 * k, 1.524 * k, 0.419_475_92 * k),
            |k| CulvertBarrel::pipe_arch(1.8542 * k, 1.397 * k, 0.4572 * k, 1.938_528 * k),
            |k| CulvertBarrel::arch(3.048 * k, 1.6002 * k),
        ];
        let rejected: [(Build, &str); 2] = [
            (
                |k| CulvertBarrel::pipe_arch(2.0 * k, 1.0 * k, 0.5 * k, 1.01 * k),
                "a pipe-arch needs a rise above the corner-centre height plus the corner radius",
            ),
            (
                |k| CulvertBarrel::pipe_arch(2.0 * k, 1.8 * k, 0.5 * k, 2.0 * k),
                "a pipe-arch needs the rise above the corner centres",
            ),
        ];
        for scale in [2f64.powi(-900), 1.0, 2f64.powi(300)] {
            for (shape, build) in admitted.iter().enumerate() {
                let barrel = build(scale);
                assert!(barrel.is_ok(), "shape {shape} at {scale:e}: {barrel:?}");
            }
            for (build, expected) in rejected {
                let text = message(build(scale));
                assert!(
                    text.as_deref().is_some_and(|t| t.contains(expected)),
                    "{text:?} lacks {expected:?} at {scale:e}"
                );
            }
        }
        // Dimensions too far apart to share one frame reject with an action.
        let text = message(CulvertBarrel::vertical_ellipse(1e-300, 1e300, 1e-301));
        let expected = "the dimensions differ in size by more than F64 can scale to a unit rise. Supply dimensions closer in size";
        assert!(
            text.as_deref().is_some_and(|t| t.contains(expected)),
            "{text:?} lacks {expected:?}"
        );
    }

    #[test]
    fn admitted_arc_barrels_report_their_inputs() -> Result<(), StructureError> {
        let ellipse = CulvertBarrel::horizontal_ellipse(1.524, 0.9652, 0.419_475_92)?;
        assert_eq!(ellipse.shape(), CulvertBarrelShape::HorizontalEllipse);
        assert_eq!((ellipse.span_m(), ellipse.rise_m()), (1.524, 0.9652));
        assert_eq!(ellipse.given_radius_m(), Some(&[0.419_475_92][..]));
        let turned = CulvertBarrel::vertical_ellipse(0.9652, 1.524, 0.419_475_92)?;
        assert_eq!(turned.shape(), CulvertBarrelShape::VerticalEllipse);
        assert_eq!(turned.given_radius_m(), Some(&[0.419_475_92][..]));
        let pipe = CulvertBarrel::pipe_arch(1.8542, 1.397, 0.4572, 1.938_528)?;
        assert_eq!(pipe.shape(), CulvertBarrelShape::PipeArch);
        assert_eq!(pipe.given_radius_m(), Some(&[0.4572, 1.938_528][..]));
        let arch = CulvertBarrel::arch(3.048, 1.6002)?;
        assert_eq!(arch.shape(), CulvertBarrelShape::Arch);
        assert_eq!((arch.span_m(), arch.rise_m()), (3.048, 1.6002));
        assert_eq!(arch.given_radius_m(), None);
        for barrel in [ellipse, turned, pipe, arch] {
            assert!(barrel.shape().arced());
        }
        Ok(())
    }

    #[test]
    fn pipe_arch_rules_certify_the_aisi_layout() {
        // AISI Table 1.9 row 1 in metres: corner centres near 21 in above the invert.
        let layout = PipeArch::new(1.8542, 1.397, 0.4572, 1.938_528);
        let inches = 0.0254;
        assert!(layout.corner_height.lower > 20.9 * inches);
        assert!(layout.corner_height.upper < 21.1 * inches);
        assert!(layout.gap.lower > 0.0);
        assert!(layout.reach.lower > 0.0);
        let top = layout.top_radius();
        assert!(top.lower > 36.0 * inches && top.upper < 37.5 * inches);
    }
}