Code covered by the BSD License  

Highlights from
Huygens-Fresnel integral approximation, free-form apertures and rough surfaces

image thumbnail

Huygens-Fresnel integral approximation, free-form apertures and rough surfaces



Simulate wave propagation through free-form apertures, or off rough surfaces.

function obj = createOptions(varargin)
% createOptions - create an options structure, define some general
% parameters and create basic folder structure

% parse the input
p = inputParser;
p.addParamValue('fileName', '', @ischar);
p.addParamValue('folder', 'objects', @ischar);
p.addParamValue('dataFolder', '', @ischar)
p.addParamValue('title', 'job', @ischar)

% use GPU
p.addParamValue('useGpu', true, @(x)islogical(x))
% keep enough GPU memory to store at least 'x' objA.arrays more
p.addParamValue('gpuMemoryOverhead', 2, @(x)isnumeric(x));
% 'x(1)' fullsized (objA.nGrid) arrays and 'x(2)' (objB.nGrid) arrays
% are kept in GPU memory by 'huygensFresnel.m'
p.addParamValue('gpuMemoryUsage', [20 1], @(x)isnumeric(x) && numel(x)==2);
% display a status message every N points while calculating
p.addParamValue('display', 50, @(x)isnumeric(x));
% save portions of N values while evaluating for safety reasons
p.addParamValue('save', 1000, @(x)isnumeric(x));
% a descriptional text
p.addParamValue('description', '', @ischar);
% a timestamp, moment of creation
p.addParamValue('timestamp', datestr(now), @ischar);
% the first index of the output field to process in plane2Plane(.)
p.addParamValue('startIndex', 1, @isnumeric);
% overwrite existing data
p.addParamValue('overwrite', false, @islogical);
% single precision arithmentic on the GPU throws an error
p.addParamValue('singlePrecisionIsError', true, @islogical)
% debug level
p.addParamValue('debugLevel', 0, @isnumeric);
% disable Huygens-Fresnel computation for test purposes
p.addParamValue('dryRun', false, @islogical);


% use the gpu
global useGpu
useGpu = obj.useGpu;

% debug level
global debugLevel
debugLevel = obj.debugLevel;

% start time for messages
obj.tStart = tic;

global tStart;
tStart = obj.tStart;

displayMessage(2, 'timer started');

% issue an error or at least a warning if single precision will be used for
% the computation, only 7 significant digits pose a problem when dealing
% with dimensions in [mm] and wavelength' in [nm]
if (obj.useGpu && ~GPUisDoublePrecision)
    if obj.singlePrecisionIsError
        displayMessage(-1, 'ERROR: single precision arithmetic GPU yields only 7 significant digits; set ''singlePrecisionIsError=false'' to suppress this error');
        displayMessage(0, 'ERROR: single precision arithmetic GPU yields only 7 significant digits');

% check and create folder structure
if strcmp(obj.dataFolder, '')
    obj.dataFolder = [obj.folder filesep '_data'];
displayMessage(2, 'create folders');
mkdir(obj.folder);							% objects folder
mkdir(obj.dataFolder);						% intermediate data folder

displayMessage(1, 'DONE options');			% creation done

Contact us