// Predefined design scripts, selectable from the interface. Each is a // MATLAB-syntax script that fills in the `design` struct; see design.ts for // the fields. A script is self-contained: the shape functions it uses are // ordinary MATLAB functions written at the bottom of the script itself. export interface Preset { id: string; label: string; source: string; } const flatRectangle = `% A flat rectangular sheet of stainless steel, hanging freely (no stand). % The script is an ordinary MATLAB program that fills in a struct named % design. Lengths are meters; the constants at the top are the only units. % A field can be a number or a function handle @(x, y, r, theta) of the % point, measured from the center of the bounding box; the handles are % applied to whole grid matrices, so use elementwise operators (.*, ./, .^) % inside them. Anything else a script needs it defines itself, as MATLAB % functions at the bottom; the other presets show how. inch = 0.0254; % m mm = 1e-3; % m design.name = 'Flat steel rectangle'; design.material.E = 170e9; % Young's modulus [Pa] design.material.nu = 0.29; % Poisson ratio design.material.rho = 7900; % density [kg/m^3] design.bounds.width = 12*inch; % bounding box [m] design.bounds.height = 18*inch; design.thickness = 0.79*mm; design.stand = []; % free plate design.loss.T60 = @(f) 3 ./ (1 + f/1500); % decay time [s] as a function of frequency [Hz] `; const bowedRectangle = `% The same steel sheet with a 3 mm parabolic bow across its width, the % kind of bow that rolling and handling leave in real sheet metal. The bow % makes the sheet a shallow shell: the linear modes couple bending to % stretching, and the full simulation oil-cans and wobbles when struck. inch = 0.0254; mm = 1e-3; W = 12*inch; H = 18*inch; design.name = 'Bowed steel rectangle'; design.material.E = 170e9; design.material.nu = 0.29; design.material.rho = 7900; design.bounds.width = W; design.bounds.height = H; design.thickness = 0.79*mm; design.profile = @(x, y, r, theta) bow(x, W, 3*mm, 0.3); % stress-free height [m] design.stand = []; design.loss.T60 = @(f) 3 ./ (1 + f/1500); function v = bow(s, span, sag, offset) % A parabola of the given sag across a span centered on 0; s runs along the % span, and the offset in -1..1 moves the crest toward one end. t = 2*s/span; v = sag * (1 - t.^2) .* (1 + offset*t); end `; const flatDisc = `% A flat 16 inch bronze disc with a center hole on a cymbal stand. The % stand is a rod through the hole with a felt pad below the plate and % another above it under the wing nut; each pad is an annulus of felt of % the given radii and thickness, and its stiffness per unit area is E over % the thickness. The pads hold the disc level and let it bounce and rock. inch = 0.0254; mm = 1e-3; D = 16*inch; hole = 13*mm; design.name = 'Flat bronze disc'; design.material.E = 110e9; % bronze design.material.nu = 0.34; design.material.rho = 8800; design.bounds.width = D; design.bounds.height = D; design.inside = @(x, y, r, theta) (r <= D/2) & (r >= hole/2); design.thickness = 1.0*mm; design.stand.pad.innerRadius = 7*mm; % the felt sits on the plastic sleeve of the rod design.stand.pad.outerRadius = 20*mm; design.stand.pad.thickness = 12*mm; design.stand.pad.E = 0.5e6; % Pa, felt in compression design.stand.pad.lossFactor = 0.3; design.stand.topPad = true; design.stand.preload = 1*mm; % compression of the top pad by the wing nut design.loss.T60 = @(f) 4 ./ (1 + f/2000); `; const crash16 = `% A 16 inch flat crash: bronze, lathed to a taper from 1.2 mm at the % center to 0.7 mm at the edge, on a stand. Flat, so the linear modes are % pure bending modes; the tapered profile is what makes it a crash rather % than a ride. inch = 0.0254; mm = 1e-3; D = 16*inch; R = D/2; hole = 13*mm; tCenter = 1.2*mm; tEdge = 0.7*mm; design.name = '16 inch flat crash'; design.material.E = 110e9; design.material.nu = 0.34; design.material.rho = 8800; design.bounds.width = D; design.bounds.height = D; design.inside = @(x, y, r, theta) (r <= R) & (r >= hole/2); design.thickness = @(x, y, r, theta) tCenter + (tEdge - tCenter) * ramp(40*mm, R, r); design.stand.pad.innerRadius = 7*mm; design.stand.pad.outerRadius = 20*mm; design.stand.pad.thickness = 12*mm; design.stand.pad.E = 0.5e6; design.stand.pad.lossFactor = 0.3; design.stand.topPad = true; design.stand.preload = 1*mm; design.loss.T60 = [100 5; 1000 3.5; 5000 1.2; 15000 0.4]; % table of [Hz seconds], interpolated function v = ramp(a, b, x) % 0 at x = a, 1 at x = b, clamped to that range outside. v = min(max((x - a) ./ (b - a), 0), 1); end `; const ride20 = `% A 20 inch flat ride: thicker bronze, 2.2 mm at the center to 1.4 mm at % the edge, on a stand with a loose wing nut (a small preload). The % thickness raises every frequency in proportion, and the ride has a % clearer ping and a longer decay than the crash. inch = 0.0254; mm = 1e-3; D = 20*inch; R = D/2; hole = 13*mm; design.name = '20 inch flat ride'; design.material.E = 110e9; design.material.nu = 0.34; design.material.rho = 8800; design.bounds.width = D; design.bounds.height = D; design.inside = @(x, y, r, theta) (r <= R) & (r >= hole/2); design.thickness = @(x, y, r, theta) 2.2*mm + (1.4*mm - 2.2*mm) * ramp(50*mm, R, r); design.stand.pad.innerRadius = 7*mm; design.stand.pad.outerRadius = 22*mm; design.stand.pad.thickness = 12*mm; design.stand.pad.E = 0.5e6; design.stand.pad.lossFactor = 0.3; design.stand.topPad = true; design.stand.preload = 0.3*mm; design.loss.T60 = @(f) 8 ./ (1 + f/2500); function v = ramp(a, b, x) v = min(max((x - a) ./ (b - a), 0), 1); end `; const crashBell16 = `% A 16 inch crash with a shallow bow and a cosine bell, on a stand. The % profile makes the cymbal a shallow shell: the linear model couples the % bending to the stretching (a larger eigenproblem, so the modes take % longer), and the full simulation shows the asymmetric nonlinearity of a % curved plate. The slopes are kept small; the interface reports the % largest one. inch = 0.0254; mm = 1e-3; D = 16*inch; R = D/2; hole = 13*mm; bellR = 55*mm; bellH = 8*mm; bowH = 10*mm; tCenter = 1.2*mm; tEdge = 0.7*mm; design.name = '16 inch crash with bell'; design.material.E = 110e9; design.material.nu = 0.34; design.material.rho = 8800; design.bounds.width = D; design.bounds.height = D; design.inside = @(x, y, r, theta) (r <= R) & (r >= hole/2); design.thickness = @(x, y, r, theta) tCenter + (tEdge - tCenter) * ramp(bellR, R, r); design.profile = @(x, y, r, theta) bowH * (1 - (r/R).^2) + dome(r, bellR, bellH); design.stand.pad.innerRadius = 7*mm; design.stand.pad.outerRadius = 20*mm; design.stand.pad.thickness = 12*mm; design.stand.pad.E = 0.5e6; design.stand.pad.lossFactor = 0.3; design.stand.topPad = true; design.stand.preload = 1*mm; design.loss.T60 = [100 5; 1000 3.5; 5000 1.2; 15000 0.4]; function v = ramp(a, b, x) v = min(max((x - a) ./ (b - a), 0), 1); end function v = dome(d, radius, height) % A cosine dome of the given height and base radius, with zero slope both at % its rim and at its apex; d is the distance from its center. v = 0.5 * height * (1 + cos(pi * d / radius)) .* (d < radius); end `; const ellipse = `% A free elliptical steel plate. The outline is any test on the point; % an ellipse inscribed in the bounding box here. The degenerate mode pairs % of a disc split on an ellipse, which the mode browser shows. inch = 0.0254; mm = 1e-3; A = 14*inch; B = 10*inch; design.name = 'Steel ellipse'; design.material.E = 170e9; design.material.nu = 0.29; design.material.rho = 7900; design.bounds.width = A; design.bounds.height = B; design.inside = @(x, y, r, theta) (x/(A/2)).^2 + (y/(B/2)).^2 <= 1; design.thickness = 1.0*mm; design.stand = []; design.loss.T60 = @(f) 3 ./ (1 + f/1500); `; const thunderSheet = `% A thunder sheet: a large thin steel sheet hung from one corner. Its modes % are dense and low, and the full simulation turns a hard hit into a roar. % Long at the default spacing; a coarser grid keeps it interactive. inch = 0.0254; mm = 1e-3; design.name = 'Thunder sheet'; design.material.E = 200e9; design.material.nu = 0.3; design.material.rho = 7850; design.bounds.width = 24*inch; design.bounds.height = 36*inch; design.thickness = 0.5*mm; design.stand = []; design.loss.T60 = @(f) 2.5 ./ (1 + f/1000); `; export const PRESETS: Preset[] = [ { id: "flat-rectangle", label: "Flat steel rectangle", source: flatRectangle }, { id: "bowed-rectangle", label: "Bowed steel rectangle", source: bowedRectangle }, { id: "flat-disc", label: "Flat bronze disc on a stand", source: flatDisc }, { id: "crash-16", label: "16 inch flat crash", source: crash16 }, { id: "ride-20", label: "20 inch flat ride", source: ride20 }, { id: "crash-bell-16", label: "16 inch crash with bell", source: crashBell16 }, { id: "ellipse", label: "Steel ellipse", source: ellipse }, { id: "thunder-sheet", label: "Thunder sheet", source: thunderSheet }, ]; export const DEFAULT_PRESET = "crash-16"; export function presetById(id: string): Preset | undefined { return PRESETS.find((p) => p.id === id); }