examples: update to matlab examples

pull/1/head v0.0.6
Thorsten Liebig 2010-04-24 16:47:40 +02:00
parent 62cb98a307
commit be6d7510e8
7 changed files with 118 additions and 73 deletions

View File

@ -2,6 +2,7 @@ close all;
clear all; clear all;
clc clc
%% setup the simulation %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
abs_length = 500; abs_length = 500;
length = 5000; length = 5000;
unit = 1e-3; unit = 1e-3;
@ -27,6 +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_Ex = [func_Er '*cos(a) - ' func_Ea '*sin(a)'];
func_Ey = [func_Er '*sin(a) + ' func_Ea '*cos(a)']; func_Ey = [func_Er '*sin(a) + ' func_Ea '*cos(a)'];
%% define file pathes and openEMS options %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
openEMS_Path = [pwd() '/../../'] openEMS_Path = [pwd() '/../../']
openEMS_opts = ''; openEMS_opts = '';
% openEMS_opts = [openEMS_opts ' --disable-dumps']; % openEMS_opts = [openEMS_opts ' --disable-dumps'];
@ -39,14 +41,14 @@ Sim_CSX = 'Circ_WG.xml';
mkdir(Sim_Path); mkdir(Sim_Path);
%setup FDTD parameter %% setup FDTD parameter & excitation function %%%%%%%%%%%%%%%%%%%%%%%%%%%%%
FDTD = InitFDTD(1000,1e-6,'OverSampling',5); FDTD = InitFDTD(1000,1e-6,'OverSampling',5);
T = 1/f0; T = 1/f0;
FDTD = SetCustomExcite(FDTD,f0,[ '(1-exp(-1*(t/' num2str(T) ')^2) ) * sin(2*pi*' num2str(f0) '*t)' ]); FDTD = SetCustomExcite(FDTD,f0,[ '(1-exp(-1*(t/' num2str(T) ')^2) ) * sin(2*pi*' num2str(f0) '*t)' ]);
BC = [1 1 1 1 1 1] * 0; BC = [1 1 1 1 1 1] * 0;
FDTD = SetBoundaryCond(FDTD,BC); FDTD = SetBoundaryCond(FDTD,BC);
%setup CSXCAD geometry %% setup CSXCAD geometry & mesh %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
CSX = InitCSX(); CSX = InitCSX();
mesh.x = -mesh_res(1)/2-rad:mesh_res(1):rad+mesh_res(1)/2; mesh.x = -mesh_res(1)/2-rad:mesh_res(1):rad+mesh_res(1)/2;
mesh.y = -mesh_res(2)/2-rad:mesh_res(2):rad+mesh_res(2)/2; mesh.y = -mesh_res(2)/2-rad:mesh_res(2):rad+mesh_res(2)/2;
@ -56,7 +58,7 @@ CSX = DefineRectGrid(CSX, 1e-3,mesh);
start = [0,0,0]; start = [0,0,0];
stop = [0,0,length]; stop = [0,0,length];
%%fake pml %%% fake pml
finalKappa = 0.3/abs_length^4; finalKappa = 0.3/abs_length^4;
finalSigma = finalKappa*MUE0/EPS0; finalSigma = finalKappa*MUE0/EPS0;
CSX = AddMaterial(CSX,'pml'); CSX = AddMaterial(CSX,'pml');
@ -83,7 +85,7 @@ weight{3} = 0;
CSX = SetExcitationWeight(CSX, 'excite', weight ); CSX = SetExcitationWeight(CSX, 'excite', weight );
CSX = AddCylinder(CSX,'excite', 5 ,[0 0 -0.1],[0 0 0.1],rad); CSX = AddCylinder(CSX,'excite', 5 ,[0 0 -0.1],[0 0 0.1],rad);
%dump %% define dump boxes... %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
CSX = AddDump(CSX,'Et','SubSampling','2,2,4','FileType',1,'DumpMode',2); CSX = AddDump(CSX,'Et','SubSampling','2,2,4','FileType',1,'DumpMode',2);
start = [mesh.x(1) , mesh.y(1) , mesh.z(1)]; start = [mesh.x(1) , mesh.y(1) , mesh.z(1)];
stop = [mesh.x(end) , mesh.y(end) , mesh.z(end)]; stop = [mesh.x(end) , mesh.y(end) , mesh.z(end)];
@ -102,21 +104,22 @@ CSX = AddBox(CSX,'Et',0 , start,stop);
% stop = [mesh.x(end) , mesh.y(end) , length/2]; % stop = [mesh.x(end) , mesh.y(end) , length/2];
% CSX = AddBox(CSX,'Exy',0 , start,stop); % CSX = AddBox(CSX,'Exy',0 , start,stop);
%% define voltage calc boxes %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%voltage calc %voltage calc
CSX = AddProbe(CSX,'ut1',0); CSX = AddProbe(CSX,'ut1',0);
start = [ -rad 0 0/2 ];stop = [ rad 0 0/2 ]; start = [ -rad 0 0/2 ];stop = [ rad 0 0/2 ];
CSX = AddBox(CSX,'ut1', 0 ,start,stop); 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 %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); WriteOpenEMS([Sim_Path '/' Sim_CSX],FDTD,CSX);
%cd to working dir and run openEMS %% cd to working dir and run openEMS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
savePath = pwd(); savePath = pwd();
cd(Sim_Path); %cd to working dir cd(Sim_Path); %cd to working dir
command = [openEMS_Path 'openEMS.sh ' Sim_CSX ' ' openEMS_opts]; command = [openEMS_Path 'openEMS.sh ' Sim_CSX ' ' openEMS_opts];
@ -124,6 +127,7 @@ disp(command);
system(command) system(command)
cd(savePath); cd(savePath);
%% do the plots %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
UI = ReadUI('ut1','tmp/'); UI = ReadUI('ut1','tmp/');
plot(UI.TD{1}.t,UI.TD{1}.val); plot(UI.TD{1}.t,UI.TD{1}.val);
grid on; grid on;

