In 1947 the United States released J. E. Mack’s high-speed film of the Trinity test of 16 July 1945, with the time of each frame and a length scale, while the energy of the explosion remained secret. G. I. Taylor (1950) had worked out the similarity solution of a strong point explosion: the radius of the blast wave, the time , the energy and the density of the air form a single dimensionless group, , so that . From the radius–time data of the film he estimated an energy of about of TNT; the radiochemical value made public later is about . This lecture uses the same reasoning, Mental Move 5, Nondimensionalize Before You Sweep, with exact rational null spaces (representation_scaling.buckingham_pi_nullspace), the dimensional matrices in CANONICAL_DIM_MATRICES and the 25 radius–time pairs of Taylor’s table in TAYLOR_TRINITY_1945.
Learning objectives¶
Quantify how Buckingham’s -Theorem () reduces exponential parameter-sweep grids from down to runs across
constants_benchmarks.CANONICAL_DIM_MATRICES.Compute exact primitive-integer dimensional nullspace bases solving via
representation_scaling.buckingham_pi_nullspacewithout floating-point SVD basis mixing.Reproduce G. I. Taylor’s 1950 Trinity blast-wave analysis on
constants_benchmarks.TAYLOR_TRINITY_1945, verifying the scaling law and extracting explosive yield in kilotons of TNT.Collapse multi-fluid dimensional experimental scatter onto universal master curves ( vs. ) and design dynamically similar scale-model tests.
Time: about 60 min
try: # use the installed package, or the copy in this repository
import engthink
except ImportError:
import pathlib, subprocess, sys
for _root in [pathlib.Path.cwd(), *pathlib.Path.cwd().parents]:
if (_root / "engthink" / "__init__.py").exists():
sys.path.insert(0, str(_root))
break
else: # on Google Colab: install from GitHub
subprocess.run([sys.executable, "-m", "pip", "install", "-q",
"git+https://github.com/ktwyw/engthink.git"], check=True)
import engthink
import inspect
import math
import numpy as np
import matplotlib.pyplot as plt
from engthink import (constants_benchmarks, divide_spatial, dynamic_optimality, emergence_verification,
greedy_heuristic_search, information_streams, invariants_complexity, reductions_constraints,
representation_scaling)
from engthink.plotting import label_panels, log_ticks, panel_label, use_style
use_style()
def show_source(obj):
"""Return the source code of a library function or class."""
return inspect.getsource(obj)
def heading(text):
print(f"\n{text}\n" + "=" * len(text))1. Dimensional Homogeneity as Linear Algebra & The Curse of Parameter Sweeps¶
1.1 The Dimensional Matrix and Rank–Nullity¶
Every physical law must hold whether length is measured in metres, centimetres or furlongs (scale-invariance symmetry). If base dimensions (such as ) describe each variable’s dimensions as , any dimensionless product satisfies if and only if its exponent vector lies in the right nullspace of the dimensional matrix :
Mental Move #5, Nondimensionalize Before You Sweep: Sweeping values per input across convective heat-transfer variables (h, D, k, rho, U, mu, cp) executes CFD runs ( independent conditions for the output h). Nondimensionalizing collapses the problem to dimensionless groups (), requiring only runs, a -fold reduction.
heading("Demonstration 1: Exact rational nullspaces and grid-sweep compression across CANONICAL_DIM_MATRICES")
g_pts = 10
print(f"{'Physical System':30s} | {'n':>2s} | {'rank':>4s} | {'p=n-r':>5s} | {'Sweep Gain':>11s} | {'Primitive Integer Pi Basis'}")
print("-" * 110)
for key, spec in constants_benchmarks.CANONICAL_DIM_MATRICES.items():
res = representation_scaling.buckingham_pi_nullspace(spec["matrix"], spec["variables"])
n_v = len(spec["variables"])
r_d = res["rank"]
p_g = res["n_pi_groups"]
# Independent input sweep compression for predicting 1 target variable: G^(n-1) -> G^(p-1) = G^r:
sweep_gain = g_pts ** r_d
groups_str = " ; ".join(res["formatted_groups"])
print(f"{key:30s} | {n_v:2d} | {r_d:4d} | {p_g:5d} | {sweep_gain:9,d}x | {groups_str}")
assert res["nullspace_residual"] == 0.0
assert p_g == n_v - r_d
blast_res = representation_scaling.buckingham_pi_nullspace(
constants_benchmarks.CANONICAL_DIM_MATRICES["taylor_blast_wave"]["matrix"],
constants_benchmarks.CANONICAL_DIM_MATRICES["taylor_blast_wave"]["variables"],
)
assert blast_res["n_pi_groups"] == 1
assert blast_res["pi_exponents"].tolist() == [[5, -2, -1, 1]]
Demonstration 1: Exact rational nullspaces and grid-sweep compression across CANONICAL_DIM_MATRICES
===================================================================================================
Physical System | n | rank | p=n-r | Sweep Gain | Primitive Integer Pi Basis
--------------------------------------------------------------------------------------------------------------
taylor_blast_wave | 4 | 3 | 1 | 1,000x | R^5 * rho0 / (t^2 * E)
pipe_pressure_drop | 6 | 3 | 3 | 1,000x | dP_per_L * D / (rho * U^2) ; dP_per_L * mu / (rho^2 * U^3) ; dP_per_L * eps_rough / (rho * U^2)
convective_heat_transfer | 7 | 4 | 3 | 10,000x | k / (h * D) ; mu / (D * rho * U) ; rho * U * cp / (h)
capillary_droplet_oscillation | 5 | 3 | 2 | 1,000x | sigma / (omega^2 * R^3 * rho) ; mu / (omega * R^2 * rho)
What Demonstration 1 shows.
Zero-parameter curves: For
taylor_blast_wave(R, t, E, rho0), and group: . Writing immediately dictates the exact power-law exponent from linear algebra alone; solving the equations of gas dynamics is needed only for the constant .
2. Taylor’s estimate of the Trinity yield (TAYLOR_TRINITY_1945)¶
Rearranging (where Taylor integrated the self-similar Sedov–Taylor ODE for diatomic air to obtain ) gives two predictions for the 25 radius–time pairs measured from Mack’s film (constants_benchmarks.TAYLOR_TRINITY_1945):
Plotting against must form a straight line of exact slope across nearly three orders of magnitude in time ( to ).
Rescaling every radius measurement into the invariant collapses the entire expanding shock trajectory onto a constant horizontal plateau, from which the classified yield is:
heading("Demonstration 2: Taylor's (1950) estimate of the Trinity energy from 25 frames")
trin = constants_benchmarks.TAYLOR_TRINITY_1945
t_s = trin["time_s"]
r_m = trin["radius_m"]
rho0 = trin["rho_air_kg_m3"]
s_gam = trin["S_gamma_1p4"]
j_per_kt = trin["joules_per_kiloton_tnt"]
# 1. Unconstrained empirical log-log regression log10(R) = slope * log10(t) + intercept:
emp_slope, emp_intercept = np.polyfit(np.log10(t_s), np.log10(r_m), 1)
# 2. Evaluate Taylor's collapsed invariant C_i = R_i * t_i^(-2/5) [m * s^(-2/5)]:
collapsed_c = r_m * (t_s ** (-0.4))
c_mean = float(np.mean(collapsed_c))
c_rel_std = float(np.std(collapsed_c, ddof=1) / c_mean)
# 3. Deduce the explosive energy E [J] and kilotons of TNT:
e_joules = rho0 * ((c_mean / s_gam) ** 5)
yield_kt_tnt = e_joules / j_per_kt
print(f"Empirical log-log slope d(log R)/d(log t) : {emp_slope:.4f} (Exact Buckingham Pi exponent = 2/5 = 0.4000)")
print(f"Collapsed invariant <R * t^(-2/5)> : {c_mean:.2f} m*s^(-2/5) (scatter CV = {100*c_rel_std:.2f}% over 620x time span)")
print(f"Deduced Trinity Energy E : {e_joules:.3e} J -> Yield = {yield_kt_tnt:.2f} kilotons TNT")
t_smooth = np.logspace(np.log10(t_s[0]) - 0.1, np.log10(t_s[-1]) + 0.1, 200)
r_theory = c_mean * (t_smooth ** 0.4)
fig, (ax1, ax2) = plt.subplots(1, 2, figsize=(11.5, 4.2))
ax1.loglog(t_s * 1e3, r_m, "o", color="#C0392B", ms=5.5, label="Mack camera data (1945)")
ax1.loglog(t_smooth * 1e3, r_theory, "-", color="#2166AC", lw=2.1, label=r"Taylor law $R \propto t^{2/5}$ (slope $= 0.400$)")
ax1.set_xlabel(r"Time after detonation $t$ [ms]")
ax1.set_ylabel(r"Fireball shock radius $R$ [m]")
ax1.set_title("Blast-wave radius of the Trinity explosion")
ax1.legend(fontsize=8.3)
ax2.semilogx(t_s * 1e3, collapsed_c, "s-", color="#2E8B57", lw=1.6, ms=5.0, label=r"Frame-by-frame $R_i t_i^{-2/5}$")
ax2.axhline(c_mean, color="#2166AC", ls="--", lw=2.0, label=f"Mean plateau = {c_mean:.1f} -> {yield_kt_tnt:.1f} kt TNT")
ax2.set_ylim(0.80 * c_mean, 1.20 * c_mean)
ax2.set_xlabel(r"Time after detonation $t$ [ms]")
ax2.set_ylabel(r"Collapsed invariant $R\,t^{-2/5}$ [$\mathrm{m\,s^{-2/5}}$]")
ax2.set_title("$R\\,t^{-2/5}$ is nearly constant")
ax2.legend(fontsize=8.3)
label_panels(fig)
plt.show()
assert abs(emp_slope - 0.40) < 0.012
assert c_rel_std < 0.06
assert 16.0 < yield_kt_tnt < 19.5
Demonstration 2: Taylor's (1950) estimate of the Trinity energy from 25 frames
==============================================================================
Empirical log-log slope d(log R)/d(log t) : 0.4058 (Exact Buckingham Pi exponent = 2/5 = 0.4000)
Collapsed invariant <R * t^(-2/5)> : 578.41 m*s^(-2/5) (scatter CV = 5.41% over 620x time span)
Deduced Trinity Energy E : 6.880e+13 J -> Yield = 16.44 kilotons TNT

