2010-04-30 12:56:46 +00:00
|
|
|
close all
|
|
|
|
clear
|
2010-03-24 20:27:48 +00:00
|
|
|
clc
|
|
|
|
|
2010-04-24 14:47:40 +00:00
|
|
|
%% setup the simulation %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
2010-05-19 09:41:35 +00:00
|
|
|
length = 10000;
|
2010-03-24 20:27:48 +00:00
|
|
|
width = 1000;
|
|
|
|
height = 1000;
|
2010-05-19 09:41:35 +00:00
|
|
|
mesh_res = 20;
|
|
|
|
abs_length = mesh_res*10;
|
2010-03-24 20:27:48 +00:00
|
|
|
|
|
|
|
EPS0 = 8.85418781762e-12;
|
|
|
|
MUE0 = 1.256637062e-6;
|
|
|
|
|
2010-04-30 12:56:46 +00:00
|
|
|
%% define openEMS options %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
2010-03-24 20:27:48 +00:00
|
|
|
openEMS_opts = '';
|
2010-05-25 10:17:09 +00:00
|
|
|
% openEMS_opts = [openEMS_opts ' --disable-dumps'];
|
2010-03-24 20:27:48 +00:00
|
|
|
% openEMS_opts = [openEMS_opts ' --debug-material'];
|
2010-05-25 10:17:09 +00:00
|
|
|
openEMS_opts = [openEMS_opts ' --engine=fastest'];
|
2010-03-24 20:27:48 +00:00
|
|
|
|
|
|
|
Sim_Path = 'tmp';
|
|
|
|
Sim_CSX = 'plane_wave.xml';
|
|
|
|
|
2010-05-25 10:17:09 +00:00
|
|
|
if (exist(Sim_Path,'dir'))
|
|
|
|
rmdir(Sim_Path,'s');
|
|
|
|
end
|
2010-03-24 20:27:48 +00:00
|
|
|
mkdir(Sim_Path);
|
|
|
|
|
2010-04-24 14:47:40 +00:00
|
|
|
%% setup FDTD parameter & excitation function %%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
2010-05-19 09:41:35 +00:00
|
|
|
FDTD = InitFDTD(5000,1e-5,'OverSampling',10);
|
2010-03-24 20:27:48 +00:00
|
|
|
FDTD = SetGaussExcite(FDTD,0.5e9,0.5e9);
|
|
|
|
BC = [1 1 0 0 0 0];
|
|
|
|
FDTD = SetBoundaryCond(FDTD,BC);
|
|
|
|
|
2010-04-24 14:47:40 +00:00
|
|
|
%% setup CSXCAD geometry & mesh %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
2010-03-24 20:27:48 +00:00
|
|
|
CSX = InitCSX();
|
|
|
|
mesh.x = -width/2 : mesh_res : width/2;
|
|
|
|
mesh.y = -height/2 : mesh_res : height/2;
|
|
|
|
mesh.z = 0 : mesh_res : length;
|
|
|
|
CSX = DefineRectGrid(CSX, 1e-3,mesh);
|
|
|
|
|
|
|
|
|
2010-04-24 14:47:40 +00:00
|
|
|
%% fake pml %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
2010-03-24 20:27:48 +00:00
|
|
|
finalKappa = 0.3/abs_length^4;
|
|
|
|
finalSigma = finalKappa*MUE0/EPS0;
|
|
|
|
CSX = AddMaterial(CSX,'pml');
|
|
|
|
CSX = SetMaterialProperty(CSX,'pml','Kappa',finalKappa);
|
|
|
|
CSX = SetMaterialProperty(CSX,'pml','Sigma',finalSigma);
|
|
|
|
CSX = SetMaterialWeight(CSX,'pml','Kappa',['pow(abs(z)-' num2str(length-abs_length) ',4)']);
|
|
|
|
CSX = SetMaterialWeight(CSX,'pml','Sigma',['pow(abs(z)-' num2str(length-abs_length) ',4)']);
|
|
|
|
start=[-width/2 -height/2 length-abs_length];
|
|
|
|
stop=[width/2 height/2 length];
|
|
|
|
CSX = AddBox(CSX,'pml',0 ,start,stop);
|
|
|
|
|
2010-04-24 14:47:40 +00:00
|
|
|
%% apply the excitation %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
2010-03-24 20:27:48 +00:00
|
|
|
start=[-width/2 -height/2 0];
|
|
|
|
stop=[width/2 height/2 0];
|
|
|
|
CSX = AddExcitation(CSX,'excite',0,[0 1 0]);
|
|
|
|
CSX = AddBox(CSX,'excite',0 ,start,stop);
|
|
|
|
|
2010-04-24 14:47:40 +00:00
|
|
|
%% define dump boxes... %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
|
|
|
CSX = AddDump(CSX,'Et','FileType',1,'SubSampling','4,4,1');
|
|
|
|
start = [mesh.x(1) , mesh.y(1) , mesh.z(1)];
|
|
|
|
stop = [mesh.x(end) , mesh.y(end) , mesh.z(end)];
|
2010-04-05 18:22:03 +00:00
|
|
|
CSX = AddBox(CSX,'Et',0 , start,stop);
|
2010-03-24 20:27:48 +00:00
|
|
|
|
2010-05-25 10:17:09 +00:00
|
|
|
CSX = AddDump(CSX,'Ht','DumpType',1,'FileType',1,'SubSampling','4,4,1','DumpMode',2);
|
2010-04-05 18:22:03 +00:00
|
|
|
CSX = AddBox(CSX,'Ht',0,start,stop);
|
2010-03-24 20:27:48 +00:00
|
|
|
|
2010-04-24 14:47:40 +00:00
|
|
|
%% Write openEMS compatoble xml-file %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
2010-03-24 20:27:48 +00:00
|
|
|
WriteOpenEMS([Sim_Path '/' Sim_CSX],FDTD,CSX);
|
|
|
|
|
2010-06-09 07:22:54 +00:00
|
|
|
%% run openEMS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
|
|
|
RunOpenEMS(Sim_Path, Sim_CSX, openEMS_opts);
|
2010-03-24 20:27:48 +00:00
|
|
|
|
2010-04-24 14:47:40 +00:00
|
|
|
%% do the plots %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
|
|
|
PlotArgs.slice = {mesh.x(round(end/2)) mesh.y(round(end/2)) mesh.z(round(end/2))};
|
2010-04-05 21:16:52 +00:00
|
|
|
PlotArgs.pauseTime=0.01;
|
2010-05-25 10:17:09 +00:00
|
|
|
PlotArgs.component=1;
|
2010-04-24 14:47:40 +00:00
|
|
|
PlotArgs.Limit = 'auto';
|
2010-04-05 21:16:52 +00:00
|
|
|
|
2010-05-25 10:17:09 +00:00
|
|
|
PlotHDF5FieldData('tmp/Ht.h5',PlotArgs)
|