/ proof-of-concept / cymbalsim
Sign in
proof-of-concept / cymbalsim
cymbalsim / src / mruntime.ts
33 lines · 1.2 KBCodeBlameHistory
5778036cymbalsim: scripted plate and cymbal designer with a modal linear model and a von Karman GPU modelJeremy Magland 1// The only .m file the simulator puts in scope of a design script. It is not
2// a design helper: the trailer that evaluatePlate appends calls it to sample
2a1a6daDerive the losses from physical constants instead of a prescribed decay curveJeremy Magland 3// a field (a number or a function handle) on the grid matrices, and to
4// report a bad return value in the script's own terms. Design scripts define
5// whatever shape functions they need themselves, at the bottom of the
6// script.
8import type { WorkspaceFile } from "numbl";
10const SAMPLE = `function v = cymbalsim_field(f, what, x, y, r, theta)
11% Samples a design field (a number or a function handle) on the grid matrices.
12if isa(f, 'function_handle')
13 try
14 v = f(x, y, r, theta);
15 catch e
16 error('%s: %s', what, e.message);
17 end
18elseif isnumeric(f) || islogical(f)
19 v = f;
20else
21 error('%s must be a number or a function handle @(x, y, r, theta)', what);
22end
23if isscalar(v)
24 v = double(v) * ones(size(x));
25elseif ~isequal(size(v), size(x))
26 error('%s returned a %d x %d array for a %d x %d grid; use elementwise operators (.*, ./, .^)', what, size(v, 1), size(v, 2), size(x, 1), size(x, 2));
27else
28 v = double(v);
29end
30end
31`;
2a1a6daDerive the losses from physical constants instead of a prescribed decay curveJeremy Magland 33export const RUNTIME_FILES: WorkspaceFile[] = [{ name: "cymbalsim_field.m", source: SAMPLE }];
↑↓ move↵openescclose