Figure 1.1. Taylor’s analysis of the Trinity film. (a) Radius of the blast wave against time for the 25 frames, with the law (line); the fitted slope is 0.406. (b) The combination is nearly constant after the first frames; its mean plateau, 578.4, corresponds to an energy of 16.4 kt of TNT.
Sensitivity to the constant: Because , a 1 % error in is a 5 % error in the energy. Over the 25 frames has a coefficient of variation of 5.4 %, the fitted log–log slope is 0.406 against 2/5, and the mean of gives of TNT, close to Taylor’s own estimate of about and below the radiochemical value of about .
3. Collapsing Multi-Fluid Pipe Pressure-Drop Scatter onto One Master Curve¶
Consider flow in smooth circular pipes, governed by the 5 variables (dP_per_L, rho, U, D, mu), for five fluids: air, water, a light crude oil, a glycerol–water mixture and liquid sodium. The data are synthetic: pressure gradients computed from the laminar law blended into the Blasius law , with 1.5 % random noise, for representative densities and viscosities. Plotting raw pressure gradient against velocity gives a scattered cloud. Applying buckingham_pi_nullspace yields groups:
All smooth-pipe data for Newtonian fluids must therefore fall on one curve . (The library returns and as its basis; any product of powers of the groups is also a group.)
heading("Demonstration 3: Collapsing 5-fluid dimensional scatter onto the universal Moody/Blasius curve")
pipe_spec = constants_benchmarks.CANONICAL_DIM_MATRICES["pipe_pressure_drop"]
smooth_mat = pipe_spec["matrix"][:, :5]
smooth_vars = pipe_spec["variables"][:5]
smooth_pi = representation_scaling.buckingham_pi_nullspace(smooth_mat, smooth_vars)
print("Smooth-pipe Pi groups:", smooth_pi["formatted_groups"])
fluids = [
("Dry air (1 bar)", 1.20, 1.81e-5, "#2166AC", "o"),
("Liquid water (20 °C)", 998.0, 1.00e-3, "#2E8B57", "s"),
("Light crude oil", 860.0, 1.40e-2, "#C0392B", "^"),
("Glycerol-water 75%", 1195.0, 3.50e-2, "#7B4FA3", "D"),
("Liquid sodium (400 °C)", 856.0, 2.80e-4, "#E08214", "v"),
]
rng_p = np.random.default_rng(2026)
fig, (ax1, ax2) = plt.subplots(1, 2, figsize=(11.5, 4.2))
all_re, all_eu, all_theory = [], [], []
for label, rho_f, mu_f, col, mk in fluids:
d_arr = rng_p.uniform(0.008, 0.25, size=36)
u_arr = 10.0 ** rng_p.uniform(-1.3, 1.2, size=36)
re_arr = rho_f * u_arr * d_arr / mu_f
# Smooth-pipe Darcy friction factor (laminar 64/Re blended smoothly into turbulent Blasius 0.3164*Re^-0.25):
f_lam = 64.0 / re_arr
f_turb = 0.3164 * (re_arr ** (-0.25))
w_turb = 1.0 / (1.0 + np.exp(-(re_arr - 2600.0) / 350.0))
f_true = (1.0 - w_turb) * f_lam + w_turb * f_turb
dp_dx = (f_true / d_arr) * 0.5 * rho_f * (u_arr ** 2) * rng_p.normal(1.0, 0.015, size=36)
eu_pi1 = dp_dx * d_arr / (rho_f * (u_arr ** 2))
ax1.loglog(u_arr, dp_dx, mk, color=col, ms=4.8, alpha=0.8, label=label)
ax2.loglog(re_arr, 2.0 * eu_pi1, mk, color=col, ms=4.8, alpha=0.8, label=label)
all_re.extend(re_arr.tolist())
all_eu.extend((2.0 * eu_pi1).tolist())
all_theory.extend(f_true.tolist())
re_grid = np.logspace(1.5, 6.2, 300)
w_g = 1.0 / (1.0 + np.exp(-(re_grid - 2600.0) / 350.0))
ax2.loglog(re_grid, (1.0 - w_g) * (64.0 / re_grid) + w_g * (0.3164 * re_grid ** -0.25), "k-", lw=1.8, label="Master law")
ax1.set_xlabel(r"Mean pipe velocity $U$ [m/s]")
ax1.set_ylabel(r"Pressure gradient $\Delta P / L$ [Pa/m]")
ax1.set_title("Dimensional data for five fluids")
ax1.legend(fontsize=7.3)
ax2.set_xlabel(r"Reynolds number $\mathrm{Re} = \rho U D / \mu$")
ax2.set_ylabel(r"Darcy factor $f_D = 2\,\Pi_1 = 2(\Delta P/L)D/(\rho U^2)$")
ax2.set_title(r"Buckingham-$\Pi$ collapse onto one curve")
ax2.legend(fontsize=7.3)
label_panels(fig)
plt.show()
rel_collapse_rms = float(np.sqrt(np.mean(((np.array(all_eu) - np.array(all_theory)) / np.array(all_theory)) ** 2)))
print(f"Collapsed 180 multi-fluid points onto 1 curve with RMS scatter = {100*rel_collapse_rms:.2f}% (pure measurement noise = 1.50%)")
assert smooth_pi["n_pi_groups"] == 2
assert rel_collapse_rms < 0.025
Demonstration 3: Collapsing 5-fluid dimensional scatter onto the universal Moody/Blasius curve
==============================================================================================
Smooth-pipe Pi groups: ['dP_per_L * D / (rho * U^2)', 'dP_per_L * mu / (rho^2 * U^3)']

