testsuite updated
parent
b324296e23
commit
ee23c2f909
|
@ -1,4 +1,4 @@
|
|||
function pass = Coax
|
||||
function pass = Coax( openEMS_options, options )
|
||||
|
||||
physical_constants;
|
||||
|
||||
|
@ -6,10 +6,23 @@ physical_constants;
|
|||
ENABLE_PLOTS = 1;
|
||||
CLEANUP = 1; % if enabled and result is PASS, remove simulation folder
|
||||
STOP_IF_FAILED = 1; % if enabled and result is FAILED, stop with error
|
||||
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
|
||||
|
||||
% LIMITS
|
||||
upper_error = 0.036; % max +3.6%
|
||||
lower_error = 0; % max -0.0%
|
||||
upper_error = 0.03; % max +3%
|
||||
lower_error = 0.01; % max -1%
|
||||
|
||||
% structure
|
||||
abs_length = 250;
|
||||
|
@ -21,15 +34,15 @@ mesh_res = [5 5 5];
|
|||
f_start = 0;
|
||||
f_stop = 1e9;
|
||||
|
||||
Sim_Path = 'tmp';
|
||||
Sim_Path = 'tmp_Coax';
|
||||
Sim_CSX = 'coax.xml';
|
||||
|
||||
[status,message,messageid]=rmdir(Sim_Path,'s');
|
||||
[status,message,messageid]=mkdir(Sim_Path);
|
||||
|
||||
%setup FDTD parameter
|
||||
FDTD = InitFDTD(5e5,1e-6);
|
||||
FDTD = SetGaussExcite(FDTD,(f_stop-f_start)/2,(f_stop-f_start)/2);
|
||||
FDTD = InitFDTD(5000,1e-6);
|
||||
FDTD = SetGaussExcite(FDTD,0,f_stop);
|
||||
BC = [1 1 1 1 1 1] * 0;
|
||||
FDTD = SetBoundaryCond(FDTD,BC);
|
||||
|
||||
|
@ -41,7 +54,7 @@ mesh.z = 0 : mesh_res(3) : length;
|
|||
mesh.z = linspace(0,length,numel(mesh.z) + 4-mod(numel(mesh.z),4)); % make it compatible with sse-engine
|
||||
CSX = DefineRectGrid(CSX, 1e-3,mesh);
|
||||
|
||||
%create copper
|
||||
% create a perfect electric conductor
|
||||
CSX = AddMetal(CSX,'PEC');
|
||||
|
||||
%%%fake pml
|
||||
|
@ -55,12 +68,14 @@ CSX = SetMaterialWeight(CSX,'pml','Sigma',['pow(abs(z)-' num2str(length-abs_leng
|
|||
|
||||
%%% coax
|
||||
start = [0, 0 , 0];stop = [0, 0 , length];
|
||||
CSX = AddCylinder(CSX,'PEC',0 ,start,stop,coax_rad_i); % inner conductor
|
||||
CSX = AddCylinder(CSX,'PEC',1 ,start,stop,coax_rad_i); % inner conductor
|
||||
CSX = AddCylindricalShell(CSX,'PEC',0 ,start,stop,0.5*(coax_rad_aa+coax_rad_ai),(coax_rad_aa-coax_rad_ai)); % outer conductor
|
||||
|
||||
%%% add PML
|
||||
start(3) = length-abs_length;
|
||||
CSX = AddCylindricalShell(CSX,'pml',0 ,start,stop,0.5*(coax_rad_i+coax_rad_ai),(coax_rad_ai-coax_rad_i));
|
||||
|
||||
%%% add excitation
|
||||
start(3) = 0; stop(3)=mesh_res(1)/2;
|
||||
CSX = AddExcitation(CSX,'excite',0,[1 1 0]);
|
||||
weight{1} = '(x)/(x*x+y*y)';
|
||||
|
@ -85,20 +100,23 @@ CSX = AddBox(CSX,'ut1', 0 ,start,stop);
|
|||
|
||||
%current calc
|
||||
CSX = AddProbe(CSX,'it1',1);
|
||||
mid = 0.5*(coax_rad_i+coax_rad_ai);
|
||||
% mid = 0.5*(coax_rad_i+coax_rad_ai);
|
||||
mid = coax_rad_i+3*mesh_res(1);
|
||||
start = [ -mid -mid length/2 ];stop = [ mid mid length/2 ];
|
||||
CSX = AddBox(CSX,'it1', 0 ,start,stop);
|
||||
|
||||
%Write openEMS compatible xml-file
|
||||
WriteOpenEMS([Sim_Path '/' Sim_CSX],FDTD,CSX);
|
||||
|
||||
%cd to working dir and run openEMS
|
||||
savePath = pwd();
|
||||
cd(Sim_Path); %cd to working dir
|
||||
invoke_openEMS( Sim_CSX );
|
||||
UI = ReadUI( {'ut1','it1'} );
|
||||
cd(savePath);
|
||||
% show structure
|
||||
% CSXGeomPlot( [Sim_Path '/' Sim_CSX] );
|
||||
|
||||
% run openEMS
|
||||
folder = fileparts( mfilename('fullpath') );
|
||||
Settings.LogFile = [folder '/' Sim_Path '/openEMS.log'];
|
||||
Settings.Silent = SILENT;
|
||||
RunOpenEMS( Sim_Path, Sim_CSX, openEMS_options, Settings );
|
||||
UI = ReadUI( {[Sim_Path '/ut1'], [Sim_Path '/it1']} );
|
||||
|
||||
|
||||
%
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
function pass = cavity
|
||||
function pass = cavity( openEMS_options, options )
|
||||
|
||||
physical_constants;
|
||||
|
||||
|
@ -6,6 +6,19 @@ physical_constants;
|
|||
ENABLE_PLOTS = 1;
|
||||
CLEANUP = 1; % if enabled and result is PASS, remove simulation folder
|
||||
STOP_IF_FAILED = 1; % if enabled and result is FAILED, stop with error
|
||||
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
|
||||
|
||||
% LIMITS - inside
|
||||
lower_rel_limit = 1.3e-3; % -0.13%
|
||||
|
@ -31,7 +44,7 @@ end
|
|||
f_start = 1e9;
|
||||
f_stop = 10e9;
|
||||
|
||||
Sim_Path = 'tmp';
|
||||
Sim_Path = 'tmp_cavity';
|
||||
Sim_CSX = 'cavity.xml';
|
||||
|
||||
[status,message,messageid]=rmdir(Sim_Path,'s');
|
||||
|
@ -101,12 +114,12 @@ CSX = AddBox(CSX,'ut1z', 0 ,pos1,pos2);
|
|||
%Write openEMS compatible xml-file
|
||||
WriteOpenEMS([Sim_Path '/' Sim_CSX],FDTD,CSX);
|
||||
|
||||
%cd to working dir and run openEMS
|
||||
savePath = pwd();
|
||||
cd(Sim_Path); %cd to working dir
|
||||
invoke_openEMS( Sim_CSX );
|
||||
UI = ReadUI( {'ut1x', 'ut1y', 'ut1z'} );
|
||||
cd(savePath);
|
||||
% run openEMS
|
||||
folder = fileparts( mfilename('fullpath') );
|
||||
Settings.LogFile = [folder '/' Sim_Path '/openEMS.log'];
|
||||
Settings.Silent = SILENT;
|
||||
RunOpenEMS( Sim_Path, Sim_CSX, openEMS_options, Settings );
|
||||
UI = ReadUI( {[Sim_Path '/ut1x'], [Sim_Path '/ut1y'], [Sim_Path '/ut1z']} );
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -1,30 +1,40 @@
|
|||
function pass = cavity
|
||||
%pass = cavity
|
||||
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 = 0;
|
||||
ENABLE_PLOTS = 1;
|
||||
SILENT = 0; % 0=show openEMS output
|
||||
|
||||
engines = {'' '--engine=sse' '--engine=sse-compressed' '--engine=multithreaded'};
|
||||
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'}];
|
||||
|
||||
isOctave = exist('OCTAVE_VERSION','builtin') ~= 0;
|
||||
if isOctave
|
||||
old_crr = confirm_recursive_rmdir(0);
|
||||
end
|
||||
|
||||
global Sim_Path Sim_CSX
|
||||
Sim_Path = 'tmp';
|
||||
Sim_Path = 'tmp_cavity';
|
||||
Sim_CSX = 'cavity.xml';
|
||||
|
||||
for n=1:numel(engines)
|
||||
result{n} = sim( engines{n} );
|
||||
result{n} = sim( [engines{n} ' ' openEMS_options], SILENT );
|
||||
end
|
||||
|
||||
pass = compare( result );
|
||||
pass = compare( result, SILENT );
|
||||
|
||||
if pass
|
||||
disp( 'enginetests/cavity.m (engine comparison): pass' );
|
||||
|
@ -39,13 +49,10 @@ if ~pass && STOP_IF_FAILED
|
|||
error 'test failed'
|
||||
end
|
||||
|
||||
if isOctave
|
||||
confirm_recursive_rmdir(old_crr);
|
||||
end
|
||||
return
|
||||
|
||||
|
||||
function result = sim( openEMS_options )
|
||||
function result = sim( openEMS_options, SILENT )
|
||||
global Sim_Path Sim_CSX
|
||||
physical_constants;
|
||||
|
||||
|
@ -118,7 +125,10 @@ CSX = AddBox( CSX, 'Ht', 0, pos1, pos2 );
|
|||
WriteOpenEMS( [Sim_Path '/' Sim_CSX], FDTD, CSX );
|
||||
|
||||
% cd to working dir and run openEMS
|
||||
RunOpenEMS( Sim_Path, Sim_CSX, openEMS_options );
|
||||
folder = fileparts( mfilename('fullpath') );
|
||||
Settings.LogFile = [folder '/' Sim_Path '/openEMS.log'];
|
||||
Settings.Silent = SILENT;
|
||||
RunOpenEMS( Sim_Path, Sim_CSX, openEMS_options, Settings );
|
||||
|
||||
% collect result
|
||||
E.mesh = ReadHDF5Mesh( [Sim_Path '/Et.h5'] );
|
||||
|
@ -131,7 +141,7 @@ result.probes = ReadUI( {'E_probe','H_probe'}, Sim_Path );
|
|||
|
||||
|
||||
|
||||
function pass = compare( results )
|
||||
function pass = compare( results, SILENT )
|
||||
pass = 0;
|
||||
% n=1: reference simulation
|
||||
for n=2:numel(results)
|
||||
|
@ -151,7 +161,9 @@ for n=2:numel(results)
|
|||
end
|
||||
end
|
||||
end
|
||||
disp( ['simulation ' num2str(n) ' is identical to simulation 1'] );
|
||||
if ~SILENT
|
||||
disp( ['simulation ' num2str(n) ' is identical to simulation 1'] );
|
||||
end
|
||||
end
|
||||
|
||||
global ENABLE_PLOTS;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
function pass = fieldprobes
|
||||
function pass = fieldprobes( openEMS_options, options )
|
||||
%
|
||||
% infinitesimal dipole in free-space
|
||||
%
|
||||
|
@ -10,10 +10,24 @@ pass = 1;
|
|||
physical_constants;
|
||||
|
||||
|
||||
ENABLE_PLOTS = 0;
|
||||
ENABLE_PLOTS = 1;
|
||||
CLEANUP = 1; % if enabled and result is PASS, remove simulation folder
|
||||
STOP_IF_FAILED = 1; % if enabled and result is FAILED, stop with error
|
||||
VERBOSE = 0;
|
||||
VERBOSE = 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;
|
||||
VERBOSE = 0;
|
||||
end
|
||||
|
||||
% LIMITS
|
||||
limit_max_time_diff = 1e-15;
|
||||
|
@ -25,7 +39,7 @@ limit_min_h_amp = 1e-7;
|
|||
|
||||
% setup the simulation %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
drawingunit = 1e-6; % specify everything in um
|
||||
Sim_Path = 'tmp';
|
||||
Sim_Path = 'tmp_fieldprobes';
|
||||
Sim_CSX = 'tmp.xml';
|
||||
|
||||
f_max = 1e9;
|
||||
|
@ -101,21 +115,11 @@ FDTD = SetBoundaryCond( FDTD, BC );
|
|||
[~,~,~] = mkdir(Sim_Path);
|
||||
WriteOpenEMS([Sim_Path '/' Sim_CSX],FDTD,CSX);
|
||||
|
||||
% define openEMS options %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
openEMS_opts = '';
|
||||
% openEMS_opts = [openEMS_opts ' --disable-dumps'];
|
||||
% openEMS_opts = [openEMS_opts ' --debug-material'];
|
||||
% openEMS_opts = [openEMS_opts ' --debug-operator'];
|
||||
% openEMS_opts = [openEMS_opts ' --debug-PEC'];
|
||||
% openEMS_opts = [openEMS_opts ' --debug-boxes'];
|
||||
openEMS_opts = [openEMS_opts ' --showProbeDiscretization'];
|
||||
openEMS_opts = [openEMS_opts ' --engine=fastest'];
|
||||
settings = [];
|
||||
if ~VERBOSE, settings.Silent = 1; end
|
||||
RunOpenEMS( Sim_Path, Sim_CSX, openEMS_opts, settings );
|
||||
|
||||
|
||||
|
||||
% run openEMS
|
||||
folder = fileparts( mfilename('fullpath') );
|
||||
Settings.LogFile = [folder '/' Sim_Path '/openEMS.log'];
|
||||
Settings.Silent = SILENT;
|
||||
RunOpenEMS( Sim_Path, Sim_CSX, openEMS_options, Settings );
|
||||
|
||||
|
||||
%% POSTPROCESS
|
||||
|
|
|
@ -0,0 +1,55 @@
|
|||
%
|
||||
% run the testsuite
|
||||
%
|
||||
|
||||
clc
|
||||
clear
|
||||
close all
|
||||
drawnow
|
||||
|
||||
Octave = exist('OCTAVE_VERSION','var') ~= 0;
|
||||
|
||||
if Octave
|
||||
confirm_recursive_rmdir(0);
|
||||
end
|
||||
|
||||
folder = fileparts( mfilename( 'fullpath' ) );
|
||||
cd( folder );
|
||||
addpath( [folder filesep 'helperscripts'] );
|
||||
|
||||
% openEMS options
|
||||
options = {'--engine=multithreaded', '--engine=sse-compressed', '--engine=sse', '--engine=basic'};
|
||||
|
||||
for o=1:numel(options)
|
||||
|
||||
disp( [datestr(now) ' *** TESTSUITE started (options: ' options{o} ')'] );
|
||||
|
||||
% now list the tests
|
||||
folders = dir();
|
||||
for f=1:numel(folders)
|
||||
if folders(f).isdir
|
||||
if strcmp(folders(f).name,'.') || strcmp(folders(f).name,'..')
|
||||
continue
|
||||
end
|
||||
if strcmp(folders(f).name,'helperscripts')
|
||||
continue
|
||||
end
|
||||
oldpwd = pwd;
|
||||
cd( folders(f).name );
|
||||
scripts = dir('*.m');
|
||||
for s=1:numel(scripts)
|
||||
if ~scripts(s).isdir
|
||||
% execute function
|
||||
disp( [datestr(now) ' executing: ' folders(f).name '/' scripts(s).name] );
|
||||
[~,fname] = fileparts( scripts(s).name );
|
||||
pass = feval( fname, options{o}, 'run_testsuite' );
|
||||
end
|
||||
end
|
||||
cd(oldpwd);
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
disp( '***' );
|
||||
disp( ['*** ' datestr(now) ' ALL TESTS DONE'] );
|
||||
disp( '***' );
|
|
@ -47,7 +47,7 @@ for n=1:numel(filenames)
|
|||
UI.TD{n}.additional = tmp(:,3:end)';
|
||||
end
|
||||
|
||||
if (nargin<3)
|
||||
if (nargin<3) || isempty(freq)
|
||||
[UI.FD{n}.f,UI.FD{n}.val] = FFT_time2freq( t,val );
|
||||
else
|
||||
UI.FD{n}.f = freq;
|
||||
|
|
|
@ -49,5 +49,7 @@ else
|
|||
command = [command ' > ' logfile ' 2>&1'];
|
||||
end
|
||||
|
||||
disp( ['invoking openEMS simulator: ' command] );
|
||||
if ~silent
|
||||
disp( ['invoking openEMS simulator: ' command] );
|
||||
end
|
||||
system(command);
|
||||
|
|
Loading…
Reference in New Issue