// The only .m file the simulator puts in scope of a design script. It is not // a design helper: the trailer that evaluatePlate appends calls it to sample // a field (a number or a function handle) on the grid matrices, and to // report a bad return value in the script's own terms. Design scripts define // whatever shape functions they need themselves, at the bottom of the // script. import type { WorkspaceFile } from "numbl"; const SAMPLE = `function v = cymbalsim_field(f, what, x, y, r, theta) % Samples a design field (a number or a function handle) on the grid matrices. if isa(f, 'function_handle') try v = f(x, y, r, theta); catch e error('%s: %s', what, e.message); end elseif isnumeric(f) || islogical(f) v = f; else error('%s must be a number or a function handle @(x, y, r, theta)', what); end if isscalar(v) v = double(v) * ones(size(x)); elseif ~isequal(size(v), size(x)) 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)); else v = double(v); end end `; export const RUNTIME_FILES: WorkspaceFile[] = [{ name: "cymbalsim_field.m", source: SAMPLE }];