// The only .m file the simulator puts in scope of a design script. It is not // a design helper: evaluatePlate's trailer 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 = steelsim_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: "steelsim_field.m", source: SAMPLE }];