/ proof-of-concept / steelsim41
Sign in
proof-of-concept / steelsim41
steelsim41 / src / presets.ts
214 lines · 8.8 KBCodeBlameHistory
8db04e0Design scripts in MATLAB syntax, run by numblJeremy Magland 1// Predefined design scripts, selectable from the interface. Each is a
2// MATLAB-syntax script that fills in the `design` struct; see design.ts for
3// the fields and mhelpers.ts for the helper functions in scope.
5export interface Preset {
6 id: string;
7 label: string;
8 source: string;
9}
8db04e0Design scripts in MATLAB syntax, run by numblJeremy Magland 11const flatRectangle = `% A flat rectangular sheet of stainless steel, hanging freely (no mount).
12% Lengths are meters; inch and mm are conversion constants. The script fills
13% in a struct named design. A field can be a number or a function handle
14% @(x, y, r, theta) of the point, measured from the center of the bounding
15% box; the handles are applied to whole grid matrices, so use elementwise
16% operators (.*, ./, .^) inside them.
17design.name = 'Flat steel rectangle';
18design.material.E = 170e9; % Young's modulus [Pa]
19design.material.nu = 0.29; % Poisson ratio
20design.material.rho = 7900; % density [kg/m^3]
21design.bounds.width = 12*inch; % bounding box [m]
22design.bounds.height = 18*inch;
23design.thickness = 0.79*mm;
24design.profile = 0; % stress-free height [m]: flat
25design.mount = []; % free plate
26design.loss.sigma0 = 1.15; % frequency-independent loss [1/s]
27design.loss.sigma1 = 5e-4; % loss proportional to k^2 [m^2/s]
28design.loss.sigmaIn = 20; % extra loss of the in-plane motion [1/s]
8db04e0Design scripts in MATLAB syntax, run by numblJeremy Magland 31const bowedRectangle = `% The same steel sheet with a 3 mm parabolic bow across its width, the
32% kind of bow that rolling and handling leave in real sheet metal. The bow
33% makes the sheet a shallow shell, which oil-cans and wobbles when struck.
34W = 12*inch; H = 18*inch;
35design.name = 'Bowed steel rectangle';
36design.material.E = 170e9;
37design.material.nu = 0.29;
38design.material.rho = 7900;
39design.bounds.width = W;
40design.bounds.height = H;
41design.thickness = 0.79*mm;
42% bow(s, span, sag, offset): parabola of the given sag across the span; the
43% offset in -1..1 moves the crest toward one edge.
44design.profile = @(x, y, r, theta) bow(x, W, 3*mm, 0.3);
45design.mount = [];
46design.loss.sigma0 = 1.15;
47design.loss.sigma1 = 5e-4;
48design.loss.sigmaIn = 20;
8db04e0Design scripts in MATLAB syntax, run by numblJeremy Magland 51const flatDisc = `% A flat 16 inch steel disc with a center hole, sitting on a stand: the
52% nodes within the mount radius are tied to the ground by a spring (the felt)
53% and a dashpot, spread over the mount area.
54D = 16*inch;
55design.name = 'Flat steel disc';
56design.material.E = 170e9;
57design.material.nu = 0.29;
58design.material.rho = 7900;
59design.bounds.width = D;
60design.bounds.height = D;
61design.inside = circle(D, 12*mm); % diameter, hole diameter
62design.thickness = 1.0*mm;
63design.profile = 0;
64design.mount.radius = 20*mm; % felt radius
65design.mount.stiffness = 2e4; % [N/m]
66design.mount.damping = 5; % [N s/m]
67design.loss.sigma0 = 1.15;
68design.loss.sigma1 = 5e-4;
69design.loss.sigmaIn = 20;
8db04e0Design scripts in MATLAB syntax, run by numblJeremy Magland 72const crash16 = `% A 16 inch crash: B20 bronze, tapered from the bell to the edge, with a
73% shallow bow and a cosine bell. The shallow-shell model behind the
74% simulation is strained where the slope of the profile exceeds about 0.1
75% to 0.2, so the bow and the bell are a little flatter than on a real crash.
76D = 16*inch; R = D/2;
77bellR = 60*mm; bellH = 12*mm; % base radius and height of the bell
78bowH = 16*mm; % rise from the edge to the foot of the bell
79design.name = '16 inch crash';
80design.material.E = 110e9;
81design.material.nu = 0.34;
82design.material.rho = 8800;
83design.bounds.width = D;
84design.bounds.height = D;
85design.inside = circle(D, 12*mm);
86% Taper: 1.4 mm at the bell, 0.8 mm at the edge.
87design.thickness = @(x, y, r, theta) lerp(1.4*mm, 0.8*mm, clamp((r - bellR) ./ (R - bellR), 0, 1));
88% A paraboloidal bow plus the bell; dome(d, radius, height) has zero slope at its rim.
89design.profile = @(x, y, r, theta) bowH * (1 - (r/R).^2) + dome(r, bellR, bellH);
90design.mount.radius = 20*mm;
91design.mount.stiffness = 2e4;
92design.mount.damping = 5;
93design.loss.sigma0 = 0.6;
94design.loss.sigma1 = 2.5e-4;
95design.loss.sigmaIn = 20;
8db04e0Design scripts in MATLAB syntax, run by numblJeremy Magland 98const crashDented = `% A 16 inch crash that has been through a lot: the same bronze, taper,
99% bow, and bell as the clean crash, plus a dozen dents scattered over the
100% bow and a faint hammering texture. The dents are Gaussian bumps of a few
101% centimeters (broad compared with the 8 mm grid) and a millimeter or two
102% in height, up or down; change the seed for a different set. Dents break
103% the symmetry of the disc, split the degenerate mode pairs, and give the
104% cymbal a less pure, more trashy tone.
105D = 16*inch; R = D/2;
106bellR = 60*mm; bellH = 12*mm; bowH = 16*mm;
107% Twelve dents from a seeded generator (the same on every run).
108nd = 12;
109u = reshape(seededrand(7, 4*nd), 4, nd); % rows: radius, angle, size, height
110rr = bellR + 25*mm + (R - bellR - 45*mm) * u(1,:); % on the bow, clear of the bell and the edge
111th = 2*pi * u(2,:);
112cx = rr .* cos(th); cy = rr .* sin(th);
113rad = (18 + 14*u(3,:)) * mm;
114hgt = sign(u(4,:) - 0.5) .* (0.8 + 1.4*u(4,:)) * mm;
115hammer = noise2d(3, 40*mm); % unit RMS, correlation length 40 mm
116design.name = '16 inch crash, dented';
117design.material.E = 110e9;
118design.material.nu = 0.34;
119design.material.rho = 8800;
120design.bounds.width = D;
121design.bounds.height = D;
122design.inside = circle(D, 12*mm);
123design.thickness = @(x, y, r, theta) lerp(1.4*mm, 0.8*mm, clamp((r - bellR) ./ (R - bellR), 0, 1));
124design.profile = @(x, y, r, theta) bowH * (1 - (r/R).^2) + dome(r, bellR, bellH) ...
125 + dents(x, y, cx, cy, rad, hgt) ...
126 + 0.3*mm * hammer(x, y) .* smoothstep(bellR, bellR + 30*mm, r); % no hammering on the bell
127design.mount.radius = 20*mm;
128design.mount.stiffness = 2e4;
129design.mount.damping = 5;
130design.loss.sigma0 = 0.6;
131design.loss.sigma1 = 2.5e-4;
132design.loss.sigmaIn = 20;
8db04e0Design scripts in MATLAB syntax, run by numblJeremy Magland 135const ride20 = `% A 20 inch ride: heavier bronze, a larger bell, a flatter bow. The taper
136% is stronger than on the crash, and the mount is a little stiffer.
137D = 20*inch; R = D/2;
138bellR = 70*mm; bellH = 14*mm;
139bowH = 15*mm;
140design.name = '20 inch ride';
141design.material.E = 110e9;
142design.material.nu = 0.34;
143design.material.rho = 8800;
144design.bounds.width = D;
145design.bounds.height = D;
146design.inside = circle(D, 12*mm);
147design.thickness = @(x, y, r, theta) lerp(2.0*mm, 1.1*mm, smoothstep(bellR, R, r));
148design.profile = @(x, y, r, theta) bowH * (1 - (r/R).^2) + dome(r, bellR, bellH);
149design.mount.radius = 22*mm;
150design.mount.stiffness = 3e4;
151design.mount.damping = 8;
152design.loss.sigma0 = 0.5;
153design.loss.sigma1 = 2e-4;
154design.loss.sigmaIn = 20;
8db04e0Design scripts in MATLAB syntax, run by numblJeremy Magland 157const ellipseTwist = `% A steel ellipse with a saddle (twist) and a bow, hanging freely. The
158% twist raises two opposite quadrants and lowers the other two, which
159% breaks the symmetry of the disc modes.
160W = 14*inch; H = 20*inch;
161design.name = 'Steel ellipse with a twist';
162design.material.E = 170e9;
163design.material.nu = 0.29;
164design.material.rho = 7900;
165design.bounds.width = W;
166design.bounds.height = H;
167design.inside = ellipse(W, H);
168design.thickness = 0.79*mm;
169% 2x/W and 2y/H run from -1 to 1 over the bounding box.
170design.profile = @(x, y, r, theta) 2*mm * (2*x/W) .* (2*y/H) + bow(y, H, 2*mm);
171design.mount = [];
172design.loss.sigma0 = 1.15;
173design.loss.sigma1 = 5e-4;
174design.loss.sigmaIn = 20;
8db04e0Design scripts in MATLAB syntax, run by numblJeremy Magland 177const china18 = `% An 18 inch china: a conical bow that falls from the bell toward a flange,
178% and an upturned edge that rises again over the outer 45 mm. The bell is
179% square-topped (a plateau with rounded shoulders). The edge slope is well
180% beyond the shallow-shell range, so this preset is the least trustworthy.
181D = 18*inch; R = D/2;
182bellR = 65*mm; bellH = 14*mm;
183flangeR = R - 45*mm; bowH = 14*mm; edgeH = 12*mm;
184design.name = '18 inch china';
185design.material.E = 110e9;
186design.material.nu = 0.34;
187design.material.rho = 8800;
188design.bounds.width = D;
189design.bounds.height = D;
190design.inside = circle(D, 12*mm);
191design.thickness = @(x, y, r, theta) lerp(1.6*mm, 0.9*mm, smoothstep(bellR, flangeR, r));
192design.profile = @(x, y, r, theta) bowH * max(0, 1 - r/flangeR) ... % cone down to the flange
193 + edgeH * smoothstep(flangeR, R, r) ... % upturned edge
194 + bellH * (1 - smoothstep(bellR - 20*mm, bellR, r)); % flat-topped bell
195design.mount.radius = 20*mm;
196design.mount.stiffness = 2e4;
197design.mount.damping = 5;
198design.loss.sigma0 = 0.7;
199design.loss.sigma1 = 3e-4;
200design.loss.sigmaIn = 20;
203export const PRESETS: Preset[] = [
204 { id: "flat-rectangle", label: "Flat steel rectangle", source: flatRectangle },
205 { id: "bowed-rectangle", label: "Bowed steel rectangle", source: bowedRectangle },
206 { id: "flat-disc", label: "Flat steel disc on a stand", source: flatDisc },
207 { id: "crash-16", label: "16 inch crash", source: crash16 },
6edbaa3Add a dented 16 inch crash presetJeremy Magland 208 { id: "crash-16-dented", label: "16 inch crash, dented", source: crashDented },
1ee087eCymbal designer: scripted design, thickness field, mount, single strikeJeremy Magland 209 { id: "ride-20", label: "20 inch ride", source: ride20 },
210 { id: "ellipse-twist", label: "Steel ellipse with a twist", source: ellipseTwist },
211 { id: "china-18", label: "18 inch china", source: china18 },
212];
214export const DEFAULT_PRESET = PRESETS[0];
↑↓ move↵openescclose