Collapsed 180 multi-fluid points onto 1 curve with RMS scatter = 1.58% (pure measurement noise = 1.50%)
Figure 1.2. Dimensionless collapse of synthetic pipe-flow data. (a) Pressure gradient against mean velocity for five fluids: the points scatter over six decades. (b) The same points as a friction factor against the Reynolds number fall on one curve, laminar below about 2000 and turbulent above.
Transfer between fluids: The 180 synthetic points of five fluids fall on one curve with an r.m.s. scatter of 1.58 %, essentially the 1.5 % noise put into the data. A curve measured with water in a laboratory tube therefore predicts the pressure drop of liquid sodium at the same Reynolds number.
4. Dynamic Similitude & Scale-Model Wind-Tunnel Design¶
Suppose we test a geometric scale model () of an underwater autonomous hull moving at in seawater () inside a pressurized dry-air wind tunnel at (). Matching and force coefficient determines the exact tunnel speed and full-scale drag .
heading("Demonstration 4: Dynamic similitude scaling (20-bar compressed-air tunnel -> seawater prototype)")
l_proto, u_proto, rho_proto, mu_proto = 3.20, 4.00, 1025.0, 1.076e-3
l_model = l_proto / 8.0
rho_model, mu_model = 23.80, 1.82e-5 # 20-bar compressed air reduces kinematic viscosity 20x
re_proto = rho_proto * u_proto * l_proto / mu_proto
# Match Re_model == Re_proto -> u_model = re_proto * mu_model / (rho_model * l_model):
u_model = re_proto * mu_model / (rho_model * l_model)
mach_model = u_model / 343.0
# Suppose wind-tunnel sting balance measures F_model = 48.5 N on the 1:8 model:
f_model = 48.5
cd_matched = f_model / (0.5 * rho_model * (u_model ** 2) * (l_model ** 2))
f_proto_pred = cd_matched * (0.5 * rho_proto * (u_proto ** 2) * (l_proto ** 2))
print(f"Prototype Re_p = {re_proto:.3e} | Required 20-bar tunnel speed U_m = {u_model:.2f} m/s (Mach = {mach_model:.3f} < 0.3)")
print(f"Matched Drag Coefficient C_D = {cd_matched:.4f} -> Full-scale seawater drag F_p = {f_proto_pred:.1f} N")
re_model_check = rho_model * u_model * l_model / mu_model
assert np.isclose(re_model_check, re_proto, rtol=1e-14)
assert mach_model < 0.30 # Unpressurized 1-bar air would require ~460 m/s (supersonic Mach 1.35 — invalid)
# Verify defensive input validation in buckingham_pi_nullspace:
for bad_args in [(np.array([1, 2, 3]), None), (np.zeros((0, 3)), None), (np.ones((2, 3)), ["a", "b"])]:
caught = False
try:
representation_scaling.buckingham_pi_nullspace(*bad_args)
except ValueError:
caught = True
assert caught
print("Similitude scaling (why NACA built variable-density compressed-air tunnels) and guards verified")
Demonstration 4: Dynamic similitude scaling (20-bar compressed-air tunnel -> seawater prototype)
================================================================================================
Prototype Re_p = 1.219e+07 | Required 20-bar tunnel speed U_m = 23.31 m/s (Mach = 0.068 < 0.3)
Matched Drag Coefficient C_D = 0.0469 -> Full-scale seawater drag F_p = 3936.2 N
Similitude scaling (why NACA built variable-density compressed-air tunnels) and guards verified
Inside the algorithm¶
Why does representation_scaling.buckingham_pi_nullspace perform Gaussian elimination over exact fractions.Fraction objects instead of calling np.linalg.svd(D)? We inspect buckingham_pi_nullspace and write manual_svd_vs_rational_pi(dim_matrix) to compare the floating-point SVD nullspace basis against exact rational RREF: SVD rotates the nullspace by arbitrary orthogonal matrices, producing non-integer exponents such as -0.3387, 0.2365 instead of the integers of Nu, Re and Pr, even though both bases span the exact same linear subspace (verified via orthogonal projector equality ).
Check against the library¶
heading("Inside the algorithm: Exact rational RREF against floating-point SVD nullspace mixing")
print(show_source(representation_scaling.buckingham_pi_nullspace))
def manual_svd_vs_rational_pi(dim_matrix: np.ndarray, var_names: list[str]) -> dict:
"""Compare floating-point SVD nullspace vectors against exact Fraction RREF integer exponents."""
d_mat = np.asarray(dim_matrix, dtype=float)
_, s_vals, vt = np.linalg.svd(d_mat, full_matrices=True)
tol = max(d_mat.shape) * np.spacing(float(np.max(s_vals)))
rank_svd = int(np.sum(s_vals > tol))
v_null_svd = vt[rank_svd:, :] # Shape (p, n), orthonormal rows
rat_res = representation_scaling.buckingham_pi_nullspace(dim_matrix, var_names)
b_rat = rat_res["pi_exponents"].astype(float) # Shape (p, n), primitive integer rows
# Orthogonal projection matrices onto ker(D): P = V^T V == B^T (B B^T)^(-1) B
proj_svd = v_null_svd.T @ v_null_svd
proj_rat = b_rat.T @ np.linalg.inv(b_rat @ b_rat.T) @ b_rat
return {
"svd_basis_rows": v_null_svd,
"rational_integer_rows": rat_res["pi_exponents"],
"formatted_groups": rat_res["formatted_groups"],
"projector_max_diff": float(np.max(np.abs(proj_svd - proj_rat))),
}
conv_spec = constants_benchmarks.CANONICAL_DIM_MATRICES["convective_heat_transfer"]
cmp_null = manual_svd_vs_rational_pi(conv_spec["matrix"], conv_spec["variables"])
print("Variables:", conv_spec["variables"])
print("SVD Nullspace Row 0 (mixed irrational decimals):", np.round(cmp_null["svd_basis_rows"][0], 4))
print("Rational RREF Integer Rows:\n", cmp_null["rational_integer_rows"])
print("Clean Physical Groups:", cmp_null["formatted_groups"])
print(f"Subspace Projector Max |P_SVD - P_Rational| = {cmp_null['projector_max_diff']:.2e}")
assert cmp_null["projector_max_diff"] < 1.0e-14
Inside the algorithm: Exact rational RREF against floating-point SVD nullspace mixing
=====================================================================================
def buckingham_pi_nullspace(dim_matrix: np.ndarray, var_names: list[str] | None = None) -> dict:
"""Compute an exact primitive-integer Buckingham-Pi nullspace basis solving D @ pi = 0 via Fraction RREF."""
d_in = np.asarray(dim_matrix)
if d_in.ndim != 2 or d_in.shape[0] == 0 or d_in.shape[1] == 0:
raise ValueError("dim_matrix must be a non-empty 2-D array of shape (n_dims, n_vars).")
m_dims, n_vars = d_in.shape
names = [f"v{j}" for j in range(n_vars)] if var_names is None else list(var_names)
if len(names) != n_vars:
raise ValueError("var_names length must equal dim_matrix.shape[1].")
mat = [[Fraction(val).limit_denominator(10**6) for val in row] for row in d_in.tolist()]
pivot_cols: list[int] = []
r_piv = 0
for col in range(n_vars):
if r_piv >= m_dims:
break
sel = None
for r in range(r_piv, m_dims):
if mat[r][col] != 0:
sel = r
break
if sel is None:
continue
mat[r_piv], mat[sel] = mat[sel], mat[r_piv]
pv = mat[r_piv][col]
mat[r_piv] = [entry / pv for entry in mat[r_piv]]
for r in range(m_dims):
if r != r_piv and mat[r][col] != 0:
fac = mat[r][col]
mat[r] = [mat[r][c] - fac * mat[r_piv][c] for c in range(n_vars)]
pivot_cols.append(col)
r_piv += 1
rank = len(pivot_cols)
free_cols = [c for c in range(n_vars) if c not in pivot_cols]
basis_int: list[list[int]] = []
formatted: list[str] = []
for f_col in free_cols:
vec_q = [Fraction(0) for _ in range(n_vars)]
vec_q[f_col] = Fraction(1)
for row_idx, p_col in enumerate(pivot_cols):
vec_q[p_col] = -mat[row_idx][f_col]
lcm_den = 1
for q in vec_q:
lcm_den = math.lcm(lcm_den, q.denominator)
ints = [int(q * lcm_den) for q in vec_q]
nz = [abs(v) for v in ints if v != 0]
g = nz[0]
for val in nz[1:]:
g = math.gcd(g, val)
ints = [v // g for v in ints]
if ints[f_col] < 0:
ints = [-v for v in ints]
basis_int.append(ints)
num_terms = [f"{names[j]}^{ints[j]}" if ints[j] != 1 else names[j] for j in range(n_vars) if ints[j] > 0]
den_terms = [f"{names[j]}^{-ints[j]}" if ints[j] != -1 else names[j] for j in range(n_vars) if ints[j] < 0]
lhs = " * ".join(num_terms) if num_terms else "1"
rhs = " * ".join(den_terms)
formatted.append(f"{lhs} / ({rhs})" if rhs else lhs)
pi_arr = np.array(basis_int, dtype=int) if basis_int else np.zeros((0, n_vars), dtype=int)
residual = float(np.max(np.abs(np.asarray(dim_matrix, dtype=float) @ pi_arr.T))) if pi_arr.size else 0.0
return {
"rank": rank,
"n_pi_groups": len(free_cols),
"pivot_columns": pivot_cols,
"free_columns": free_cols,
"pi_exponents": pi_arr,
"formatted_groups": formatted,
"nullspace_residual": residual,
}
Variables: ['h', 'D', 'k', 'rho', 'U', 'mu', 'cp']
SVD Nullspace Row 0 (mixed irrational decimals): [-0.3387 0.2365 0.0433 0.5753 0.5753 -0.2798 0.2954]
Rational RREF Integer Rows:
[[-1 -1 1 0 0 0 0]
[ 0 -1 0 -1 -1 1 0]
[-1 0 0 1 1 0 1]]
Clean Physical Groups: ['k / (h * D)', 'mu / (D * rho * U)', 'rho * U * cp / (h)']
Subspace Projector Max |P_SVD - P_Rational| = 3.05e-16
Exercises¶
Worked solutions are in 01_solutions.ipynb. The cell below the list is a short self-check to start from.
Verify a result. Use
representation_scaling.buckingham_pi_nullspaceon(T_period, L, m, g)andCANONICAL_DIM_MATRICES['capillary_droplet_oscillation'], and verify numerical invariance of the capillary -groups across SI, CGS, and Imperial (slug, ft, s) unit systems.Find how it fails. Audit (a) omitting gravity in free-surface ship hull scaling (
1:25tow-tank test of a ship cruising at ), and (b) adding a redundantForcerow (Force = M L T^-2) to a 4-variable Hookean spring-mass matrix where naive fails.Implement it yourself. Implement
nondimensional_data_collapse_fitter(dim_matrix, data_columns, target_col=0, var_names=None)that isolatestarget_colinto (exponent +1) by placing repeating basis variables beforetarget_col, computes all input , and fits in log space. Test on synthetic multi-fluid convective heat-transfer data governed by Dittus–Boelter .
heading("Self-check for the exercises")
assert abs(emp_slope - 0.40) < 0.012 and 16.0 < yield_kt_tnt < 19.5
assert smooth_pi["n_pi_groups"] == 2 and rel_collapse_rms < 0.025
assert cmp_null["projector_max_diff"] < 1.0e-14
print("All checks passed.")
Self-check for the exercises
============================
All checks passed.