From d0427ea1406db76d705f107b3c6e4860face5b08 Mon Sep 17 00:00:00 2001 From: Sebastian Held Date: Fri, 30 Apr 2010 14:56:46 +0200 Subject: [PATCH] examples adapted to win32 --- TESTSUITE/helperscripts/invoke_openEMS.m | 15 ----------- matlab/examples/Circ_Waveguide.m | 20 +++++---------- .../examples/Circ_Waveguide_CylinderCoords.m | 16 ++++++------ matlab/examples/Coax.m | 12 ++++----- matlab/examples/Coax_CylinderCoords.m | 14 ++++------- matlab/examples/Coax_partial_CylinderCoords.m | 10 +++----- matlab/examples/Helix.m | 18 ++++++------- matlab/examples/MSL.m | 12 ++++----- matlab/examples/PlaneWave.m | 15 +++++------ matlab/examples/Rect_Waveguide.m | 15 +++++------ matlab/invoke_openEMS.m | 25 +++++++++++++++++++ 11 files changed, 77 insertions(+), 95 deletions(-) delete mode 100644 TESTSUITE/helperscripts/invoke_openEMS.m create mode 100644 matlab/invoke_openEMS.m diff --git a/TESTSUITE/helperscripts/invoke_openEMS.m b/TESTSUITE/helperscripts/invoke_openEMS.m deleted file mode 100644 index e1a4c28..0000000 --- a/TESTSUITE/helperscripts/invoke_openEMS.m +++ /dev/null @@ -1,15 +0,0 @@ -function invoke_openEMS( opts ) - -if nargin < 1 - opts = ''; -end -% openEMS_opts = [openEMS_opts ' --disable-dumps']; -% openEMS_opts = [openEMS_opts ' --debug-material']; - -filename = mfilename('fullpath'); -dir = fileparts( filename ); -openEMS_Path = [dir '/../../']; - -command = [openEMS_Path 'openEMS.sh ' opts]; -disp(command); -system(command); diff --git a/matlab/examples/Circ_Waveguide.m b/matlab/examples/Circ_Waveguide.m index aa8c509..f414681 100644 --- a/matlab/examples/Circ_Waveguide.m +++ b/matlab/examples/Circ_Waveguide.m @@ -1,5 +1,5 @@ -close all; -clear all; +close all +clear clc %% setup the simulation %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @@ -18,7 +18,7 @@ f0 = 400e6; p11 = 1.841; kc = p11 / rad /unit; k = 2*pi*f0/C0; -fc = C0*kc/2/pi +fc = C0*kc/2/pi; beta = sqrt(k^2 - kc^2); kc = kc*unit; @@ -28,8 +28,7 @@ func_Ea = [ num2str(1/kc) '*sin(a)*0.5*(j0(' num2str(kc) '*rho)-jn(2,' num2str func_Ex = [func_Er '*cos(a) - ' func_Ea '*sin(a)']; func_Ey = [func_Er '*sin(a) + ' func_Ea '*cos(a)']; -%% define file pathes and openEMS options %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -openEMS_Path = [pwd() '/../../'] +%% define and openEMS options %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% openEMS_opts = ''; % openEMS_opts = [openEMS_opts ' --disable-dumps']; % openEMS_opts = [openEMS_opts ' --debug-material']; @@ -110,21 +109,14 @@ CSX = AddProbe(CSX,'ut1',0); start = [ -rad 0 0/2 ];stop = [ rad 0 0/2 ]; CSX = AddBox(CSX,'ut1', 0 ,start,stop); -%current calc -CSX = AddProbe(CSX,'it1',1); -mid = 0.5*(coax_rad_i+coax_rad_ai); -start = [ -mid -mid length/2 ];stop = [ mid mid length/2 ]; -CSX = AddBox(CSX,'it1', 0 ,start,stop); - %% Write openEMS compatoble 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 -command = [openEMS_Path 'openEMS.sh ' Sim_CSX ' ' openEMS_opts]; -disp(command); -system(command) +args = [Sim_CSX ' ' openEMS_opts]; +invoke_openEMS(args); cd(savePath); %% do the plots %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% diff --git a/matlab/examples/Circ_Waveguide_CylinderCoords.m b/matlab/examples/Circ_Waveguide_CylinderCoords.m index 6e3e24f..7520c08 100644 --- a/matlab/examples/Circ_Waveguide_CylinderCoords.m +++ b/matlab/examples/Circ_Waveguide_CylinderCoords.m @@ -1,5 +1,5 @@ -close all; -clear all; +close all +clear clc %% setup the simulation %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @@ -22,15 +22,14 @@ f0 = 400e6; p11 = 1.841; kc = p11 / rad /unit; k = 2*pi*f0/C0; -fc = C0*kc/2/pi +fc = C0*kc/2/pi; beta = sqrt(k^2 - kc^2); kc = kc*unit; func_Er = [ num2str(-1/kc^2,15) '/rho*cos(a)*j1(' num2str(kc,15) '*rho)']; func_Ea = [ num2str(1/kc,15) '*sin(a)*0.5*(j0(' num2str(kc,15) '*rho)-jn(2,' num2str(kc,15) '*rho))']; -%% define file pathes and openEMS options %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -openEMS_Path = [pwd() '/../../'] +%% define openEMS options %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% openEMS_opts = ''; % openEMS_opts = [openEMS_opts ' --disable-dumps']; % openEMS_opts = [openEMS_opts ' --debug-material']; @@ -117,9 +116,8 @@ WriteOpenEMS([Sim_Path '/' Sim_CSX],FDTD,CSX); %% cd to working dir and run openEMS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% savePath = pwd(); cd(Sim_Path); %cd to working dir -command = [openEMS_Path 'openEMS.sh ' Sim_CSX ' ' openEMS_opts]; -disp(command); -system(command) +args = [Sim_CSX ' ' openEMS_opts]; +invoke_openEMS(args); cd(savePath); %% do the plots %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @@ -153,4 +151,4 @@ for z =z_planes Ex(10,5) pause(1) end -end \ No newline at end of file +end diff --git a/matlab/examples/Coax.m b/matlab/examples/Coax.m index cb3740c..5fb06b1 100644 --- a/matlab/examples/Coax.m +++ b/matlab/examples/Coax.m @@ -1,5 +1,5 @@ -close all; -clear all; +close all +clear clc %% setup the simulation %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @@ -18,8 +18,7 @@ Z0 = sqrt(MUE0/EPS0); f0 = 0.5e9; epsR = 1; -%% define file pathes and openEMS options %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -openEMS_Path = [pwd() '/../../'] +%% define openEMS options %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% openEMS_opts = ''; openEMS_opts = [openEMS_opts ' --disable-dumps']; % openEMS_opts = [openEMS_opts ' --debug-material']; @@ -98,9 +97,8 @@ WriteOpenEMS([Sim_Path '/' Sim_CSX],FDTD,CSX); %% cd to working dir and run openEMS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% savePath = pwd(); cd(Sim_Path); %cd to working dir -command = [openEMS_Path 'openEMS.sh ' Sim_CSX ' ' openEMS_opts]; -disp(command); -system(command) +args = [Sim_CSX ' ' openEMS_opts]; +invoke_openEMS(args) cd(savePath); %% postproc & do the plots %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% diff --git a/matlab/examples/Coax_CylinderCoords.m b/matlab/examples/Coax_CylinderCoords.m index 44c2f77..c273e05 100644 --- a/matlab/examples/Coax_CylinderCoords.m +++ b/matlab/examples/Coax_CylinderCoords.m @@ -1,5 +1,5 @@ -close all; -clear all; +close all +clear clc %% setup the simulation %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @@ -21,8 +21,7 @@ max_alpha = max_mesh; N_alpha = ceil(rad_a * 2*pi / max_alpha); mesh_res = [max_mesh 2*pi/N_alpha max_mesh]; -%% define file pathes and openEMS options %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -openEMS_Path = [pwd() '/../../']; +%% define and openEMS options %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% openEMS_opts = ''; openEMS_opts = [openEMS_opts ' --disable-dumps']; % openEMS_opts = [openEMS_opts ' --debug-material']; @@ -107,9 +106,8 @@ WriteOpenEMS([Sim_Path '/' Sim_CSX],FDTD,CSX); %% cd to working dir and run openEMS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% savePath = pwd(); cd(Sim_Path); %cd to working dir -command = [openEMS_Path 'openEMS.sh ' Sim_CSX ' ' openEMS_opts]; -disp(command); -system(command) +args = [Sim_CSX ' ' openEMS_opts]; +invoke_openEMS(args); cd(savePath); %% postproc & do the plots %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @@ -129,5 +127,3 @@ plot(UI.FD{1}.f,real(Z),'Linewidth',2); plot(UI.FD{1}.f,imag(Z),'r','Linewidth',2); xlim([0 2*f0]); legend('Z_L','\Re\{Z\}','\Im\{Z\}','Location','Best'); - - diff --git a/matlab/examples/Coax_partial_CylinderCoords.m b/matlab/examples/Coax_partial_CylinderCoords.m index 5178a51..8c45f7e 100644 --- a/matlab/examples/Coax_partial_CylinderCoords.m +++ b/matlab/examples/Coax_partial_CylinderCoords.m @@ -1,5 +1,5 @@ -close all; -clear all; +close all +clear clc EPS0 = 8.85418781762e-12; @@ -21,7 +21,6 @@ max_alpha = max_mesh; N_alpha = ceil(rad_a * 2*pi * partial / max_alpha); mesh_res = [max_mesh 2*pi*partial/N_alpha max_mesh]; -openEMS_Path = [pwd() '/../../'] openEMS_opts = ''; openEMS_opts = [openEMS_opts ' --disable-dumps']; % openEMS_opts = [openEMS_opts ' --debug-material']; @@ -105,9 +104,8 @@ WriteOpenEMS([Sim_Path '/' Sim_CSX],FDTD,CSX); %cd to working dir and run openEMS savePath = pwd(); cd(Sim_Path); %cd to working dir -command = [openEMS_Path 'openEMS.sh ' Sim_CSX ' ' openEMS_opts]; -disp(command); -system(command) +args = [Sim_CSX ' ' openEMS_opts]; +invoke_openEMS(args) cd(savePath); UI = ReadUI({'ut1_1','ut1_2','it1'},'tmp/'); diff --git a/matlab/examples/Helix.m b/matlab/examples/Helix.m index 5a6a360..7bd1d9f 100644 --- a/matlab/examples/Helix.m +++ b/matlab/examples/Helix.m @@ -1,5 +1,5 @@ -close all; -clear; +close all +clear clc %% setup the simulation %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @@ -16,8 +16,7 @@ port_resist = 1000; f_max = 100e6; f_excite = 300e6; -%% define file pathes and openEMS options %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -openEMS_Path = [pwd() '/../../'] +%% define openEMS options %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% openEMS_opts = ''; % openEMS_opts = [openEMS_opts ' --disable-dumps']; openEMS_opts = [openEMS_opts ' --debug-material']; @@ -27,8 +26,8 @@ openEMS_opts = [openEMS_opts ' --debug-boxes']; Sim_Path = 'tmp'; Sim_CSX = 'helix.xml'; -rmdir(Sim_Path,'s'); -mkdir(Sim_Path); +[status, message, messageid] = rmdir(Sim_Path,'s'); +[status,message,messageid] = mkdir(Sim_Path); %% setup FDTD parameter & excitation function %%%%%%%%%%%%%%%%%%%%%%%%%%%%% FDTD = InitFDTD(30000,1e-6); @@ -120,11 +119,10 @@ CSX = AddBox(CSX,'Ht_',0 , start,stop); WriteOpenEMS([Sim_Path '/' Sim_CSX],FDTD,CSX); %% cd to working dir and run openEMS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -savePath = pwd(); +savePath = pwd; cd(Sim_Path); %cd to working dir -command = [openEMS_Path 'openEMS.sh ' Sim_CSX ' ' openEMS_opts]; -disp(command); -system(command) +args = [Sim_CSX ' ' openEMS_opts]; +invoke_openEMS(args); cd(savePath); %% postproc & do the plots %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% diff --git a/matlab/examples/MSL.m b/matlab/examples/MSL.m index cbb27b6..0abfc99 100644 --- a/matlab/examples/MSL.m +++ b/matlab/examples/MSL.m @@ -1,5 +1,5 @@ -close all; -clear all; +close all +clear clc %% setup the simulation %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @@ -14,8 +14,7 @@ mesh_res = [5 5 10]; EPS0 = 8.85418781762e-12; MUE0 = 1.256637062e-6; -%% define file pathes and openEMS options %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -openEMS_Path = [pwd() '/../../'] +%% define openEMS options %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% openEMS_opts = ''; % openEMS_opts = [openEMS_opts ' --disable-dumps']; % openEMS_opts = [openEMS_opts ' --debug-material']; @@ -86,8 +85,7 @@ WriteOpenEMS([Sim_Path '/' Sim_CSX],FDTD,CSX); %% cd to working dir and run openEMS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% savePath = pwd(); cd(Sim_Path); %cd to working dir -command = [openEMS_Path 'openEMS.sh ' Sim_CSX ' ' openEMS_opts]; -disp(command); -system(command) +args = [Sim_CSX ' ' openEMS_opts]; +invoke_openEMS(args); cd(savePath); diff --git a/matlab/examples/PlaneWave.m b/matlab/examples/PlaneWave.m index 7939837..817a194 100644 --- a/matlab/examples/PlaneWave.m +++ b/matlab/examples/PlaneWave.m @@ -1,5 +1,5 @@ -close all; -clear all; +close all +clear clc %% setup the simulation %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @@ -12,8 +12,7 @@ mesh_res = 25; EPS0 = 8.85418781762e-12; MUE0 = 1.256637062e-6; -%% define file pathes and openEMS options %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -openEMS_Path = [pwd() '/../../'] +%% define openEMS options %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% openEMS_opts = ''; % openEMS_opts = [openEMS_opts ' --disable-dumps']; % openEMS_opts = [openEMS_opts ' --debug-material']; @@ -25,7 +24,7 @@ Sim_CSX = 'plane_wave.xml'; mkdir(Sim_Path); %% setup FDTD parameter & excitation function %%%%%%%%%%%%%%%%%%%%%%%%%%%%% -FDTD = InitFDTD(5e5,1e-6,'OverSampling',10); +FDTD = InitFDTD(5e5,1e-5,'OverSampling',10); FDTD = SetGaussExcite(FDTD,0.5e9,0.5e9); BC = [1 1 0 0 0 0]; FDTD = SetBoundaryCond(FDTD,BC); @@ -71,9 +70,8 @@ WriteOpenEMS([Sim_Path '/' Sim_CSX],FDTD,CSX); %% cd to working dir and run openEMS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% savePath = pwd(); cd(Sim_Path); %cd to working dir -command = [openEMS_Path 'openEMS.sh ' Sim_CSX ' ' openEMS_opts]; -disp(command); -system(command) +args = [Sim_CSX ' ' openEMS_opts]; +invoke_openEMS(args); cd(savePath); %% do the plots %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @@ -83,4 +81,3 @@ PlotArgs.component=2; PlotArgs.Limit = 'auto'; PlotHDF5FieldData('tmp/Et.h5',PlotArgs) - diff --git a/matlab/examples/Rect_Waveguide.m b/matlab/examples/Rect_Waveguide.m index e21648a..e98c8ca 100644 --- a/matlab/examples/Rect_Waveguide.m +++ b/matlab/examples/Rect_Waveguide.m @@ -1,5 +1,5 @@ -close all; -clear all; +close all +clear clc %% setup the simulation %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @@ -24,14 +24,13 @@ f0 = 1e9; k = 2*pi*f0/C0; kc = sqrt((m*pi/a/unit)^2 + (n*pi/b/unit)^2); -fc = C0*kc/2/pi +fc = C0*kc/2/pi; beta = sqrt(k^2 - kc^2); func_Ex = [num2str(n/b/unit) '*cos(' num2str(m*pi/a) '*x)*sin(' num2str(n*pi/b) '*y)']; func_Ey = [num2str(m/a/unit) '*sin(' num2str(m*pi/a) '*x)*cos(' num2str(n*pi/b) '*y)']; -%% define file pathes and openEMS options %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -openEMS_Path = [pwd() '/../../'] +%% define and openEMS options %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% openEMS_opts = ''; % openEMS_opts = [openEMS_opts ' --disable-dumps']; % openEMS_opts = [openEMS_opts ' --debug-material']; @@ -95,9 +94,8 @@ WriteOpenEMS([Sim_Path '/' Sim_CSX],FDTD,CSX); %% cd to working dir and run openEMS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% savePath = pwd(); cd(Sim_Path); %cd to working dir -command = [openEMS_Path 'openEMS.sh ' Sim_CSX ' ' openEMS_opts]; -disp(command); -system(command) +args = [Sim_CSX ' ' openEMS_opts]; +invoke_openEMS(args); cd(savePath); %% do the plots %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @@ -107,4 +105,3 @@ PlotArgs.component=2; PlotArgs.Limit = 'auto'; PlotHDF5FieldData('tmp/Et.h5',PlotArgs) - diff --git a/matlab/invoke_openEMS.m b/matlab/invoke_openEMS.m new file mode 100644 index 0000000..2a31dc3 --- /dev/null +++ b/matlab/invoke_openEMS.m @@ -0,0 +1,25 @@ +function invoke_openEMS( opts ) + +if nargin < 1 + error 'specify the xml file to simulate' +end + +% opts = [opts ' --disable-dumps']; +% opts = [opts ' --debug-material']; +% opts = [opts ' --debug-boxes']; +% opts = [opts ' --engine=sse']; +% opts = [opts ' --engine=multithreaded']; + +filename = mfilename('fullpath'); +dir = fileparts( filename ); +openEMS_Path = [dir filesep '..' filesep]; + +if isunix + openEMS_Path = [openEMS_Path 'openEMS.sh']; +else + openEMS_Path = [openEMS_Path 'openEMS']; +end + +command = [openEMS_Path ' ' opts]; +disp( ['invoking openEMS simulator: ' command] ); +system(command);