hpr_aero/afterbody.rs
1//! The afterbody faster than sound: a boattail's own pressure drag, and the base pressure behind
2//! it.
3//!
4//! A boattail is a transition that narrows toward the tail. Below Mach 0.8 it keeps Niskanen's
5//! rule, a share of the base drag on its decrease in area (Niskanen 2009 eq. 3.88,
6//! [`crate::drag::boattail_factor`]). Faster than sound the air expands around the boattail's
7//! shoulder, its pressure falls below the free stream's, and it pulls back on the boattail: a
8//! wave drag the rule doesn't have. Behind the boattail the base's pressure rises, which lowers the
9//! base drag. On the boattail's fore (cylinder) area `A₁ = π d₁²/4`, for a boattail of length `l`
10//! from diameter `d₁` to `d₂`, area ratio `a = (d₂/d₁)²` and half-angle
11//! `θ = atan((d₁ − d₂)/(2l))`:
12//!
13//! - **Attached flow, from Mach 1** ([`Boattail::attached_pressure_drag`]): MIL-HDBK-762's chart
14//! for conical boattails (Fig. 5-122, printed p. 5-187), `y = 4 C_D (l/d₁)²` against
15//! `x = √(M² − 1)/(2 l/d₁)` for `a` from 0.25 to 0.80, read into [`conical_boattail_chart`].
16//! The handbook cites no source for it; its values agree with Jack's second-order theory
17//! (NACA TN 2972, 1953) within −10% to +8% for `a` up to 0.6 (`validation/fixtures/aero/`
18//! `measured-boattails.json`). It is held to the **2D limit** `C_PM = −C_p,PM(M, θ)(1 − a)`:
19//! the pressure behind a Prandtl–Meyer expansion through `θ`
20//! ([`expansion_pressure_coefficient`]) over the whole annulus. On an axisymmetric boattail the
21//! pressure recovers aft of the shoulder, so the drag stays below that limit and approaches it
22//! as the boattail gets short against `β d₁` (the quasi-cylinder solution's recovery falls as
23//! `1/x`). Past the chart's end at `x = 1.4`, the drag closes the chart's gap to the limit as
24//! `1/x`: `C_D = [1 − (1 − r) 1.4/x] C_PM(M)`, with `r` the chart's share of the limit at
25//! `x = 1.4` (at most 1).
26//! - **Separation** ([`Boattail::separation_weight`]): steep boattails separate. Cubbage's
27//! boattails (NACA RM L57B21, 1957, Mach 0.6–1.28) stay attached at 16° and separate completely
28//! by 30°, and a separated boattail sees about a cylinder's base pressure. Between 16° and 30°
29//! the drag moves linearly in `θ` from the attached value to the base drag coefficient on the
30//! annulus, `C_D,base(M)(1 − a)`.
31//! - **Through Mach 1**: MIL-HDBK-762 finds no method for boattails at transonic speeds and
32//! advises extrapolating the supersonic drag "to peak value at a Mach number range of 1.0 ≤ M∞
33//! ≤ 1.2, with a sharp reduction to a lower value at subsonic speeds" (p. 5-47). The chart's
34//! near-sonic end is not used: from Mach 1 to 1.2 the attached drag is held at its Mach 1.2
35//! value, below Mach 1 the drag falls on a straight line to the rule's value at Mach 0.8, where
36//! the buildup's other transonic terms start (Niskanen p. 47), and the rule holds below. The
37//! line is half-way up at Mach 0.9; measured boattails are half-way up by 0.89 (Compton, NASA
38//! TN D-6789) to 0.92 to 0.96 (Cubbage), peak at Mach 1.0 to 1.1, and at 1.2 are 0.83 to 0.90
39//! of that peak (Cubbage), so holding the Mach 1.2 value reads under the peak.
40//! - **The base behind a boattail** ([`boattail_base_pressure_ratio`]): MIL-HDBK-762 Fig. 5-141
41//! (printed p. 5-210, after Rubin, Brazzel and Henderson, 1970) correlates a boattail's base
42//! pressure with a cylinder's at Mach 2.5 to 3.5 as `p_cyl/p_bt = 0.442 + 0.558 a_b`, with
43//! `a_b` the base's area over the cylinder's. HPR Sim takes the cylinder's pressure from Love's
44//! correlation (Fig. 5-139, printed p. 5-208; NACA TN 3819) and scales its own base drag by the
45//! ratio of the two coefficients, `k = C_p,bt/C_p,cyl`. Below Mach 2.5, where the correlation
46//! over-predicts the relief of the measured bases, `k` is held at its Mach 2.5 value, which
47//! matches Cortright and Schroeder's at Mach 1.91 and de Moraes and Nowitzky's at 1.59. Up to
48//! Mach 0.8, `k = d_B/d₁ = √a_b` ([ADR-362, held to a measured flight][adr-362]): the base drag of a conical afterbody
49//! scales with `(r_b/R)³` on the largest cross-section (Stoney, NASA TR R-100, 1961, p. 11,
50//! from wind-tunnel data; Hoerner's eq. 35 has the same dependence), where Niskanen's rule on
51//! the base's area scales with its square, so the rule keeps `d_B/d₁` of its value. From Mach
52//! 0.8 to 1, `k` runs on a straight line between the two. A separated boattail gives no relief
53//! (weight as above).
54//!
55//! Narrowing parts of one smooth surface drag as one cone ([`crate::drag::BoattailTerm`]), and a
56//! lip behind a boattail sits in its wake ([`crate::drag::WakeTerm`]); every part between a
57//! boattail and what follows fades both, and the base's relief, so each is continuous in the
58//! geometry.
59//!
60//! Outside the data: the chart below `a = 0.25` (Jack's theory reaches 0.2), attached flow up to
61//! 16° where Jack's theory stops at 11°, Cubbage's separation angles (measured to Mach 1.28) at
62//! every Mach number, and Fig. 5-141 outside its bases' area ratios of 0.25 to 0.67 and angles to
63//! 14°. How well each piece agrees with the measurements is in the guide.
64//!
65//! Calisto's boattail, 0.472 calibers long from `a = 1` to 0.469 (18.4°), at Mach 1.5: the chart
66//! gives 0.219 and the 2D limit 0.211, so the attached drag is 0.211; separation takes it 17% of
67//! the way to the base's 0.088, to 0.190.
68//!
69//! ```
70//! use hpr_aero::afterbody::Boattail;
71//!
72//! let calisto = Boattail::new(0.06, 0.127, 0.087)?;
73//! assert!((calisto.attached_pressure_drag(1.5)? - 0.211).abs() < 5e-4);
74//! assert!((calisto.pressure_drag_coefficient(1.5)? - 0.190).abs() < 5e-4);
75//! # Ok::<(), hpr_aero::AeroError>(())
76//! ```
77//!
78//! See [Boattails faster than sound][guide] in the guide.
79//!
80//! [guide]: https://hpr.fusionspace.co/physics/aero.html#boattails-faster-than-sound
81//! [adr-362]: https://github.com/nrdptel/fusionspace-eridanus/blob/main/docs/decisions/0362-base-drag-behind-a-boattail-below-mach-0-8-held-to-the-hermes-a-3a.md
82
83use serde::Serialize;
84
85use crate::drag::{base_drag_coefficient, boattail_factor, check_mach_any};
86use crate::error::{AeroError, check_dimension};
87
88/// The ratio of specific heats of air, `γ = 1.4`.
89pub(crate) const GAMMA: f64 = 1.4;
90
91/// `√((γ + 1)/(γ − 1))`, `√6` for `γ = 1.4`.
92const PM_K: f64 = 2.449_489_742_783_178;
93
94/// The largest turning angle of a Prandtl–Meyer expansion from Mach 1, to a vacuum:
95/// `(π/2)(√((γ + 1)/(γ − 1)) − 1)`, 130.45° (NACA Report 1135, 1953, eq. 172, p. 626).
96pub const MAX_TURNING_RAD: f64 = std::f64::consts::FRAC_PI_2 * (PM_K - 1.0);
97
98/// The boattail half-angle up to which the flow stays attached: 16°, Cubbage's steepest attached
99/// boattail (NACA RM L57B21).
100pub const SEPARATION_ONSET_RAD: f64 = 16.0 * std::f64::consts::PI / 180.0;
101
102/// The boattail half-angle from which the flow is separated: 30°, Cubbage's shallowest separated
103/// boattail (NACA RM L57B21).
104pub const SEPARATION_COMPLETE_RAD: f64 = 30.0 * std::f64::consts::PI / 180.0;
105
106/// The lowest Mach number of MIL-HDBK-762 Fig. 5-141's correlation, 2.5; below it the base
107/// pressure ratio is held.
108pub const BASE_RELIEF_MACH: f64 = 2.5;
109
110/// Where a boattail's drag starts its transonic rise and its base's relief its move to the
111/// supersonic value: Mach 0.8, where
112/// the rest of the buildup starts its transonic methods ([`crate::drag::SUBSONIC_MACH_LIMIT`],
113/// Niskanen 2009 p. 47). An earlier draft used 0.9, chosen after seeing the Arcas Robin wind
114/// tunnel, a target (the decision record on the afterbody, [ADR-030][adr-030]).
115///
116/// [adr-030]: https://github.com/nrdptel/fusionspace-eridanus/blob/main/docs/DECISIONS.md#adr-030-the-afterbody-faster-than-sound-a-boattails-wave-drag-the-base-behind-it-and-a-lip-in-its-wake-2026-09-18
117pub const TRANSONIC_ONSET_MACH: f64 = crate::drag::SUBSONIC_MACH_LIMIT;
118
119/// Where the transonic rise ends: from Mach 1 a boattail takes its supersonic drag (held to
120/// [`SUPERSONIC_MODEL_MACH`]'s value) and its base the supersonic relief.
121pub const SUPERSONIC_MACH: f64 = 1.0;
122
123/// The lowest Mach number at which the supersonic boattail drag is evaluated, 1.2, the top of
124/// MIL-HDBK-762's "peak value" range (p. 5-47); from Mach 1 to 1.2 its value there is held.
125pub const SUPERSONIC_MODEL_MACH: f64 = 1.2;
126
127/// The chart's abscissae `x = √(M² − 1)/(2 l/d₁)` at which [`CHART_Y`] was read.
128pub const CHART_X: [f64; 20] = [
129 0.06, 0.08, 0.1, 0.125, 0.15, 0.2, 0.25, 0.3, 0.35, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1.0, 1.1,
130 1.2, 1.3, 1.4,
131];
132
133/// The chart's curves, by area ratio `(d₂/d₁)²`.
134pub const CHART_AREA_RATIOS: [f64; 8] = [0.25, 0.30, 0.35, 0.40, 0.50, 0.60, 0.70, 0.80];
135
136/// MIL-HDBK-762 Fig. 5-122 (printed p. 5-187, PDF p. 425), "Wave-Drag Coefficient of Conical
137/// Boattails at Supersonic Speeds": `y = 4 C_D (l/d₁)²` on `π d₁²/4`, one row per
138/// [`CHART_AREA_RATIOS`] at [`CHART_X`]. Read from a 200-dpi render with the grid fitted for tilt,
139/// each curve fitted in `ln y` against `ln x` and checked on an overlay: ±(0.005 + 2%), the lines
140/// being about 0.017 thick. The 0.80 curve's reading rises by 0.001 past `x = 1.2`, where the
141/// printed line doesn't; it is held at 0.0332. The chart starts at `x = 0.05`, where the readings
142/// hook; they start at 0.06.
143pub const CHART_Y: [[f64; 20]; 8] = [
144 [
145 2.1326, 1.9357, 1.7839, 1.6375, 1.5231, 1.3518, 1.2251, 1.1244, 1.0402, 0.9677, 0.8467,
146 0.7477, 0.6642, 0.5925, 0.5302, 0.4757, 0.4277, 0.3852, 0.3475, 0.3140,
147 ],
148 [
149 1.8266, 1.6867, 1.5666, 1.4424, 1.3406, 1.1822, 1.0627, 0.9673, 0.8884, 0.8213, 0.7118,
150 0.6250, 0.5538, 0.4941, 0.4431, 0.3990, 0.3606, 0.3270, 0.2972, 0.2708,
151 ],
152 [
153 1.5427, 1.4371, 1.3387, 1.2330, 1.1445, 1.0054, 0.9003, 0.8169, 0.7484, 0.6905, 0.5972,
154 0.5241, 0.4648, 0.4153, 0.3733, 0.3371, 0.3057, 0.2781, 0.2538, 0.2322,
155 ],
156 [
157 1.2846, 1.1867, 1.1073, 1.0249, 0.9557, 0.8441, 0.7567, 0.6857, 0.6265, 0.5762, 0.4952,
158 0.4324, 0.3822, 0.3412, 0.3071, 0.2782, 0.2535, 0.2322, 0.2136, 0.1973,
159 ],
160 [
161 0.8662, 0.7911, 0.7271, 0.6625, 0.6112, 0.5347, 0.4798, 0.4378, 0.4042, 0.3762, 0.3316,
162 0.2968, 0.2684, 0.2444, 0.2238, 0.2057, 0.1897, 0.1754, 0.1626, 0.1510,
163 ],
164 [
165 0.5522, 0.5015, 0.4652, 0.4292, 0.3993, 0.3509, 0.3129, 0.2822, 0.2569, 0.2358, 0.2028,
166 0.1783, 0.1596, 0.1450, 0.1333, 0.1238, 0.1161, 0.1096, 0.1042, 0.0996,
167 ],
168 [
169 0.3266, 0.2894, 0.2697, 0.2526, 0.2384, 0.2137, 0.1920, 0.1732, 0.1569, 0.1430, 0.1209,
170 0.1046, 0.0924, 0.0832, 0.0762, 0.0708, 0.0666, 0.0633, 0.0608, 0.0590,
171 ],
172 [
173 0.1610, 0.1445, 0.1385, 0.1337, 0.1287, 0.1167, 0.1038, 0.0918, 0.0812, 0.0723, 0.0587,
174 0.0494, 0.0431, 0.0388, 0.0360, 0.0343, 0.0334, 0.0332, 0.0332, 0.0332,
175 ],
176];
177
178/// Love's correlation of turbulent base pressure behind cylinders, `−C_p,b` against Mach number
179/// (MIL-HDBK-762 Fig. 5-139, printed p. 5-208, the solid line, after NACA TN 3819), read at
180/// Mach 2.5 to 5: ±0.001 (±0.0015 at Mach 3, where symbols hide the line).
181pub const LOVE_BASE_PRESSURE: [(f64, f64); 6] = [
182 (2.5, 0.1195),
183 (3.0, 0.097),
184 (3.5, 0.0805),
185 (4.0, 0.067),
186 (4.5, 0.0565),
187 (5.0, 0.0475),
188];
189
190/// The Prandtl–Meyer function `ν(M) = √((γ + 1)/(γ − 1)) atan √((γ − 1)(M² − 1)/(γ + 1)) −
191/// atan √(M² − 1)`, rad: the angle through which a flow at Mach 1 turns, expanding, to reach `M`
192/// (NACA Report 1135, 1953, eq. 171c, p. 626).
193///
194/// # Errors
195///
196/// [`AeroError::Domain`] below Mach 1 or for a non-finite Mach number.
197pub fn prandtl_meyer_angle(mach: f64) -> Result<f64, AeroError> {
198 if !(mach.is_finite() && mach >= 1.0) {
199 return Err(AeroError::Domain {
200 what: "Mach number of a Prandtl-Meyer expansion",
201 value: mach,
202 });
203 }
204 Ok(prandtl_meyer(mach))
205}
206
207pub(crate) fn prandtl_meyer(mach: f64) -> f64 {
208 let b = (mach * mach - 1.0).sqrt();
209 PM_K * (b / PM_K).atan() - b.atan()
210}
211
212/// The Mach number whose Prandtl–Meyer angle is `nu_rad`, for `0 ≤ ν < ν_max`
213/// ([`MAX_TURNING_RAD`]): Newton's method on `ν(M)`, kept inside a bracket, until a step moves
214/// `M` by a few rounding steps, so that every platform lands on the same root to rounding, not
215/// wherever a tolerance first stops it.
216pub(crate) fn inverse_prandtl_meyer(nu_rad: f64) -> f64 {
217 if nu_rad <= 0.0 {
218 return 1.0;
219 }
220 // A bracket [lo, hi] with ν(lo) ≤ ν < ν(hi).
221 let (mut lo, mut hi) = (1.0, 2.0);
222 while prandtl_meyer(hi) < nu_rad {
223 lo = hi;
224 hi *= 2.0;
225 }
226 let mut mach = 0.5 * (lo + hi);
227 for _ in 0..200 {
228 let f = prandtl_meyer(mach) - nu_rad;
229 if f == 0.0 {
230 break;
231 }
232 if f > 0.0 {
233 hi = mach;
234 } else {
235 lo = mach;
236 }
237 let m2 = mach * mach;
238 let slope = (m2 - 1.0).sqrt() / (mach * (1.0 + 0.5 * (GAMMA - 1.0) * m2));
239 let newton = mach - f / slope;
240 let next = if newton > lo && newton < hi && slope > 0.0 {
241 newton
242 } else {
243 0.5 * (lo + hi)
244 };
245 let settled = (next - mach).abs() <= 4.0 * f64::EPSILON * mach;
246 mach = next;
247 if settled {
248 break;
249 }
250 }
251 mach
252}
253
254/// The pressure coefficient behind a two-dimensional isentropic (Prandtl–Meyer) expansion of a
255/// flow at Mach `mach ≥ 1` through `turn_rad`: `M₂` from `ν(M₂) = ν(M) + θ`, then
256/// `C_p = (p₂/p − 1)/(γ M²/2)` with `p₂/p = [(1 + (γ−1)M²/2)/(1 + (γ−1)M₂²/2)]^(γ/(γ−1))`
257/// (NACA Report 1135: the pressures from eq. 44, the dynamic pressure `γ p M²/2` from eq. 31b,
258/// p. 616). Past the largest turning angle the flow reaches a vacuum, `C_p = −2/(γ M²)`.
259///
260/// # Errors
261///
262/// [`AeroError::Domain`] below Mach 1, for a non-finite Mach number, or a turning angle outside
263/// `[0, π/2]`.
264pub fn expansion_pressure_coefficient(mach: f64, turn_rad: f64) -> Result<f64, AeroError> {
265 let nu = prandtl_meyer_angle(mach)?;
266 if !(0.0..=std::f64::consts::FRAC_PI_2).contains(&turn_rad) {
267 return Err(AeroError::Domain {
268 what: "expansion turning angle",
269 value: turn_rad,
270 });
271 }
272 let q = 0.5 * GAMMA * mach * mach;
273 let target = nu + turn_rad;
274 if target >= MAX_TURNING_RAD {
275 return Ok(-1.0 / q);
276 }
277 let m2 = inverse_prandtl_meyer(target);
278 let h = 0.5 * (GAMMA - 1.0);
279 let ratio = ((1.0 + h * mach * mach) / (1.0 + h * m2 * m2)).powf(GAMMA / (GAMMA - 1.0));
280 Ok((ratio - 1.0) / q)
281}
282
283/// A curve's value at `x`: log-log between the readings, held below the first.
284fn chart_curve(row: &[f64; 20], x: f64) -> f64 {
285 if x <= CHART_X[0] {
286 return row[0];
287 }
288 let last = CHART_X.len() - 1;
289 if x >= CHART_X[last] {
290 return row[last];
291 }
292 // `CHART_X[0] < x < CHART_X[last]`, so the partition point is between 1 and `last`.
293 let i = CHART_X.partition_point(|&c| c <= x) - 1;
294 let t = (x / CHART_X[i]).ln() / (CHART_X[i + 1] / CHART_X[i]).ln();
295 (row[i].ln() * (1.0 - t) + row[i + 1].ln() * t).exp()
296}
297
298/// MIL-HDBK-762 Fig. 5-122's `y = 4 C_D (l/d₁)²` for a conical boattail of area ratio
299/// `a = (d₂/d₁)²` at `x = √(M² − 1)/(2 l/d₁)` from 0 to 1.4 ([`CHART_Y`]): log-log in `x` between
300/// the readings, held below `x = 0.06`, and linear in `a` between the curves. Past the chart's
301/// last curve, `a > 0.8`, it goes to 0 at `a = 1` as `(1 − √a)²` (linear theory's pressure is
302/// proportional to the surface slope, so at a fixed length the drag goes as the slope squared);
303/// below its first, `a < 0.25`, it continues the straight line through the 0.25 and 0.30 curves.
304///
305/// # Errors
306///
307/// [`AeroError::Domain`] for `x` outside `[0, 1.4]` or `a` outside `[0, 1]`.
308pub fn conical_boattail_chart(x: f64, area_ratio: f64) -> Result<f64, AeroError> {
309 if !(0.0..=CHART_X[CHART_X.len() - 1]).contains(&x) {
310 return Err(AeroError::Domain {
311 what: "boattail chart abscissa",
312 value: x,
313 });
314 }
315 if !(0.0..=1.0).contains(&area_ratio) {
316 return Err(AeroError::Domain {
317 what: "boattail area ratio",
318 value: area_ratio,
319 });
320 }
321 let curve = |i: usize| chart_curve(&CHART_Y[i], x);
322 let n = CHART_AREA_RATIOS.len();
323 let (first, last) = (CHART_AREA_RATIOS[0], CHART_AREA_RATIOS[n - 1]);
324 Ok(if area_ratio >= last {
325 let slope = (1.0 - area_ratio.sqrt()) / (1.0 - last.sqrt());
326 curve(n - 1) * slope * slope
327 } else if area_ratio <= first {
328 let (y0, y1) = (curve(0), curve(1));
329 y0 + (y0 - y1) * (first - area_ratio) / (CHART_AREA_RATIOS[1] - first)
330 } else {
331 // `first < a < last`, so the partition point is between 1 and `n − 1`.
332 let i = CHART_AREA_RATIOS.partition_point(|&c| c <= area_ratio) - 1;
333 let t =
334 (area_ratio - CHART_AREA_RATIOS[i]) / (CHART_AREA_RATIOS[i + 1] - CHART_AREA_RATIOS[i]);
335 curve(i) * (1.0 - t) + curve(i + 1) * t
336 })
337}
338
339/// Love's `−C_p,b` for a cylinder at `mach`, linear between [`LOVE_BASE_PRESSURE`]'s readings and
340/// held at their ends.
341fn love_base_pressure(mach: f64) -> f64 {
342 let points = &LOVE_BASE_PRESSURE;
343 let (first, last) = (points[0], points[points.len() - 1]);
344 if mach <= first.0 {
345 return first.1;
346 }
347 if mach >= last.0 {
348 return last.1;
349 }
350 let i = points.partition_point(|p| p.0 <= mach) - 1;
351 let ((m0, c0), (m1, c1)) = (points[i], points[i + 1]);
352 c0 + (c1 - c0) * (mach - m0) / (m1 - m0)
353}
354
355/// The base pressure behind a boattail over a cylinder's, as a ratio of pressure coefficients
356/// `k = C_p,bt/C_p,cyl` that scales the base drag, for a base of area ratio `a_b` (its area over
357/// the boattail's fore area) and an attached boattail (MIL-HDBK-762 Fig. 5-141, printed p. 5-210):
358///
359/// - From Mach 2.5, `p_bt = p_cyl/(0.442 + 0.558 a_b)` with the cylinder's `p_cyl/p =
360/// 1 + C_p,cyl γM²/2` from Love's correlation ([`LOVE_BASE_PRESSURE`]), and
361/// `k = (1 − p_bt/p)/(1 − p_cyl/p)`, not below 0 (no measured base pressure is above the free
362/// stream's).
363/// - From Mach 1 to 2.5, `k` at Mach 2.5.
364/// - Up to Mach 0.8, `k = d_B/d₁ = √a_b` ([ADR-362, held to a measured flight][adr-362]): Stoney's empirical base drag of a
365/// conical afterbody, from wind-tunnel data, is `C_D,b = C_D,b,cylinder (r_b/R)³` on the
366/// largest cross-section (NASA TR R-100, 1961, printed p. 11; Missile DATCOM's manual names
367/// the method for a boattail's base drag below Mach 1.2), where the flat-base rule on the
368/// base's area scales with `(r_b/R)²`. Hoerner's subsonic base drag has the same `(d_B/d)³`
369/// (*Fluid-Dynamic Drag*, 1965, p. 3-20, eq. 35). So the base keeps `d_B/d₁` of the flat-base
370/// value: 1 at a flat base. Stoney warns that the rule does not allow for the negative base
371/// drags seen at subsonic speeds. On the Hermes A-3A's measured flight below Mach 0.8 (NACA RM
372/// SL55F15, Fig. 20) it reads high by 0.025 to 0.035 on the largest cross-section, power off,
373/// where 1 read high by 0.050 to 0.064 (`validation/fixtures/aero/base-drag-under-power.json`).
374/// - From Mach 0.8 to 1, a straight line from `√a_b` to the value at Mach 1.
375///
376/// # Errors
377///
378/// [`AeroError::Domain`] for a negative or non-finite Mach number, or `a_b` outside `[0, 1]`.
379///
380/// [adr-362]: https://github.com/nrdptel/fusionspace-eridanus/blob/main/docs/decisions/0362-base-drag-behind-a-boattail-below-mach-0-8-held-to-the-hermes-a-3a.md
381pub fn boattail_base_pressure_ratio(mach: f64, base_area_ratio: f64) -> Result<f64, AeroError> {
382 check_mach_any(mach)?;
383 if !(0.0..=1.0).contains(&base_area_ratio) {
384 return Err(AeroError::Domain {
385 what: "base area ratio",
386 value: base_area_ratio,
387 });
388 }
389 let supersonic = |m: f64| {
390 let cylinder = love_base_pressure(m);
391 // Past Mach 5.5 Love's held value would ask for less than a vacuum.
392 let p_cyl = (1.0 - cylinder * 0.5 * GAMMA * m * m).max(0.0);
393 let p_bt = p_cyl / (0.442 + 0.558 * base_area_ratio);
394 ((1.0 - p_bt) / (1.0 - p_cyl)).max(0.0)
395 };
396 let subsonic = base_area_ratio.sqrt();
397 Ok(if mach <= TRANSONIC_ONSET_MACH {
398 subsonic
399 } else if mach < SUPERSONIC_MACH {
400 let k = supersonic(BASE_RELIEF_MACH);
401 subsonic
402 + (k - subsonic) * (mach - TRANSONIC_ONSET_MACH)
403 / (SUPERSONIC_MACH - TRANSONIC_ONSET_MACH)
404 } else {
405 supersonic(mach.max(BASE_RELIEF_MACH))
406 })
407}
408
409/// A boattail's geometry and the terms of its pressure drag that don't depend on the Mach number.
410/// Coefficients are on its fore area `π d₁²/4`.
411#[derive(Debug, Clone, Copy, PartialEq, Serialize)]
412#[non_exhaustive]
413pub struct Boattail {
414 /// Length `l`, m.
415 pub length_m: f64,
416 /// Fore diameter `d₁`, m.
417 pub fore_diameter_m: f64,
418 /// Aft diameter `d₂`, m.
419 pub aft_diameter_m: f64,
420 /// Area ratio `a = (d₂/d₁)²`.
421 pub area_ratio: f64,
422 /// Length over fore diameter, `l/d₁`.
423 pub length_ratio: f64,
424 /// Half-angle of the cone through the same ends, `θ = atan((d₁ − d₂)/(2l))`, rad.
425 pub half_angle_rad: f64,
426 /// Niskanen's boattail factor (eq. 3.88), used below Mach 0.8.
427 pub rule_factor: f64,
428 /// The share of the separated value in the supersonic drag and base pressure:
429 /// ([`SEPARATION_ONSET_RAD`], [`SEPARATION_COMPLETE_RAD`]) mapped linearly to (0, 1).
430 pub separation_weight: f64,
431 /// The chart's share of the 2D limit at its end, `x = 1.4`, at most 1: `r` in the drag past
432 /// the chart.
433 pub chart_end_ratio: f64,
434}
435
436impl Boattail {
437 /// A boattail of `length_m` narrowing from `fore_diameter_m` to `aft_diameter_m`, compared as
438 /// the cone through the same ends. For one length, area ratio and Mach number Jack found the
439 /// cone's wave drag the smallest of conical, tangent-parabolic and secant-parabolic boattails
440 /// (NACA TN 2972 p. 1), so a curved boattail likely drags more than HPR Sim gives; its steeper
441 /// aft end may also separate where the cone's chord angle doesn't.
442 ///
443 /// # Errors
444 ///
445 /// [`AeroError::Domain`] for a non-positive or non-finite length or fore diameter, a negative
446 /// aft diameter, or diameters that don't decrease.
447 pub fn new(
448 length_m: f64,
449 fore_diameter_m: f64,
450 aft_diameter_m: f64,
451 ) -> Result<Self, AeroError> {
452 check_dimension("boattail length", length_m, false)?;
453 let rule_factor = boattail_factor(length_m, fore_diameter_m, aft_diameter_m)?;
454 let ratio = aft_diameter_m / fore_diameter_m;
455 let length_ratio = length_m / fore_diameter_m;
456 let half_angle_rad = ((fore_diameter_m - aft_diameter_m) / (2.0 * length_m)).atan();
457 let separation_weight = ((half_angle_rad - SEPARATION_ONSET_RAD)
458 / (SEPARATION_COMPLETE_RAD - SEPARATION_ONSET_RAD))
459 .clamp(0.0, 1.0);
460 let mut boattail = Self {
461 length_m,
462 fore_diameter_m,
463 aft_diameter_m,
464 area_ratio: ratio * ratio,
465 length_ratio,
466 half_angle_rad,
467 rule_factor,
468 separation_weight,
469 chart_end_ratio: 1.0,
470 };
471 // The Mach number at which `x = 1.4`: `√(M² − 1) = 2.8 l/d₁`.
472 let end = CHART_X[CHART_X.len() - 1];
473 let beta = 2.0 * end * length_ratio;
474 let mach_end = (1.0 + beta * beta).sqrt();
475 let chart = boattail.chart_drag(end)?;
476 boattail.chart_end_ratio = (chart / boattail.expansion_limit(mach_end)?).min(1.0);
477 Ok(boattail)
478 }
479
480 /// The chart's `C_D` at `x`.
481 fn chart_drag(&self, x: f64) -> Result<f64, AeroError> {
482 let l = self.length_ratio;
483 Ok(conical_boattail_chart(x, self.area_ratio)? / (4.0 * l * l))
484 }
485
486 /// The 2D limit `C_PM = −C_p,PM(M, θ)(1 − a)` at `mach ≥ 1`: a Prandtl–Meyer expansion's
487 /// pressure over the whole annulus.
488 ///
489 /// # Errors
490 ///
491 /// As [`expansion_pressure_coefficient`].
492 pub fn expansion_limit(&self, mach: f64) -> Result<f64, AeroError> {
493 Ok(-expansion_pressure_coefficient(mach, self.half_angle_rad)? * (1.0 - self.area_ratio))
494 }
495
496 /// The attached boattail's pressure drag at `mach ≥ 1`: the chart held to the 2D limit, and
497 /// past the chart's end the limit less the chart's share of it closing as `1/x` (module
498 /// docs).
499 ///
500 /// # Errors
501 ///
502 /// As [`expansion_pressure_coefficient`].
503 pub fn attached_pressure_drag(&self, mach: f64) -> Result<f64, AeroError> {
504 let limit = self.expansion_limit(mach)?;
505 let x = (mach * mach - 1.0).sqrt() / (2.0 * self.length_ratio);
506 let end = CHART_X[CHART_X.len() - 1];
507 Ok(if x <= end {
508 self.chart_drag(x)?.min(limit)
509 } else {
510 (1.0 - (1.0 - self.chart_end_ratio) * end / x) * limit
511 })
512 }
513
514 /// The boattail's pressure drag on its fore area at any Mach number (module docs): Niskanen's
515 /// rule to Mach 0.8; from Mach 1, the attached drag (held at its Mach 1.2 value to Mach 1.2)
516 /// blended toward the separated value at the Mach number itself; a straight line between.
517 /// So a boattail steep enough to separate completely drags like the step it tends to.
518 ///
519 /// # Errors
520 ///
521 /// [`AeroError::Domain`] for a negative or non-finite Mach number.
522 pub fn pressure_drag_coefficient(&self, mach: f64) -> Result<f64, AeroError> {
523 check_mach_any(mach)?;
524 let annulus = 1.0 - self.area_ratio;
525 let supersonic = |m: f64| -> Result<f64, AeroError> {
526 let separated = base_drag_coefficient(m)? * annulus;
527 let w = self.separation_weight;
528 let attached = self.attached_pressure_drag(m.max(SUPERSONIC_MODEL_MACH))?;
529 Ok((1.0 - w) * attached + w * separated)
530 };
531 if mach <= TRANSONIC_ONSET_MACH {
532 Ok(self.rule_factor * base_drag_coefficient(mach)? * annulus)
533 } else if mach < SUPERSONIC_MACH {
534 let low = self.rule_factor * base_drag_coefficient(TRANSONIC_ONSET_MACH)? * annulus;
535 let high = supersonic(SUPERSONIC_MACH)?;
536 let t = (mach - TRANSONIC_ONSET_MACH) / (SUPERSONIC_MACH - TRANSONIC_ONSET_MACH);
537 Ok(low + (high - low) * t)
538 } else {
539 supersonic(mach)
540 }
541 }
542
543 /// The factor on the base drag of a base right behind this boattail, of area ratio `a_b` (the
544 /// base's area over the boattail's fore area): [`boattail_base_pressure_ratio`], moved toward
545 /// 1 by the separation weight.
546 ///
547 /// # Errors
548 ///
549 /// As [`boattail_base_pressure_ratio`].
550 pub fn base_pressure_ratio(&self, mach: f64, base_area_ratio: f64) -> Result<f64, AeroError> {
551 let k = boattail_base_pressure_ratio(mach, base_area_ratio)?;
552 let w = self.separation_weight;
553 Ok((1.0 - w) * k + w)
554 }
555}
556
557#[cfg(test)]
558mod tests {
559 use super::*;
560
561 fn close(got: f64, want: f64, tol: f64, what: &str) {
562 assert!((got - want).abs() <= tol, "{what}: {got} against {want}");
563 }
564
565 /// The Prandtl–Meyer function against NACA Report 1135's table (M = 2: 26.380°; M = 3:
566 /// 49.757°), its limit (eq. 172: 130.45°), and the inverse.
567 #[test]
568 fn prandtl_meyer_matches_tables_and_inverts() {
569 let deg = |r: f64| r.to_degrees();
570 close(deg(prandtl_meyer_angle(1.0).unwrap()), 0.0, 1e-12, "ν(1)");
571 close(deg(prandtl_meyer_angle(2.0).unwrap()), 26.380, 5e-4, "ν(2)");
572 close(deg(prandtl_meyer_angle(3.0).unwrap()), 49.757, 5e-4, "ν(3)");
573 close(deg(MAX_TURNING_RAD), 130.454, 5e-4, "ν_max");
574 assert!(prandtl_meyer_angle(0.99).is_err());
575 assert!(prandtl_meyer_angle(f64::NAN).is_err());
576 for mach in [1.0, 1.001, 1.2, 2.0, 4.6, 20.0, 300.0] {
577 let back = inverse_prandtl_meyer(prandtl_meyer(mach));
578 close(back, mach, 1e-9 * mach, "inverse");
579 }
580 }
581
582 /// Expansion pressure by hand: from Mach 1.5 through 15°, `ν` goes from 11.905° to 26.905°,
583 /// `M₂` = 2.0191, `p₂/p = (1.45/1.8154)^3.5 = 0.4554` and `C_p = −0.3458`; a turn past the
584 /// vacuum limit gives `−2/(γM²)`.
585 #[test]
586 fn expansion_pressure_by_hand_and_at_the_vacuum() {
587 let cp = expansion_pressure_coefficient(1.5, 15f64.to_radians()).unwrap();
588 close(cp, -0.3458, 5e-5, "Mach 1.5, 15°");
589 close(
590 expansion_pressure_coefficient(1.5, 0.0).unwrap(),
591 0.0,
592 1e-12,
593 "no turn",
594 );
595 let vacuum = expansion_pressure_coefficient(4.0, std::f64::consts::FRAC_PI_2).unwrap();
596 close(vacuum, -1.0 / (0.7 * 16.0), 1e-12, "vacuum");
597 assert!(expansion_pressure_coefficient(1.5, -0.1).is_err());
598 }
599
600 /// The chart gives back its readings at the grid, is log-log between them, falls with `x`
601 /// and with the area ratio, and goes to 0 at `a = 1`.
602 #[test]
603 fn chart_reproduces_its_readings_and_orders() {
604 for (i, &a) in CHART_AREA_RATIOS.iter().enumerate() {
605 for (j, &x) in CHART_X.iter().enumerate() {
606 close(
607 conical_boattail_chart(x, a).unwrap(),
608 CHART_Y[i][j],
609 1e-12,
610 "grid",
611 );
612 }
613 }
614 // Halfway in ln x between 0.4 and 0.5 on the 0.50 curve: the geometric mean.
615 let x = (0.4f64 * 0.5).sqrt();
616 close(
617 conical_boattail_chart(x, 0.5).unwrap(),
618 (0.3762f64 * 0.3316).sqrt(),
619 1e-12,
620 "log-log",
621 );
622 close(
623 conical_boattail_chart(0.0, 0.5).unwrap(),
624 0.8662,
625 1e-12,
626 "held below 0.06",
627 );
628 close(
629 conical_boattail_chart(0.7, 1.0).unwrap(),
630 0.0,
631 1e-12,
632 "a = 1",
633 );
634 let mut previous = f64::INFINITY;
635 for step in 0..=100 {
636 let a = f64::from(step) / 100.0;
637 let y = conical_boattail_chart(0.5, a).unwrap();
638 assert!(y < previous || a == 0.0, "falls with a at {a}");
639 previous = y;
640 }
641 assert!(conical_boattail_chart(1.41, 0.5).is_err());
642 assert!(conical_boattail_chart(0.5, 1.01).is_err());
643 }
644
645 /// The module's worked example, Calisto's boattail at Mach 1.5, and the pieces of the drag:
646 /// continuous at Mach 0.8, 1 and 1.2, the rule below, never above the 2D limit, and the chart's
647 /// own value inside it.
648 #[test]
649 fn calistos_boattail_by_hand() {
650 let b = Boattail::new(0.06, 0.127, 0.087).unwrap();
651 close(b.area_ratio, 0.469_28, 1e-5, "area ratio");
652 close(b.half_angle_rad.to_degrees(), 18.435, 1e-3, "angle");
653 close(b.separation_weight, (18.435 - 16.0) / 14.0, 1e-4, "weight");
654 // x = √1.25/(2 × 0.472) = 1.183; the chart at a = 0.469: 0.219 on d₁.
655 let x = 1.25f64.sqrt() / (2.0 * b.length_ratio);
656 let chart =
657 conical_boattail_chart(x, b.area_ratio).unwrap() / (4.0 * b.length_ratio.powi(2));
658 close(chart, 0.2189, 5e-4, "chart");
659 let limit = b.expansion_limit(1.5).unwrap();
660 close(limit, 0.2112, 5e-4, "2D limit");
661 close(
662 b.attached_pressure_drag(1.5).unwrap(),
663 limit.min(chart),
664 1e-12,
665 "attached",
666 );
667 let separated = 0.25 / 1.5 * (1.0 - b.area_ratio);
668 let w = b.separation_weight;
669 close(
670 b.pressure_drag_coefficient(1.5).unwrap(),
671 (1.0 - w) * limit.min(chart) + w * separated,
672 1e-12,
673 "blended",
674 );
675 let rule =
676 |m: f64| b.rule_factor * base_drag_coefficient(m).unwrap() * (1.0 - b.area_ratio);
677 close(
678 b.pressure_drag_coefficient(0.5).unwrap(),
679 rule(0.5),
680 1e-12,
681 "rule",
682 );
683 close(
684 b.pressure_drag_coefficient(0.8).unwrap(),
685 rule(0.8),
686 1e-12,
687 "rule to 0.8",
688 );
689 // From Mach 1 to 1.2 the attached part is held at its Mach 1.2 value, and the separated
690 // part follows the base drag at the Mach number itself.
691 let attached = b.attached_pressure_drag(1.2).unwrap();
692 let held = |m: f64| (1.0 - w) * attached + w * 0.25 / m * (1.0 - b.area_ratio);
693 close(
694 b.pressure_drag_coefficient(1.0).unwrap(),
695 held(1.0),
696 1e-12,
697 "held from 1",
698 );
699 close(
700 b.pressure_drag_coefficient(1.1).unwrap(),
701 held(1.1),
702 1e-12,
703 "held to 1.2",
704 );
705 close(
706 b.pressure_drag_coefficient(0.9).unwrap(),
707 0.5 * (rule(0.8) + held(1.0)),
708 1e-12,
709 "half-way at 0.9",
710 );
711 for (edge, what) in [
712 (TRANSONIC_ONSET_MACH, "0.8"),
713 (SUPERSONIC_MACH, "1"),
714 (SUPERSONIC_MODEL_MACH, "1.2"),
715 ] {
716 let below = b.pressure_drag_coefficient(edge - 1e-9).unwrap();
717 let above = b.pressure_drag_coefficient(edge + 1e-9).unwrap();
718 close(below, above, 1e-6, what);
719 }
720 for step in 0..=400 {
721 let mach = 1.0 + f64::from(step) / 100.0;
722 let attached = b.attached_pressure_drag(mach).unwrap();
723 assert!(
724 attached <= b.expansion_limit(mach).unwrap() + 1e-12,
725 "Mach {mach}"
726 );
727 assert!(attached > 0.0, "Mach {mach}");
728 }
729 }
730
731 /// Past the chart's end the drag closes on the 2D limit as `1/x`, starting from the chart's
732 /// value at `x = 1.4`: continuous there, rising toward the limit's share.
733 #[test]
734 fn past_the_chart_the_drag_closes_on_the_2d_limit() {
735 // A long, gentle boattail reaches x = 1.4 early: 2 calibers to a = 0.5.
736 let b = Boattail::new(0.2, 0.1, 0.1 * 0.5f64.sqrt()).unwrap();
737 let mach_end = (1.0 + (2.8 * b.length_ratio).powi(2)).sqrt();
738 let chart = b.chart_drag(1.4).unwrap();
739 assert!(chart < b.expansion_limit(mach_end).unwrap());
740 close(
741 b.attached_pressure_drag(mach_end).unwrap(),
742 chart,
743 1e-9,
744 "at the end",
745 );
746 close(
747 b.attached_pressure_drag(mach_end + 1e-9).unwrap(),
748 chart,
749 1e-7,
750 "just past",
751 );
752 let mut previous = 0.0;
753 for mach in [6.0, 8.0, 12.0, 20.0] {
754 let share = b.attached_pressure_drag(mach).unwrap() / b.expansion_limit(mach).unwrap();
755 assert!(share > previous && share < 1.0, "Mach {mach}: {share}");
756 previous = share;
757 }
758 }
759
760 /// A boattail that tends to a step down drags like the step, the base drag on the area it
761 /// uncovers, at every Mach number: within 0.6% where the straight line from Mach 0.8 to 1
762 /// stands in for the base drag's curve, and to rounding elsewhere.
763 #[test]
764 fn a_vanishing_boattail_drags_like_a_step() {
765 let b = Boattail::new(1e-9, 0.1, 0.06).unwrap();
766 assert_eq!(b.separation_weight, 1.0);
767 let annulus = 1.0 - b.area_ratio;
768 for step in 0..500 {
769 let mach = f64::from(step) / 100.0;
770 let step_drag = base_drag_coefficient(mach).unwrap() * annulus;
771 let got = b.pressure_drag_coefficient(mach).unwrap();
772 let tol = if mach > TRANSONIC_ONSET_MACH && mach < SUPERSONIC_MACH {
773 6e-3
774 } else {
775 1e-12
776 };
777 close(got, step_drag, tol * step_drag, "step");
778 }
779 }
780
781 /// Separation: none to 16°, all from 30°, where a boattail drags like the base it uncovers
782 /// and gives its base no relief.
783 #[test]
784 fn steep_boattails_separate() {
785 let d = 0.1;
786 let at = |deg: f64| {
787 let l = (d - 0.06) / (2.0 * deg.to_radians().tan());
788 Boattail::new(l, d, 0.06).unwrap()
789 };
790 close(at(15.0).separation_weight, 0.0, 0.0, "15°");
791 close(at(16.0).separation_weight, 0.0, 1e-12, "16°");
792 close(at(23.0).separation_weight, 0.5, 1e-12, "23°");
793 let steep = at(45.0);
794 close(steep.separation_weight, 1.0, 0.0, "45°");
795 close(
796 steep.pressure_drag_coefficient(2.0).unwrap(),
797 0.125 * (1.0 - 0.36),
798 1e-12,
799 "separated",
800 );
801 close(
802 steep.base_pressure_ratio(2.0, 0.36).unwrap(),
803 1.0,
804 0.0,
805 "no relief",
806 );
807 // Below Mach 0.8 too (ADR-362): a separated boattail's base keeps the flat-base value,
808 // and half separated, half of the √a_b relief, 0.5 · 0.6 + 0.5 by hand.
809 close(
810 steep.base_pressure_ratio(0.5, 0.36).unwrap(),
811 1.0,
812 0.0,
813 "no relief, subsonic",
814 );
815 close(
816 at(23.0).base_pressure_ratio(0.5, 0.36).unwrap(),
817 0.8,
818 1e-12,
819 "half relief, subsonic",
820 );
821 }
822
823 /// The base pressure ratio: `√a_b` up to Mach 0.8 (NASA TR R-100), held below 2.5, Fig.
824 /// 5-141's line in pressure from 2.5 (at Mach 3, `p_cyl/p_bt = 0.442 + 0.558 a_b` exactly), 1
825 /// for a base as large as the cylinder, and none below 0.
826 #[test]
827 fn base_pressure_ratio_follows_fig_5_141() {
828 let k = |m: f64, a: f64| boattail_base_pressure_ratio(m, a).unwrap();
829 close(k(0.5, 0.469), 0.469f64.sqrt(), 0.0, "subsonic");
830 close(k(0.8, 0.469), 0.469f64.sqrt(), 0.0, "to Mach 0.8");
831 close(k(0.5, 1.0), 1.0, 0.0, "a flat base");
832 // The Hermes A-3A's base, 4.8 in behind 8 in: 0.6 of the flat-base value.
833 close(k(0.7, 0.36), 0.6, 1e-15, "Hermes A-3A");
834 close(k(1.0, 0.469), k(2.5, 0.469), 0.0, "held");
835 close(k(1.8, 0.469), k(2.5, 0.469), 0.0, "held");
836 close(k(3.0, 1.0), 1.0, 1e-12, "no boattail");
837 // At Mach 3, Love's cylinder gives −0.097, so p_cyl/p = 1 − 0.097 × 6.3.
838 let p_cyl = 1.0 - 0.097 * 0.7 * 9.0;
839 let a = 0.338;
840 let p_bt = p_cyl / (0.442 + 0.558 * a);
841 close(k(3.0, a), (1.0 - p_bt) / (1.0 - p_cyl), 1e-12, "Fig. 5-141");
842 // Calisto's base at Mach 2.5: 0.616.
843 close(k(2.5, 0.469), 0.6157, 5e-4, "Calisto");
844 assert!(k(4.9, 0.0) >= 0.0);
845 let mid = k(0.9, 0.469);
846 close(mid, 0.5 * (0.469f64.sqrt() + k(2.5, 0.469)), 1e-12, "join");
847 assert!(boattail_base_pressure_ratio(2.0, 1.1).is_err());
848 }
849
850 /// Every boattail from 1° to 89°, `a` from 0 to 0.95, gives a finite, non-negative drag at
851 /// every Mach number to 5, and a base ratio in `[0, 1]`.
852 #[test]
853 fn every_boattail_is_finite() {
854 for deg in [1.0f64, 3.0, 8.0, 15.0, 16.0, 20.0, 30.0, 60.0, 89.0] {
855 for a in [0.0f64, 0.05, 0.2, 0.25, 0.469, 0.8, 0.95] {
856 let d2 = 0.1 * a.sqrt();
857 let l = (0.1 - d2) / (2.0 * deg.to_radians().tan());
858 let b = Boattail::new(l, 0.1, d2).unwrap();
859 for step in 0..500 {
860 let mach = f64::from(step) / 100.0;
861 let c = b.pressure_drag_coefficient(mach).unwrap();
862 assert!(c.is_finite() && c >= 0.0, "{deg}° a {a} Mach {mach}: {c}");
863 let k = b.base_pressure_ratio(mach, a).unwrap();
864 assert!((0.0..=1.0).contains(&k), "{deg}° a {a} Mach {mach}: {k}");
865 }
866 }
867 }
868 }
869}