function pass = cavity( openEMS_options, options ) %pass = cavity( openEMS_options, options ) % % Checks, if different engines produces identical results CLEANUP = 1; % if enabled and result is PASS, remove simulation folder STOP_IF_FAILED = 1; % if enabled and result is FAILED, stop with error global ENABLE_PLOTS; ENABLE_PLOTS = 1; SILENT = 0; % 0=show openEMS output if nargin < 1 openEMS_options = ''; end if nargin < 2 options = ''; end if any(strcmp( options, 'run_testsuite' )) ENABLE_PLOTS = 0; STOP_IF_FAILED = 0; SILENT = 1; end % clean openEMS_options openEMS_options = regexprep( openEMS_options, '--engine=\w+', '' ); engines = {'--engine=basic' '--engine=sse' '--engine=sse-compressed' '--engine=multithreaded'}; % engines = [engines {'--engine=sse-compressed-linear' '--engine=multithreaded-linear'}]; global Sim_Path Sim_CSX Sim_Path = 'tmp_cavity'; Sim_CSX = 'cavity.xml'; for n=1:numel(engines) result{n} = sim( [engines{n} ' ' openEMS_options], SILENT ); end pass = compare( result, SILENT ); if pass disp( 'enginetests/cavity.m (engine comparison): pass' ); else disp( 'enginetests/cavity.m (engine comparison): * FAILED *' ); end if pass && CLEANUP rmdir( Sim_Path, 's' ); end if ~pass && STOP_IF_FAILED error 'test failed' end return function result = sim( openEMS_options, SILENT ) global Sim_Path Sim_CSX physical_constants; % structure a = 5e-2; b = 2e-2; d = 6e-2; if ~((b