View File

@ -2,6 +2,7 @@ close all;
clear all; clear all;
clc clc
%% setup the simulation %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
abs_length = 250; abs_length = 250;
length = 1000; length = 1000;
coax_rad_i = 100; coax_rad_i = 100;
@ -11,10 +12,16 @@ mesh_res = [5 5 5];
EPS0 = 8.85418781762e-12; EPS0 = 8.85418781762e-12;
MUE0 = 1.256637062e-6; MUE0 = 1.256637062e-6;
C0 = 1/sqrt(EPS0*MUE0);
Z0 = sqrt(MUE0/EPS0);
f0 = 0.5e9;
epsR = 1;
%% define file pathes and openEMS options %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
openEMS_Path = [pwd() '/../../'] openEMS_Path = [pwd() '/../../']
openEMS_opts = ''; openEMS_opts = '';
% openEMS_opts = [openEMS_opts ' --disable-dumps']; openEMS_opts = [openEMS_opts ' --disable-dumps'];
% openEMS_opts = [openEMS_opts ' --debug-material']; % openEMS_opts = [openEMS_opts ' --debug-material'];
Sim_Path = 'tmp'; Sim_Path = 'tmp';
@ -22,24 +29,20 @@ Sim_CSX = 'coax.xml';
mkdir(Sim_Path); mkdir(Sim_Path);
%setup FDTD parameter %% setup FDTD parameter & excitation function %%%%%%%%%%%%%%%%%%%%%%%%%%%%%
FDTD = InitFDTD(5e5,1e-6); FDTD = InitFDTD(5e5,1e-5);
FDTD = SetGaussExcite(FDTD,0.5e9,0.5e9); FDTD = SetGaussExcite(FDTD,f0,f0);
BC = [1 1 1 1 1 1] * 0; BC = [1 1 1 1 1 1] * 0;
FDTD = SetBoundaryCond(FDTD,BC); FDTD = SetBoundaryCond(FDTD,BC);
%setup CSXCAD geometry %% setup CSXCAD geometry & mesh %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
CSX = InitCSX(); CSX = InitCSX();
mesh.x = -2.5*mesh_res(1)-coax_rad_aa : mesh_res(1) : coax_rad_aa+2.5*mesh_res(1); mesh.x = -2.5*mesh_res(1)-coax_rad_aa : mesh_res(1) : coax_rad_aa+2.5*mesh_res(1);
mesh.y = mesh.x; mesh.y = mesh.x;
mesh.z = 0 : mesh_res(3) : length; mesh.z = 0 : mesh_res(3) : length;
CSX = DefineRectGrid(CSX, 1e-3,mesh); CSX = DefineRectGrid(CSX, 1e-3,mesh);
%create copper helix and feed lines... %% fake pml %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
CSX = AddMaterial(CSX,'copper');
CSX = SetMaterialProperty(CSX,'copper','Kappa',56e6);
%%%fake pml
finalKappa = 0.3/abs_length^4; finalKappa = 0.3/abs_length^4;
finalSigma = finalKappa*MUE0/EPS0; finalSigma = finalKappa*MUE0/EPS0;
CSX = AddMaterial(CSX,'pml'); CSX = AddMaterial(CSX,'pml');
@ -49,11 +52,15 @@ CSX = SetMaterialWeight(CSX,'pml','Kappa',['pow(abs(z)-' num2str(length-abs_leng
CSX = SetMaterialWeight(CSX,'pml','Sigma',['pow(abs(z)-' num2str(length-abs_length) ',4)']); CSX = SetMaterialWeight(CSX,'pml','Sigma',['pow(abs(z)-' num2str(length-abs_length) ',4)']);
%%% coax %%% coax
CSX = AddMaterial(CSX,'copper');
CSX = SetMaterialProperty(CSX,'copper','Kappa',56e6);
start = [0, 0 , 0];stop = [0, 0 , length]; start = [0, 0 , 0];stop = [0, 0 , length];
CSX = AddCylinder(CSX,'copper',0 ,start,stop,coax_rad_i); CSX = AddCylinder(CSX,'copper',0 ,start,stop,coax_rad_i);
CSX = AddCylindricalShell(CSX,'copper',0 ,start,stop,0.5*(coax_rad_aa+coax_rad_ai),(coax_rad_aa-coax_rad_ai)); CSX = AddCylindricalShell(CSX,'copper',0 ,start,stop,0.5*(coax_rad_aa+coax_rad_ai),(coax_rad_aa-coax_rad_ai));
start(3) = length-abs_length; 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)); CSX = AddCylindricalShell(CSX,'pml',0 ,start,stop,0.5*(coax_rad_i+coax_rad_ai),(coax_rad_ai-coax_rad_i));
%% apply the excitation %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
start(3) = 0; stop(3)=mesh_res(1)/2; start(3) = 0; stop(3)=mesh_res(1)/2;
CSX = AddExcitation(CSX,'excite',0,[1 1 0]); CSX = AddExcitation(CSX,'excite',0,[1 1 0]);
weight{1} = '(x)/(x*x+y*y)'; weight{1} = '(x)/(x*x+y*y)';
@ -62,7 +69,7 @@ weight{3} = 0;
CSX = SetExcitationWeight(CSX, 'excite', weight ); CSX = SetExcitationWeight(CSX, 'excite', weight );
CSX = AddCylindricalShell(CSX,'excite',0 ,start,stop,0.5*(coax_rad_i+coax_rad_ai),(coax_rad_ai-coax_rad_i)); CSX = AddCylindricalShell(CSX,'excite',0 ,start,stop,0.5*(coax_rad_i+coax_rad_ai),(coax_rad_ai-coax_rad_i));
%dump %% define dump boxes... %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
CSX = AddDump(CSX,'Et_','DumpMode',2); CSX = AddDump(CSX,'Et_','DumpMode',2);
start = [mesh.x(1) , 0 , mesh.z(1)]; start = [mesh.x(1) , 0 , mesh.z(1)];
stop = [mesh.x(end) , 0 , mesh.z(end)]; stop = [mesh.x(end) , 0 , mesh.z(end)];
@ -72,9 +79,12 @@ CSX = AddDump(CSX,'Ht_','DumpType',1,'DumpMode',2);
CSX = AddBox(CSX,'Ht_',0,start,stop); CSX = AddBox(CSX,'Ht_',0,start,stop);
%voltage calc %voltage calc
CSX = AddProbe(CSX,'ut1',0); CSX = AddProbe(CSX,'ut1_1',0);
start = [ coax_rad_i 0 length/2 ];stop = [ coax_rad_ai 0 length/2 ]; start = [ coax_rad_i 0 length/2 ];stop = [ coax_rad_ai 0 length/2 ];
CSX = AddBox(CSX,'ut1', 0 ,start,stop); CSX = AddBox(CSX,'ut1_1', 0 ,start,stop);
CSX = AddProbe(CSX,'ut1_2',0);
start = [ coax_rad_i 0 length/2+mesh_res(3) ];stop = [ coax_rad_ai 0 length/2+mesh_res(3) ];
CSX = AddBox(CSX,'ut1_2', 0 ,start,stop);
%current calc %current calc
CSX = AddProbe(CSX,'it1',1); CSX = AddProbe(CSX,'it1',1);
@ -85,7 +95,7 @@ CSX = AddBox(CSX,'it1', 0 ,start,stop);
%Write openEMS compatoble xml-file %Write openEMS compatoble xml-file
WriteOpenEMS([Sim_Path '/' Sim_CSX],FDTD,CSX); WriteOpenEMS([Sim_Path '/' Sim_CSX],FDTD,CSX);
%cd to working dir and run openEMS %% cd to working dir and run openEMS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
savePath = pwd(); savePath = pwd();
cd(Sim_Path); %cd to working dir cd(Sim_Path); %cd to working dir
command = [openEMS_Path 'openEMS.sh ' Sim_CSX ' ' openEMS_opts]; command = [openEMS_Path 'openEMS.sh ' Sim_CSX ' ' openEMS_opts];
@ -93,3 +103,20 @@ disp(command);
system(command) system(command)
cd(savePath); cd(savePath);
%% postproc & do the plots %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
UI = ReadUI({'ut1_1','ut1_2','it1'},'tmp/');
u_f = (UI.FD{1}.val + UI.FD{2}.val)/2; %averaging voltages to fit current
i_f = UI.FD{3}.val;
delta_t = UI.TD{3}.t(1) - UI.TD{1}.t(1); % half time-step (s)
i_f2 = i_f .* exp(-1i*2*pi*UI.FD{1}.f*delta_t); % compensate half time-step advance of H-field
ZL = Z0/2/pi/sqrt(epsR)*log(coax_rad_ai/coax_rad_i); %analytic line-impedance of a coax
plot(UI.FD{1}.f,ZL*ones(size(u_f)),'g');
hold on;
grid on;
Z = u_f./i_f2;
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');

View File

@ -2,6 +2,7 @@ close all;
clear all; clear all;
clc clc
%% setup the simulation %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
EPS0 = 8.85418781762e-12; EPS0 = 8.85418781762e-12;
MUE0 = 1.256637062e-6; MUE0 = 1.256637062e-6;
C0 = 1/sqrt(EPS0*MUE0); C0 = 1/sqrt(EPS0*MUE0);
@ -20,6 +21,7 @@ max_alpha = max_mesh;
N_alpha = ceil(rad_a * 2*pi / max_alpha); N_alpha = ceil(rad_a * 2*pi / max_alpha);
mesh_res = [max_mesh 2*pi/N_alpha max_mesh]; mesh_res = [max_mesh 2*pi/N_alpha max_mesh];
%% define file pathes and openEMS options %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
openEMS_Path = [pwd() '/../../']; openEMS_Path = [pwd() '/../../'];
openEMS_opts = ''; openEMS_opts = '';
openEMS_opts = [openEMS_opts ' --disable-dumps']; openEMS_opts = [openEMS_opts ' --disable-dumps'];
@ -30,13 +32,13 @@ Sim_CSX = 'coax.xml';
mkdir(Sim_Path); mkdir(Sim_Path);
%setup FDTD parameter %% setup FDTD parameter & excitation function %%%%%%%%%%%%%%%%%%%%%%%%%%%%%
FDTD = InitCylindricalFDTD(1e5,1e-5,'OverSampling',10); FDTD = InitCylindricalFDTD(1e5,1e-5,'OverSampling',10);
FDTD = SetGaussExcite(FDTD,f0,f0); FDTD = SetGaussExcite(FDTD,f0,f0);
BC = [0 0 1 1 0 0]; BC = [0 0 1 1 0 0];
FDTD = SetBoundaryCond(FDTD,BC); FDTD = SetBoundaryCond(FDTD,BC);
%setup CSXCAD geometry %% setup CSXCAD geometry & mesh %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
CSX = InitCSX(); CSX = InitCSX();
mesh.x = rad_i : mesh_res(1) : rad_a; mesh.x = rad_i : mesh_res(1) : rad_a;
mesh.y = linspace(0,2*pi,N_alpha); mesh.y = linspace(0,2*pi,N_alpha);
@ -44,7 +46,7 @@ mesh.y = linspace(0,2*pi,N_alpha);
mesh.z = 0 : mesh_res(3) : length; mesh.z = 0 : mesh_res(3) : length;
CSX = DefineRectGrid(CSX, 1e-3,mesh); CSX = DefineRectGrid(CSX, 1e-3,mesh);
%%%fake pml %% fake pml %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
finalKappa = 0.3/abs_length^4; finalKappa = 0.3/abs_length^4;
finalSigma = finalKappa*MUE0/EPS0/epsR; finalSigma = finalKappa*MUE0/EPS0/epsR;
CSX = AddMaterial(CSX,'pml'); CSX = AddMaterial(CSX,'pml');
@ -67,6 +69,7 @@ CSX = AddBox(CSX,'fill',0 ,start,stop);
start = [rad_i mesh.y(1) 0]; start = [rad_i mesh.y(1) 0];
stop = [rad_a mesh.y(end) 0]; stop = [rad_a mesh.y(end) 0];
%% apply the excitation %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
CSX = AddExcitation(CSX,'excite',0,[1 0 0]); CSX = AddExcitation(CSX,'excite',0,[1 0 0]);
weight{1} = '1/rho'; weight{1} = '1/rho';
weight{2} = 0; weight{2} = 0;
@ -74,7 +77,7 @@ weight{3} = 0;
CSX = SetExcitationWeight(CSX, 'excite', weight ); CSX = SetExcitationWeight(CSX, 'excite', weight );
CSX = AddBox(CSX,'excite',0 ,start,stop); CSX = AddBox(CSX,'excite',0 ,start,stop);
%dump %% define dump boxes... %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
CSX = AddDump(CSX,'Et_','DumpMode',0); CSX = AddDump(CSX,'Et_','DumpMode',0);
start = [mesh.x(1) , 0 , mesh.z(1)]; start = [mesh.x(1) , 0 , mesh.z(1)];
stop = [mesh.x(end) , 0 , mesh.z(end)]; stop = [mesh.x(end) , 0 , mesh.z(end)];
@ -101,7 +104,7 @@ CSX = AddBox(CSX,'it1', 0 ,start,stop);
%Write openEMS compatoble xml-file %Write openEMS compatoble xml-file
WriteOpenEMS([Sim_Path '/' Sim_CSX],FDTD,CSX); WriteOpenEMS([Sim_Path '/' Sim_CSX],FDTD,CSX);
%cd to working dir and run openEMS %% cd to working dir and run openEMS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
savePath = pwd(); savePath = pwd();
cd(Sim_Path); %cd to working dir cd(Sim_Path); %cd to working dir
command = [openEMS_Path 'openEMS.sh ' Sim_CSX ' ' openEMS_opts]; command = [openEMS_Path 'openEMS.sh ' Sim_CSX ' ' openEMS_opts];
@ -109,6 +112,7 @@ disp(command);
system(command) system(command)
cd(savePath); cd(savePath);
%% postproc & do the plots %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
UI = ReadUI({'ut1_1','ut1_2','it1'},'tmp/'); UI = ReadUI({'ut1_1','ut1_2','it1'},'tmp/');
u_f = (UI.FD{1}.val + UI.FD{2}.val)/2; %averaging voltages to fit current u_f = (UI.FD{1}.val + UI.FD{2}.val)/2; %averaging voltages to fit current
i_f = UI.FD{3}.val; i_f = UI.FD{3}.val;

View File

@ -2,6 +2,7 @@ close all;
clear; clear;
clc clc
%% setup the simulation %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
feed_length=10; feed_length=10;
wire_rad = sqrt(1.4/pi); wire_rad = sqrt(1.4/pi);
mesh_size = wire_rad; mesh_size = wire_rad;
@ -15,6 +16,7 @@ port_resist = 1000;
f_max = 100e6; f_max = 100e6;
f_excite = 1e9; f_excite = 1e9;
%% define file pathes and openEMS options %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
openEMS_Path = [pwd() '/../../'] openEMS_Path = [pwd() '/../../']
openEMS_opts = ''; openEMS_opts = '';
% openEMS_opts = [openEMS_opts ' --disable-dumps']; % openEMS_opts = [openEMS_opts ' --disable-dumps'];
@ -27,16 +29,16 @@ Sim_CSX = 'helix.xml';
rmdir(Sim_Path,'s'); rmdir(Sim_Path,'s');
mkdir(Sim_Path); mkdir(Sim_Path);
%setup FDTD parameter %% setup FDTD parameter & excitation function %%%%%%%%%%%%%%%%%%%%%%%%%%%%%
FDTD = InitFDTD(5e5,1e-6); FDTD = InitFDTD(5e5,1e-6);
FDTD = SetGaussExcite(FDTD,f_excite/2,f_excite/2); FDTD = SetGaussExcite(FDTD,f_excite/2,f_excite/2);
BC = [1 1 1 1 1 1]; BC = [1 1 1 1 1 1];
FDTD = SetBoundaryCond(FDTD,BC); FDTD = SetBoundaryCond(FDTD,BC);
%% setup CSXCAD geometry & mesh %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
add_Lines = mesh_size * 1.5.^(1:10); add_Lines = mesh_size * 1.5.^(1:10);
add_Lines = add_Lines(find(add_Lines<(3e8/f_excite)/10*1e3)); add_Lines = add_Lines(find(add_Lines<(3e8/f_excite)/10*1e3));
%setup CSXCAD geometry
CSX = InitCSX(); CSX = InitCSX();
mesh.x = -coil_rad-mesh_size : mesh_size : coil_rad+mesh_size+feed_length; mesh.x = -coil_rad-mesh_size : mesh_size : coil_rad+mesh_size+feed_length;
mesh.x = [mesh.x(1)-add_Lines mesh.x mesh.x(end)+add_Lines ]; mesh.x = [mesh.x(1)-add_Lines mesh.x mesh.x(end)+add_Lines ];
@ -46,11 +48,10 @@ mesh.z = -mesh_size : mesh_size : coil_length+mesh_size;
mesh.z = [mesh.z(1)-add_Lines mesh.z mesh.z(end)+add_Lines ]; mesh.z = [mesh.z(1)-add_Lines mesh.z mesh.z(end)+add_Lines ];
CSX = DefineRectGrid(CSX, 1e-3,mesh); CSX = DefineRectGrid(CSX, 1e-3,mesh);
%create copper helix and feed lines... %% build/define helix %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
CSX = AddMaterial(CSX,'copper'); CSX = AddMaterial(CSX,'copper');
CSX = SetMaterialProperty(CSX,'copper','Kappa',56e6); CSX = SetMaterialProperty(CSX,'copper','Kappa',56e6);
%build helix-wire
dt = 1.0/coil_res; dt = 1.0/coil_res;
height=0; height=0;
wire.Vertex = {}; wire.Vertex = {};
@ -78,6 +79,7 @@ p(2,count+2) = 0;
p(3,count+2) = 0.5*(coil_length+port_length); p(3,count+2) = 0.5*(coil_length+port_length);
CSX = AddWire(CSX, 'copper', 0, p, wire_rad); CSX = AddWire(CSX, 'copper', 0, p, wire_rad);
%% apply the excitation & resist as a current source%%%%%%%%%%%%%%%%%%%%%%%
CSX = AddMaterial(CSX,'resist'); CSX = AddMaterial(CSX,'resist');
kappa = port_length/port_resist/wire_rad^2/pi/1e-3; kappa = port_length/port_resist/wire_rad^2/pi/1e-3;
CSX = SetMaterialProperty(CSX,'resist','Kappa',kappa); CSX = SetMaterialProperty(CSX,'resist','Kappa',kappa);
@ -87,10 +89,10 @@ stop=[coil_rad+feed_length 0 (coil_length+port_length)/2];
%start(3)=(coil_length-port_length)/2;stop(3)=(coil_length+port_length)/2; %start(3)=(coil_length-port_length)/2;stop(3)=(coil_length+port_length)/2;
CSX = AddCylinder(CSX,'resist',5 ,start,stop,wire_rad); CSX = AddCylinder(CSX,'resist',5 ,start,stop,wire_rad);
%excitation
CSX = AddExcitation(CSX,'excite',0,[0 0 1]); CSX = AddExcitation(CSX,'excite',0,[0 0 1]);
CSX = AddCylinder(CSX,'excite', 0 ,start,stop,wire_rad); CSX = AddCylinder(CSX,'excite', 0 ,start,stop,wire_rad);
%% define voltage calc boxes %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%voltage calc %voltage calc
CSX = AddProbe(CSX,'ut1',0); CSX = AddProbe(CSX,'ut1',0);
CSX = AddBox(CSX,'ut1', 0 ,stop,start); CSX = AddBox(CSX,'ut1', 0 ,stop,start);
@ -102,7 +104,7 @@ start(1) = start(1)-2;start(2) = start(2)-2;
stop(1) = stop(1)+2;stop(2) = stop(2)+2; stop(1) = stop(1)+2;stop(2) = stop(2)+2;
CSX = AddBox(CSX,'it1', 0 ,start,stop); CSX = AddBox(CSX,'it1', 0 ,start,stop);
%dump %% define dump boxes... %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
CSX = AddDump(CSX,'Et_'); CSX = AddDump(CSX,'Et_');
start = [mesh.x(1) , 0 , mesh.z(1)]; start = [mesh.x(1) , 0 , mesh.z(1)];
stop = [mesh.x(end) , 0 , mesh.z(end)]; stop = [mesh.x(end) , 0 , mesh.z(end)];
@ -113,10 +115,10 @@ start = [mesh.x(1) , 0 , mesh.z(1)];
stop = [mesh.x(end) , 0 , mesh.z(end)]; stop = [mesh.x(end) , 0 , mesh.z(end)];
CSX = AddBox(CSX,'Ht_',0 , start,stop); CSX = AddBox(CSX,'Ht_',0 , start,stop);
%Write openEMS compatoble xml-file %% Write openEMS compatoble xml-file %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
WriteOpenEMS([Sim_Path '/' Sim_CSX],FDTD,CSX); WriteOpenEMS([Sim_Path '/' Sim_CSX],FDTD,CSX);
%cd to working dir and run openEMS %% cd to working dir and run openEMS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
savePath = pwd(); savePath = pwd();
cd(Sim_Path); %cd to working dir cd(Sim_Path); %cd to working dir
command = [openEMS_Path 'openEMS.sh ' Sim_CSX ' ' openEMS_opts]; command = [openEMS_Path 'openEMS.sh ' Sim_CSX ' ' openEMS_opts];
@ -124,7 +126,7 @@ disp(command);
system(command) system(command)
cd(savePath); cd(savePath);
%%%post-proc %% postproc & do the plots %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
U = ReadUI('ut1','tmp/'); U = ReadUI('ut1','tmp/');
I = ReadUI('it1','tmp/'); I = ReadUI('it1','tmp/');

View File

@ -2,6 +2,7 @@ close all;
clear all; clear all;
clc clc
%% setup the simulation %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
abs_length = 250; abs_length = 250;
length = 1000; length = 1000;
width = 500; width = 500;
@ -13,23 +14,24 @@ mesh_res = [5 5 10];
EPS0 = 8.85418781762e-12; EPS0 = 8.85418781762e-12;
MUE0 = 1.256637062e-6; MUE0 = 1.256637062e-6;
%% define file pathes and openEMS options %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
openEMS_Path = [pwd() '/../../'] openEMS_Path = [pwd() '/../../']
openEMS_opts = ''; openEMS_opts = '';
% openEMS_opts = [openEMS_opts ' --disable-dumps']; % openEMS_opts = [openEMS_opts ' --disable-dumps'];
openEMS_opts = [openEMS_opts ' --debug-material']; % openEMS_opts = [openEMS_opts ' --debug-material'];
Sim_Path = 'tmp'; Sim_Path = 'tmp';
Sim_CSX = 'msl.xml'; Sim_CSX = 'msl.xml';
mkdir(Sim_Path); mkdir(Sim_Path);
%setup FDTD parameter %% setup FDTD parameter & excitation function %%%%%%%%%%%%%%%%%%%%%%%%%%%%%
FDTD = InitFDTD(5e5,1e-6); FDTD = InitFDTD(5e5,1e-6);
FDTD = SetGaussExcite(FDTD,0.5e9,0.5e9); FDTD = SetGaussExcite(FDTD,0.5e9,0.5e9);
BC = [1 1 0 1 0 0]; BC = [1 1 0 1 0 0];
FDTD = SetBoundaryCond(FDTD,BC); FDTD = SetBoundaryCond(FDTD,BC);
%setup CSXCAD geometry %% setup CSXCAD geometry & mesh %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
CSX = InitCSX(); CSX = InitCSX();
mesh.x = -width/2 : mesh_res(1) : width/2; mesh.x = -width/2 : mesh_res(1) : width/2;
mesh.y = [linspace(0,MSL_height,11) MSL_height+1 MSL_height+3 MSL_height+mesh_res(2):mesh_res(2):height]; mesh.y = [linspace(0,MSL_height,11) MSL_height+1 MSL_height+3 MSL_height+mesh_res(2):mesh_res(2):height];
@ -46,7 +48,7 @@ start = [-0.5*MSL_width, 0 , 0];stop = [0.5*MSL_width, MSL_height , mesh_res(1)/
CSX = AddExcitation(CSX,'excite',0,[0 -1 0]); CSX = AddExcitation(CSX,'excite',0,[0 -1 0]);
CSX = AddBox(CSX,'excite',0 ,start,stop); CSX = AddBox(CSX,'excite',0 ,start,stop);
%%%fake pml %% fake pml %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
finalKappa = 0.3/abs_length^4; finalKappa = 0.3/abs_length^4;
finalSigma = finalKappa*MUE0/EPS0; finalSigma = finalKappa*MUE0/EPS0;
CSX = AddMaterial(CSX,'pml'); CSX = AddMaterial(CSX,'pml');
@ -58,7 +60,7 @@ start = [mesh.x(1) mesh.y(1) length-abs_length];
stop = [mesh.x(end) mesh.y(end) length]; stop = [mesh.x(end) mesh.y(end) length];
CSX = AddBox(CSX,'pml',0 ,start,stop); CSX = AddBox(CSX,'pml',0 ,start,stop);
%dump %% define dump boxes... %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
CSX = AddDump(CSX,'Et_','DumpMode',2); CSX = AddDump(CSX,'Et_','DumpMode',2);
start = [mesh.x(1) , MSL_height/2 , mesh.z(1)]; start = [mesh.x(1) , MSL_height/2 , mesh.z(1)];
stop = [mesh.x(end) , MSL_height/2 , mesh.z(end)]; stop = [mesh.x(end) , MSL_height/2 , mesh.z(end)];
@ -67,6 +69,7 @@ CSX = AddBox(CSX,'Et_',0 , start,stop);
CSX = AddDump(CSX,'Ht_','DumpType',1,'DumpMode',2); CSX = AddDump(CSX,'Ht_','DumpType',1,'DumpMode',2);
CSX = AddBox(CSX,'Ht_',0,start,stop); CSX = AddBox(CSX,'Ht_',0,start,stop);
%% define voltage calc boxes %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%voltage calc %voltage calc
CSX = AddProbe(CSX,'ut1',0); CSX = AddProbe(CSX,'ut1',0);
start = [ 0 MSL_height length/2 ];stop = [ 0 0 length/2 ]; start = [ 0 MSL_height length/2 ];stop = [ 0 0 length/2 ];
@ -77,10 +80,10 @@ CSX = AddProbe(CSX,'it1',1);
start = [ -MSL_width MSL_height/2 length/2 ];stop = [ MSL_width MSL_height*1.5 length/2 ]; start = [ -MSL_width MSL_height/2 length/2 ];stop = [ MSL_width MSL_height*1.5 length/2 ];
CSX = AddBox(CSX,'it1', 0 ,start,stop); CSX = AddBox(CSX,'it1', 0 ,start,stop);
%Write openEMS compatoble xml-file %% Write openEMS compatoble xml-file %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
WriteOpenEMS([Sim_Path '/' Sim_CSX],FDTD,CSX); WriteOpenEMS([Sim_Path '/' Sim_CSX],FDTD,CSX);
%cd to working dir and run openEMS %% cd to working dir and run openEMS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
savePath = pwd(); savePath = pwd();
cd(Sim_Path); %cd to working dir cd(Sim_Path); %cd to working dir
command = [openEMS_Path 'openEMS.sh ' Sim_CSX ' ' openEMS_opts]; command = [openEMS_Path 'openEMS.sh ' Sim_CSX ' ' openEMS_opts];

View File

@ -2,6 +2,7 @@ close all;
clear all; clear all;
clc clc
%% setup the simulation %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
abs_length = 250; abs_length = 250;
length = 4000; length = 4000;
width = 1000; width = 1000;
@ -11,24 +12,25 @@ mesh_res = 25;
EPS0 = 8.85418781762e-12; EPS0 = 8.85418781762e-12;
MUE0 = 1.256637062e-6; MUE0 = 1.256637062e-6;
%% define file pathes and openEMS options %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
openEMS_Path = [pwd() '/../../'] openEMS_Path = [pwd() '/../../']
openEMS_opts = ''; openEMS_opts = '';
% openEMS_opts = [openEMS_opts ' --disable-dumps']; % openEMS_opts = [openEMS_opts ' --disable-dumps'];
% openEMS_opts = [openEMS_opts ' --debug-material']; % openEMS_opts = [openEMS_opts ' --debug-material'];
openEMS_opts = [openEMS_opts ' --engine=multithreaded']; % openEMS_opts = [openEMS_opts ' --engine=multithreaded'];
Sim_Path = 'tmp'; Sim_Path = 'tmp';
Sim_CSX = 'plane_wave.xml'; Sim_CSX = 'plane_wave.xml';
mkdir(Sim_Path); mkdir(Sim_Path);
%setup FDTD parameter %% setup FDTD parameter & excitation function %%%%%%%%%%%%%%%%%%%%%%%%%%%%%
FDTD = InitFDTD(5e5,1e-6); FDTD = InitFDTD(5e5,1e-6,'OverSampling',10);
FDTD = SetGaussExcite(FDTD,0.5e9,0.5e9); FDTD = SetGaussExcite(FDTD,0.5e9,0.5e9);
BC = [1 1 0 0 0 0]; BC = [1 1 0 0 0 0];
FDTD = SetBoundaryCond(FDTD,BC); FDTD = SetBoundaryCond(FDTD,BC);
%setup CSXCAD geometry %% setup CSXCAD geometry & mesh %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
CSX = InitCSX(); CSX = InitCSX();
mesh.x = -width/2 : mesh_res : width/2; mesh.x = -width/2 : mesh_res : width/2;
mesh.y = -height/2 : mesh_res : height/2; mesh.y = -height/2 : mesh_res : height/2;
@ -36,7 +38,7 @@ mesh.z = 0 : mesh_res : length;
CSX = DefineRectGrid(CSX, 1e-3,mesh); CSX = DefineRectGrid(CSX, 1e-3,mesh);
%%%fake pml %% fake pml %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
finalKappa = 0.3/abs_length^4; finalKappa = 0.3/abs_length^4;
finalSigma = finalKappa*MUE0/EPS0; finalSigma = finalKappa*MUE0/EPS0;
CSX = AddMaterial(CSX,'pml'); CSX = AddMaterial(CSX,'pml');
@ -48,24 +50,25 @@ start=[-width/2 -height/2 length-abs_length];
stop=[width/2 height/2 length]; stop=[width/2 height/2 length];
CSX = AddBox(CSX,'pml',0 ,start,stop); CSX = AddBox(CSX,'pml',0 ,start,stop);
%% apply the excitation %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
start=[-width/2 -height/2 0]; start=[-width/2 -height/2 0];
stop=[width/2 height/2 0]; stop=[width/2 height/2 0];
CSX = AddExcitation(CSX,'excite',0,[0 1 0]); CSX = AddExcitation(CSX,'excite',0,[0 1 0]);
CSX = AddBox(CSX,'excite',0 ,start,stop); CSX = AddBox(CSX,'excite',0 ,start,stop);
%dump %% define dump boxes... %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
CSX = AddDump(CSX,'Et','FileType',1); CSX = AddDump(CSX,'Et','FileType',1,'SubSampling','4,4,1');
start = [mesh.x(1) , 0 , mesh.z(1)]; start = [mesh.x(1) , mesh.y(1) , mesh.z(1)];
stop = [mesh.x(end) , 0 , mesh.z(end)]; stop = [mesh.x(end) , mesh.y(end) , mesh.z(end)];
CSX = AddBox(CSX,'Et',0 , start,stop); CSX = AddBox(CSX,'Et',0 , start,stop);
CSX = AddDump(CSX,'Ht','DumpType',1,'FileType',1); CSX = AddDump(CSX,'Ht','DumpType',1,'FileType',1,'SubSampling','4,4,1');
CSX = AddBox(CSX,'Ht',0,start,stop); CSX = AddBox(CSX,'Ht',0,start,stop);
%Write openEMS compatoble xml-file %% Write openEMS compatoble xml-file %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
WriteOpenEMS([Sim_Path '/' Sim_CSX],FDTD,CSX); WriteOpenEMS([Sim_Path '/' Sim_CSX],FDTD,CSX);
%cd to working dir and run openEMS %% cd to working dir and run openEMS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
savePath = pwd(); savePath = pwd();
cd(Sim_Path); %cd to working dir cd(Sim_Path); %cd to working dir
command = [openEMS_Path 'openEMS.sh ' Sim_CSX ' ' openEMS_opts]; command = [openEMS_Path 'openEMS.sh ' Sim_CSX ' ' openEMS_opts];
@ -73,11 +76,11 @@ disp(command);
system(command) system(command)
cd(savePath); cd(savePath);
% plotting %% do the plots %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
PlotArgs.plane='zx'; PlotArgs.slice = {mesh.x(round(end/2)) mesh.y(round(end/2)) mesh.z(round(end/2))};
PlotArgs.pauseTime=0.01; PlotArgs.pauseTime=0.01;
PlotArgs.component=2; PlotArgs.component=2;
PlotArgs.zlim='auto'; PlotArgs.Limit = 'auto';
PlotHDF5FieldData('tmp/Et.h5',PlotArgs) PlotHDF5FieldData('tmp/Et.h5',PlotArgs)

View File

@ -2,6 +2,7 @@ close all;
clear all; clear all;
clc clc
%% setup the simulation %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
abs_length = 250; abs_length = 250;
length = 4000; length = 4000;
unit = 1e-3; unit = 1e-3;
@ -29,6 +30,7 @@ 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_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)']; 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() '/../../'] openEMS_Path = [pwd() '/../../']
openEMS_opts = ''; openEMS_opts = '';
% openEMS_opts = [openEMS_opts ' --disable-dumps']; % openEMS_opts = [openEMS_opts ' --disable-dumps'];
@ -40,21 +42,20 @@ Sim_CSX = 'rect_wg.xml';
mkdir(Sim_Path); mkdir(Sim_Path);
%setup FDTD parameter %% setup FDTD parameter & excitation function %%%%%%%%%%%%%%%%%%%%%%%%%%%%%
FDTD = InitFDTD(500,1e-6,'OverSampling',6); FDTD = InitFDTD(500,1e-6,'OverSampling',6);
FDTD = SetSinusExcite(FDTD,f0); FDTD = SetSinusExcite(FDTD,f0);
BC = [0 0 0 0 0 0]; BC = [0 0 0 0 0 0];
FDTD = SetBoundaryCond(FDTD,BC); FDTD = SetBoundaryCond(FDTD,BC);
%setup CSXCAD geometry %% setup CSXCAD geometry & mesh %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
CSX = InitCSX(); CSX = InitCSX();
mesh.x = 0 : mesh_res(1) : width; mesh.x = 0 : mesh_res(1) : width;
mesh.y = 0 : mesh_res(2) : height; mesh.y = 0 : mesh_res(2) : height;
mesh.z = -length: mesh_res(3) : length; mesh.z = -length: mesh_res(3) : length;
CSX = DefineRectGrid(CSX, unit,mesh); CSX = DefineRectGrid(CSX, unit,mesh);
%% fake pml %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%fake pml
finalKappa = 0.3/abs_length^4; finalKappa = 0.3/abs_length^4;
finalSigma = finalKappa*MUE0/EPS0; finalSigma = finalKappa*MUE0/EPS0;
CSX = AddMaterial(CSX,'pml'); CSX = AddMaterial(CSX,'pml');
@ -69,6 +70,7 @@ start=[0 0 -length+abs_length];
stop=[width height -length]; stop=[width height -length];
CSX = AddBox(CSX,'pml',0 ,start,stop); CSX = AddBox(CSX,'pml',0 ,start,stop);
%% apply the excitation %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
start=[0 0 0]; start=[0 0 0];
stop=[width height 0]; stop=[width height 0];
CSX = AddExcitation(CSX,'excite',0,[1 1 0]); CSX = AddExcitation(CSX,'excite',0,[1 1 0]);
@ -78,7 +80,7 @@ weight{3} = 0;
CSX = SetExcitationWeight(CSX,'excite',weight); CSX = SetExcitationWeight(CSX,'excite',weight);
CSX = AddBox(CSX,'excite',0 ,start,stop); CSX = AddBox(CSX,'excite',0 ,start,stop);
%dump %% define dump boxes... %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
CSX = AddDump(CSX,'Et','FileType',1); CSX = AddDump(CSX,'Et','FileType',1);
start = [mesh.x(1) , height/2 , mesh.z(1)]; start = [mesh.x(1) , height/2 , mesh.z(1)];
stop = [mesh.x(end) , height/2 , mesh.z(end)]; stop = [mesh.x(end) , height/2 , mesh.z(end)];
@ -87,10 +89,10 @@ CSX = AddBox(CSX,'Et',0 , start,stop);
CSX = AddDump(CSX,'Ht','DumpType',1,'FileType',1); CSX = AddDump(CSX,'Ht','DumpType',1,'FileType',1);
CSX = AddBox(CSX,'Ht',0,start,stop); CSX = AddBox(CSX,'Ht',0,start,stop);
%Write openEMS compatoble xml-file %% Write openEMS compatoble xml-file %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
WriteOpenEMS([Sim_Path '/' Sim_CSX],FDTD,CSX); WriteOpenEMS([Sim_Path '/' Sim_CSX],FDTD,CSX);
%cd to working dir and run openEMS %% cd to working dir and run openEMS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
savePath = pwd(); savePath = pwd();
cd(Sim_Path); %cd to working dir cd(Sim_Path); %cd to working dir
command = [openEMS_Path 'openEMS.sh ' Sim_CSX ' ' openEMS_opts]; command = [openEMS_Path 'openEMS.sh ' Sim_CSX ' ' openEMS_opts];
@ -98,11 +100,11 @@ disp(command);
system(command) system(command)
cd(savePath); cd(savePath);
% plotting %% do the plots %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
PlotArgs.plane='zx'; PlotArgs.slice = {mesh.x(round(end/2)) mesh.y(round(end/2)) mesh.z(round(end/2))};
PlotArgs.pauseTime=0.1; PlotArgs.pauseTime=0.01;
PlotArgs.component=2; PlotArgs.component=2;
PlotArgs.zlim='auto'; PlotArgs.Limit = 'auto';
PlotHDF5FieldData('tmp/Et.h5',PlotArgs) PlotHDF5FieldData('tmp/Et.h5',PlotArgs)