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. A script is self-contained: the shape functions it uses are
4// ordinary MATLAB functions written at the bottom of the script itself.
6export interface Preset {
7 id: string;
8 label: string;
9 source: string;
10}
12const flatRectangle = `% A flat rectangular sheet of stainless steel, hanging freely.
13% The script is an ordinary MATLAB program that fills in a struct named
14% design. Lengths are meters; the constants at the top are the only units.
15% A field can be a number or a function handle @(x, y, r, theta) of the
16% point, measured from the center of the bounding box; the handles are
17% applied to whole grid matrices, so use elementwise operators (.*, ./, .^)
18% inside them. Anything else a script needs it defines itself, as MATLAB
19% functions at the bottom; the other presets show how. The decay of the
20% sound is not prescribed: it follows from the loss factor of the metal, its
21% thermal constants (thermoelastic damping), the radiation of each mode into
22% the air.
23inch = 0.0254; % m
24mm = 1e-3; % m
26design.name = 'Flat steel rectangle';
27design.material.E = 170e9; % Young's modulus [Pa]
28design.material.nu = 0.29; % Poisson ratio
29design.material.rho = 7900; % density [kg/m^3]
30design.material.lossFactor = 3e-4; % internal friction of the metal (typical published value)
31design.material.alpha = 17e-6; % thermal expansion [1/K] } for the thermoelastic damping
32design.material.cp = 500; % specific heat [J/(kg K)] }
33design.material.k = 16; % conductivity [W/(m K)] }
34design.bounds.width = 12*inch; % bounding box [m]
35design.bounds.height = 18*inch;
36design.thickness = 0.79*mm;
37`;
39const aluminumSquare = `% A flat 12 inch square of 6061-T6 aluminum, 1.02 mm thick, with a center
40% hole. Aluminum is a third the density of steel and a third as stiff, so
41% the bending frequencies land near those of a steel plate of the same size
42% and thickness. Its high thermal expansion and conductivity give it the
43% strongest thermoelastic damping of the three metals here.
44inch = 0.0254; mm = 1e-3;
45W = 12*inch; hole = 13*mm;
47design.name = 'Aluminum 6061-T6 square';
48design.material.E = 68.9e9; % Young's modulus [Pa]
49design.material.nu = 0.33; % Poisson ratio
50design.material.rho = 2700; % density [kg/m^3]
51design.material.lossFactor = 1e-4; % internal friction of the metal (typical published value)
52design.material.alpha = 23.6e-6; % thermal expansion [1/K] } for the thermoelastic damping
53design.material.cp = 896; % specific heat [J/(kg K)] }
54design.material.k = 167; % conductivity [W/(m K)] }
55design.bounds.width = W;
56design.bounds.height = W;
57design.inside = @(x, y, r, theta) r >= hole/2;
58design.thickness = 1.02*mm;
59`;
61const bowedRectangle = `% The same steel sheet with a 3 mm parabolic bow across its width, the
62% kind of bow that rolling and handling leave in real sheet metal. The bow
63% makes the sheet a shallow shell: the linear modes couple bending to
64% stretching, and the full simulation oil-cans and wobbles when struck.
65inch = 0.0254; mm = 1e-3;
66W = 12*inch; H = 18*inch;
68design.name = 'Bowed steel rectangle';
69design.material.E = 170e9;
70design.material.nu = 0.29;
71design.material.rho = 7900;
72design.material.lossFactor = 3e-4; % internal friction of the metal (typical published value)
73design.material.alpha = 17e-6; % thermal expansion [1/K] } for the thermoelastic damping
74design.material.cp = 500; % specific heat [J/(kg K)] }
75design.material.k = 16; % conductivity [W/(m K)] }
76design.bounds.width = W;
77design.bounds.height = H;
78design.thickness = 0.79*mm;
79design.profile = @(x, y, r, theta) bow(x, W, 3*mm, 0.3); % stress-free height [m]
81function v = bow(s, span, sag, offset)
82% A parabola of the given sag across a span centered on 0; s runs along the
83% span, and the offset in -1..1 moves the crest toward one end.
84t = 2*s/span;
85v = sag * (1 - t.^2) .* (1 + offset*t);
86end
87`;
89const flatDisc = `% A flat 16 inch bronze disc with a center hole, hanging freely.
90inch = 0.0254; mm = 1e-3;
91D = 16*inch; hole = 13*mm;
93design.name = 'Flat bronze disc';
94design.material.E = 110e9; % bronze
95design.material.nu = 0.34;
96design.material.rho = 8800;
97design.material.lossFactor = 2e-4; % internal friction of the metal (typical published value)
98design.material.alpha = 18e-6; % thermal expansion [1/K] } for the thermoelastic damping
99design.material.cp = 370; % specific heat [J/(kg K)] }
100design.material.k = 40; % conductivity [W/(m K)] }
101design.bounds.width = D;
102design.bounds.height = D;
103design.inside = @(x, y, r, theta) (r <= D/2) & (r >= hole/2);
104design.thickness = 1.0*mm;
105`;
107const crash16 = `% A 16 inch flat crash: bronze, lathed to a taper from 1.2 mm at the
108% center to 0.7 mm at the edge, with a center hole. Flat, so
109% the linear modes are pure bending modes; the tapered profile is what
110% makes it a crash rather than a ride.
111inch = 0.0254; mm = 1e-3;
112D = 16*inch; R = D/2; hole = 13*mm;
113tCenter = 1.2*mm; tEdge = 0.7*mm;
115design.name = '16 inch flat crash';
116design.material.E = 110e9;
117design.material.nu = 0.34;
118design.material.rho = 8800;
119design.material.lossFactor = 2e-4; % internal friction of the metal (typical published value)
120design.material.alpha = 18e-6; % thermal expansion [1/K] } for the thermoelastic damping
121design.material.cp = 370; % specific heat [J/(kg K)] }
122design.material.k = 40; % conductivity [W/(m K)] }
123design.bounds.width = D;
124design.bounds.height = D;
125design.inside = @(x, y, r, theta) (r <= R) & (r >= hole/2);
126design.thickness = @(x, y, r, theta) tCenter + (tEdge - tCenter) * ramp(40*mm, R, r);
128function v = ramp(a, b, x)
129% 0 at x = a, 1 at x = b, clamped to that range outside.
130v = min(max((x - a) ./ (b - a), 0), 1);
131end
132`;
134const ride20 = `% A 20 inch flat ride: thicker bronze, 2.2 mm at the center to 1.4 mm at
135% the edge, with a center hole. The thickness raises every frequency in
136% proportion, and the ride has a clearer ping and a longer decay than the
137% crash.
138inch = 0.0254; mm = 1e-3;
139D = 20*inch; R = D/2; hole = 13*mm;
141design.name = '20 inch flat ride';
142design.material.E = 110e9;
143design.material.nu = 0.34;
144design.material.rho = 8800;
145design.material.lossFactor = 2e-4; % internal friction of the metal (typical published value)
146design.material.alpha = 18e-6; % thermal expansion [1/K] } for the thermoelastic damping
147design.material.cp = 370; % specific heat [J/(kg K)] }
148design.material.k = 40; % conductivity [W/(m K)] }
149design.bounds.width = D;
150design.bounds.height = D;
151design.inside = @(x, y, r, theta) (r <= R) & (r >= hole/2);
152design.thickness = @(x, y, r, theta) 2.2*mm + (1.4*mm - 2.2*mm) * ramp(50*mm, R, r);
154function v = ramp(a, b, x)
155v = min(max((x - a) ./ (b - a), 0), 1);
156end
157`;
159const crashBell16 = `% A 16 inch crash with a shallow bow and a cosine bell. The
160% profile makes the cymbal a shallow shell: the linear model couples the
161% bending to the stretching (a larger eigenproblem, so the modes take
162% longer), and the full simulation shows the asymmetric nonlinearity of a
163% curved plate. The slopes are kept small; the interface reports the
164% largest one.
165inch = 0.0254; mm = 1e-3;
166D = 16*inch; R = D/2; hole = 13*mm;
167bellR = 55*mm; bellH = 8*mm; bowH = 10*mm;
168tCenter = 1.2*mm; tEdge = 0.7*mm;
170design.name = '16 inch crash with bell';
171design.material.E = 110e9;
172design.material.nu = 0.34;
173design.material.rho = 8800;
174design.material.lossFactor = 2e-4; % internal friction of the metal (typical published value)
175design.material.alpha = 18e-6; % thermal expansion [1/K] } for the thermoelastic damping
176design.material.cp = 370; % specific heat [J/(kg K)] }
177design.material.k = 40; % conductivity [W/(m K)] }
178design.bounds.width = D;
179design.bounds.height = D;
180design.inside = @(x, y, r, theta) (r <= R) & (r >= hole/2);
181design.thickness = @(x, y, r, theta) tCenter + (tEdge - tCenter) * ramp(bellR, R, r);
182design.profile = @(x, y, r, theta) bowH * (1 - (r/R).^2) + dome(r, bellR, bellH);
184function v = ramp(a, b, x)
185v = min(max((x - a) ./ (b - a), 0), 1);
186end
188function v = dome(d, radius, height)
189% A cosine dome of the given height and base radius, with zero slope both at
190% its rim and at its apex; d is the distance from its center.
191v = 0.5 * height * (1 + cos(pi * d / radius)) .* (d < radius);
192end
193`;
195const ellipse = `% An elliptical steel plate. The outline is any test on the point;
196% an ellipse inscribed in the bounding box here. The degenerate mode pairs
197% of a disc split on an ellipse, which the mode browser shows.
198inch = 0.0254; mm = 1e-3;
199A = 14*inch; B = 10*inch;
201design.name = 'Steel ellipse';
202design.material.E = 170e9;
203design.material.nu = 0.29;
204design.material.rho = 7900;
205design.material.lossFactor = 3e-4; % internal friction of the metal (typical published value)
206design.material.alpha = 17e-6; % thermal expansion [1/K] } for the thermoelastic damping
207design.material.cp = 500; % specific heat [J/(kg K)] }
208design.material.k = 16; % conductivity [W/(m K)] }
209design.bounds.width = A;
210design.bounds.height = B;
211design.inside = @(x, y, r, theta) (x/(A/2)).^2 + (y/(B/2)).^2 <= 1;
212design.thickness = 1.0*mm;
213`;
215const thunderSheet = `% A thunder sheet: a large thin steel sheet, hung from a corner in reality.
216% Its modes are dense and low, and the full simulation turns a hard hit into
217% a roar.
218% Long at the default spacing; a coarser grid keeps it interactive.
219inch = 0.0254; mm = 1e-3;
221design.name = 'Thunder sheet';
222design.material.E = 200e9;
223design.material.nu = 0.3;
224design.material.rho = 7850;
225design.material.lossFactor = 3e-4; % internal friction of the metal (typical published value)
226design.material.alpha = 12e-6; % thermal expansion [1/K] } for the thermoelastic damping
227design.material.cp = 460; % specific heat [J/(kg K)] }
228design.material.k = 50; % conductivity [W/(m K)] }
229design.bounds.width = 24*inch;
230design.bounds.height = 36*inch;
231design.thickness = 0.5*mm;
232`;
234export const PRESETS: Preset[] = [
235 { id: "flat-rectangle", label: "Flat steel rectangle", source: flatRectangle },
236 { id: "aluminum-square", label: "Aluminum 6061-T6 square", source: aluminumSquare },
237 { id: "bowed-rectangle", label: "Bowed steel rectangle", source: bowedRectangle },
238 { id: "flat-disc", label: "Flat bronze disc", source: flatDisc },
239 { id: "crash-16", label: "16 inch flat crash", source: crash16 },
240 { id: "ride-20", label: "20 inch flat ride", source: ride20 },
241 { id: "crash-bell-16", label: "16 inch crash with bell", source: crashBell16 },
242 { id: "ellipse", label: "Steel ellipse", source: ellipse },
243 { id: "thunder-sheet", label: "Thunder sheet", source: thunderSheet },
244];
246export const DEFAULT_PRESET = "crash-16";
248export function presetById(id: string): Preset | undefined {
249 return PRESETS.find((p) => p.id === id);
250}