// The parametric body: a few named low modes (A0 air mode, the main corpus modes) given directly, // plus a statistical continuation of the plate modes above them (random frequencies with the // plate's modal density and level-repulsed spacing, Gaussian mode shapes at the bridge feet with // the mean square fixed by the plate mass, filtered by the bridge's own in-plane resonance, and a // radiation coefficient from the plate's radiation efficiency). The FE body (../fe) reuses // statisticalModes() above its own f max. import type { Params } from "./params.ts"; import type { BodyMode, BodyModel } from "./types.ts"; import { N_STRINGS } from "./types.ts"; /** Small deterministic PRNG (mulberry32) and a Gaussian from it. */ export function rng(seed: number) { let a = (seed * 2654435761) >>> 0 || 1; const uni = () => { a = (a + 0x6d2b79f5) >>> 0; let t = a; t = Math.imul(t ^ (t >>> 15), t | 1); t ^= t + Math.imul(t ^ (t >>> 7), t | 61); return ((t ^ (t >>> 14)) >>> 0) / 4294967296; }; const gauss = () => { const u = Math.max(uni(), 1e-12), v = uni(); return Math.sqrt(-2 * Math.log(u)) * Math.cos(2 * Math.PI * v); }; return { uni, gauss }; } /** Lateral positions of the string notches on the bridge top (E on the bass side, negative). */ export function notchPositions(spacing: number): number[] { return Array.from({ length: N_STRINGS }, (_, i) => (i - (N_STRINGS - 1) / 2) * spacing); } /** Second-order resonance gain magnitude |1 / (1 - r^2 + i r / Q)|, r = f / f0. */ function resGain(f: number, f0: number, q: number): number { const r = f / f0; return 1 / Math.hypot(1 - r * r, r / q); } const FOOT_HALF_SPAN = 0.06; // m, half the bridge foot spacing (rotation of the feet line) export interface StatOpts { fLow: number; fHigh: number; /** modes per Hz (plate-like: constant) */ density: number; /** plate mass, kg: the mean square of a mass-normalised mode shape at a point is 1/mass */ mass: number; lossFactor: (f: number) => number; /** lateral (rocking) coupling relative to the rotation of the feet */ lateralRatio: number; bridgeF: number; bridgeQ: number; radCorner: number; radScale: number; plateArea: number; notchY: number[]; micDistance: number; airRho: number; seed: number; } /** * Statistical plate modes. Spacing: Wigner surmise (level repulsion, as for chaotic plate shapes), * mean 1/density. Mode shape values at the two feet: independent Gaussians with mean square 1/mass. * The notch sees the feet through the bridge: vertical = mean of the feet (via a stiff vertical * bridge resonance at 2.5 bridgeF), lateral = rocking of the feet line (via the in-plane bridge * resonance bridgeF), and the notch's vertical motion includes the rotation times its lateral * position. Radiation: a mode with spatial-mean-square velocity v^2 radiates power * rho c sigma A v^2; spread over a sphere this gives |p| per unit modal acceleration of * rho c sqrt(sigma A / M) / (w d sqrt(4 pi)), with sigma = radScale (f/fc)^2 / (1 + (f/fc)^2), * and a random phase. */ export function statisticalModes(o: StatOpts): BodyMode[] { const r = rng(o.seed); const modes: BodyMode[] = []; const c = 343; const rms = 1 / Math.sqrt(o.mass); let f = o.fLow + r.uni() / o.density; while (f < o.fHigh) { const fb = r.gauss() * rms, ft = r.gauss() * rms; // bass foot, treble foot const gv = resGain(f, 2.5 * o.bridgeF, o.bridgeQ); const gl = resGain(f, o.bridgeF, o.bridgeQ); const v = 0.5 * (fb + ft) * gv; const rot = ((ft - fb) / (2 * FOOT_HALF_SPAN)) * gv; // rad per unit eta const lat = -o.lateralRatio * (ft - fb) * gl; const by = o.notchY.map((y) => v + rot * y); const bz = o.notchY.map(() => lat); const w = 2 * Math.PI * f; const x = f / o.radCorner; const sigma = (o.radScale * x * x) / (1 + x * x); const amp = (o.airRho * c * Math.sqrt((sigma * o.plateArea) / o.mass)) / (w * o.micDistance * Math.sqrt(4 * Math.PI)); const ph = 2 * Math.PI * r.uni(); modes.push({ f, zeta: 0.5 * o.lossFactor(f), by, bz, radRe: amp * Math.cos(ph), radIm: amp * Math.sin(ph) }); // Wigner surmise spacing, mean 1: s = sqrt(-4/pi ln u) const s = Math.sqrt((-4 / Math.PI) * Math.log(Math.max(r.uni(), 1e-12))); f += s / o.density; } return modes; } /** Modal density (modes per Hz) of a thin orthotropic plate of area A: (A/2) sqrt(rho h / sqrt(D11 D22)). */ export function plateDensity(area: number, h: number, rho: number, eL: number, eR: number, nu: number): number { const d11 = (eL * h ** 3) / (12 * (1 - nu * nu * (eR / eL))); const d22 = (eR * h ** 3) / (12 * (1 - nu * nu * (eR / eL))); return (area / 2) * Math.sqrt((rho * h) / Math.sqrt(d11 * d22)); } export function parametricBody(p: Params): BodyModel { const b = p.body; const notchY = notchPositions(p.fe.stringSpacing); const H = p.fe.bridgeHeight; const rho0 = p.fe.airRho; const d = p.output.micDistance; const modes: BodyMode[] = []; const r = rng(b.seed * 7919 + 13); for (const m of b.lowModes) { const v = 1 / Math.sqrt(m.mass); const lat = m.lateral * v * (r.uni() < 0.5 ? -1 : 1); // rigid bridge: lateral motion at the notches = -H * rotation, so rotation = -lat / H const rot = -lat / H; modes.push({ f: m.f, zeta: 1 / (2 * m.q), by: notchY.map((y) => v + rot * y), bz: notchY.map(() => lat), // monopole: m.rad is the volume displaced per unit (vertical) bridge displacement, m^2 radRe: (rho0 * m.rad * v) / (4 * Math.PI * d), radIm: 0, label: m.label, }); } const density = b.densityScale * plateDensity(b.plateArea, p.fe.topThickness, p.fe.topRho, p.fe.topEL, p.fe.topER, p.fe.topNu); const stat = statisticalModes({ fLow: b.statFLow, fHigh: b.statFHigh, density, mass: b.plateMass, lossFactor: (f) => b.lossFactor * Math.pow(f / 1000, b.lossExp), lateralRatio: b.lateralRatio, bridgeF: b.bridgeF, bridgeQ: b.bridgeQ, radCorner: b.radCorner, radScale: b.radScale, plateArea: b.plateArea, notchY, micDistance: d, airRho: rho0, seed: b.seed, }); modes.push(...stat); return { name: "parametric", source: "parametric", modes, meta: { lowModes: b.lowModes.length, statModes: stat.length, density } }; }