// 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 and mhelpers.ts for the helper functions in scope. export interface Preset { id: string; label: string; source: string; } const flatRectangle = `% A flat rectangular sheet of stainless steel, hanging freely (no mount). % Lengths are meters; inch and mm are conversion constants. The script fills % in a struct named design. 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. 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.profile = 0; % stress-free height [m]: flat design.mount = []; % free plate design.loss.sigma0 = 1.15; % frequency-independent loss [1/s] design.loss.sigma1 = 5e-4; % loss proportional to k^2 [m^2/s] design.loss.sigmaIn = 20; % extra loss of the in-plane motion [1/s] `; 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, which oil-cans and wobbles when struck. 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; % bow(s, span, sag, offset): parabola of the given sag across the span; the % offset in -1..1 moves the crest toward one edge. design.profile = @(x, y, r, theta) bow(x, W, 3*mm, 0.3); design.mount = []; design.loss.sigma0 = 1.15; design.loss.sigma1 = 5e-4; design.loss.sigmaIn = 20; `; const flatDisc = `% A flat 16 inch steel disc with a center hole, sitting on a stand: the % nodes within the mount radius are tied to the ground by a spring (the felt) % and a dashpot, spread over the mount area. D = 16*inch; design.name = 'Flat steel disc'; design.material.E = 170e9; design.material.nu = 0.29; design.material.rho = 7900; design.bounds.width = D; design.bounds.height = D; design.inside = circle(D, 12*mm); % diameter, hole diameter design.thickness = 1.0*mm; design.profile = 0; design.mount.radius = 20*mm; % felt radius design.mount.stiffness = 2e4; % [N/m] design.mount.damping = 5; % [N s/m] design.loss.sigma0 = 1.15; design.loss.sigma1 = 5e-4; design.loss.sigmaIn = 20; `; const crash16 = `% A 16 inch crash: B20 bronze, tapered from the bell to the edge, with a % shallow bow and a cosine bell. The shallow-shell model behind the % simulation is strained where the slope of the profile exceeds about 0.1 % to 0.2, so the bow and the bell are a little flatter than on a real crash. D = 16*inch; R = D/2; bellR = 60*mm; bellH = 12*mm; % base radius and height of the bell bowH = 16*mm; % rise from the edge to the foot of the bell design.name = '16 inch crash'; design.material.E = 110e9; design.material.nu = 0.34; design.material.rho = 8800; design.bounds.width = D; design.bounds.height = D; design.inside = circle(D, 12*mm); % Taper: 1.4 mm at the bell, 0.8 mm at the edge. design.thickness = @(x, y, r, theta) lerp(1.4*mm, 0.8*mm, clamp((r - bellR) ./ (R - bellR), 0, 1)); % A paraboloidal bow plus the bell; dome(d, radius, height) has zero slope at its rim. design.profile = @(x, y, r, theta) bowH * (1 - (r/R).^2) + dome(r, bellR, bellH); design.mount.radius = 20*mm; design.mount.stiffness = 2e4; design.mount.damping = 5; design.loss.sigma0 = 0.6; design.loss.sigma1 = 2.5e-4; design.loss.sigmaIn = 20; `; const crashDented = `% A 16 inch crash that has been through a lot: the same bronze, taper, % bow, and bell as the clean crash, plus a dozen dents scattered over the % bow and a faint hammering texture. The dents are Gaussian bumps of a few % centimeters (broad compared with the 8 mm grid) and a millimeter or two % in height, up or down; change the seed for a different set. Dents break % the symmetry of the disc, split the degenerate mode pairs, and give the % cymbal a less pure, more trashy tone. D = 16*inch; R = D/2; bellR = 60*mm; bellH = 12*mm; bowH = 16*mm; % Twelve dents from a seeded generator (the same on every run). nd = 12; u = reshape(seededrand(7, 4*nd), 4, nd); % rows: radius, angle, size, height rr = bellR + 25*mm + (R - bellR - 45*mm) * u(1,:); % on the bow, clear of the bell and the edge th = 2*pi * u(2,:); cx = rr .* cos(th); cy = rr .* sin(th); rad = (18 + 14*u(3,:)) * mm; hgt = sign(u(4,:) - 0.5) .* (0.8 + 1.4*u(4,:)) * mm; hammer = noise2d(3, 40*mm); % unit RMS, correlation length 40 mm design.name = '16 inch crash, dented'; design.material.E = 110e9; design.material.nu = 0.34; design.material.rho = 8800; design.bounds.width = D; design.bounds.height = D; design.inside = circle(D, 12*mm); design.thickness = @(x, y, r, theta) lerp(1.4*mm, 0.8*mm, clamp((r - bellR) ./ (R - bellR), 0, 1)); design.profile = @(x, y, r, theta) bowH * (1 - (r/R).^2) + dome(r, bellR, bellH) ... + dents(x, y, cx, cy, rad, hgt) ... + 0.3*mm * hammer(x, y) .* smoothstep(bellR, bellR + 30*mm, r); % no hammering on the bell design.mount.radius = 20*mm; design.mount.stiffness = 2e4; design.mount.damping = 5; design.loss.sigma0 = 0.6; design.loss.sigma1 = 2.5e-4; design.loss.sigmaIn = 20; `; const ride20 = `% A 20 inch ride: heavier bronze, a larger bell, a flatter bow. The taper % is stronger than on the crash, and the mount is a little stiffer. D = 20*inch; R = D/2; bellR = 70*mm; bellH = 14*mm; bowH = 15*mm; design.name = '20 inch ride'; design.material.E = 110e9; design.material.nu = 0.34; design.material.rho = 8800; design.bounds.width = D; design.bounds.height = D; design.inside = circle(D, 12*mm); design.thickness = @(x, y, r, theta) lerp(2.0*mm, 1.1*mm, smoothstep(bellR, R, r)); design.profile = @(x, y, r, theta) bowH * (1 - (r/R).^2) + dome(r, bellR, bellH); design.mount.radius = 22*mm; design.mount.stiffness = 3e4; design.mount.damping = 8; design.loss.sigma0 = 0.5; design.loss.sigma1 = 2e-4; design.loss.sigmaIn = 20; `; const ellipseTwist = `% A steel ellipse with a saddle (twist) and a bow, hanging freely. The % twist raises two opposite quadrants and lowers the other two, which % breaks the symmetry of the disc modes. W = 14*inch; H = 20*inch; design.name = 'Steel ellipse with a twist'; design.material.E = 170e9; design.material.nu = 0.29; design.material.rho = 7900; design.bounds.width = W; design.bounds.height = H; design.inside = ellipse(W, H); design.thickness = 0.79*mm; % 2x/W and 2y/H run from -1 to 1 over the bounding box. design.profile = @(x, y, r, theta) 2*mm * (2*x/W) .* (2*y/H) + bow(y, H, 2*mm); design.mount = []; design.loss.sigma0 = 1.15; design.loss.sigma1 = 5e-4; design.loss.sigmaIn = 20; `; const china18 = `% An 18 inch china: a conical bow that falls from the bell toward a flange, % and an upturned edge that rises again over the outer 45 mm. The bell is % square-topped (a plateau with rounded shoulders). The edge slope is well % beyond the shallow-shell range, so this preset is the least trustworthy. D = 18*inch; R = D/2; bellR = 65*mm; bellH = 14*mm; flangeR = R - 45*mm; bowH = 14*mm; edgeH = 12*mm; design.name = '18 inch china'; design.material.E = 110e9; design.material.nu = 0.34; design.material.rho = 8800; design.bounds.width = D; design.bounds.height = D; design.inside = circle(D, 12*mm); design.thickness = @(x, y, r, theta) lerp(1.6*mm, 0.9*mm, smoothstep(bellR, flangeR, r)); design.profile = @(x, y, r, theta) bowH * max(0, 1 - r/flangeR) ... % cone down to the flange + edgeH * smoothstep(flangeR, R, r) ... % upturned edge + bellH * (1 - smoothstep(bellR - 20*mm, bellR, r)); % flat-topped bell design.mount.radius = 20*mm; design.mount.stiffness = 2e4; design.mount.damping = 5; design.loss.sigma0 = 0.7; design.loss.sigma1 = 3e-4; design.loss.sigmaIn = 20; `; 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 steel disc on a stand", source: flatDisc }, { id: "crash-16", label: "16 inch crash", source: crash16 }, { id: "crash-16-dented", label: "16 inch crash, dented", source: crashDented }, { id: "ride-20", label: "20 inch ride", source: ride20 }, { id: "ellipse-twist", label: "Steel ellipse with a twist", source: ellipseTwist }, { id: "china-18", label: "18 inch china", source: china18 }, ]; export const DEFAULT_PRESET = PRESETS[0];