some example updates

pull/1/head v0.0.11
Thorsten Liebig 2010-07-14 14:25:09 +02:00
parent f11b0e5ce4
commit 2d69edbe76
3 changed files with 37 additions and 77 deletions

View File

@ -10,9 +10,9 @@
% profile and not a pml
%
%close all
%clear
%clc
close all
% clear
clc
physical_constants
@ -35,12 +35,13 @@ f_max = 8e9;
%% setup FDTD parameters & excitation function %%%%%%%%%%%%%%%%%%%%%%%%%%%%
FDTD = InitFDTD( max_timesteps, min_decrement );
FDTD = SetGaussExcite( FDTD, f_max/2, f_max/2 );
BC = [0 2 1 1 0 0];
BC = [0 0 1 1 0 0];
FDTD = SetBoundaryCond( FDTD, BC );
%% mesh grading
pml_delta = cumsum(mesh_res(1) * 1.0 .^ (1:5));
pml_delta = cumsum([200 200 200 200 200]);
N_pml = 8;
pml_delta = cumsum(mesh_res(1) * 1.0 .^ (1:N_pml));
% pml_delta = cumsum([200 200 200 200 200]);
%% setup CSXCAD geometry & mesh %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
CSX = InitCSX();
@ -54,24 +55,24 @@ CSX = DefineRectGrid( CSX, drawingunit, mesh );
g = 2; % 2..3
R0 = 1e-6; % requested analytical reflection coefficient
Zm = sqrt(MUE0/(EPS0*epr)); % calculate reflection for substrate/pml interface
delta = pml_delta(5) * drawingunit;
delta = pml_delta(end) * drawingunit;
deltal = mean(diff(pml_delta)) * drawingunit;
kappa0 = -log(R0)*log(g)/( 2*Zm*deltal*(g^(delta/deltal)-1) );
kappa0 = 1.05;
% kappa0 = 1.05;
CSX = AddMaterial( CSX, 'pml_xmin' );
CSX = SetMaterialProperty( CSX, 'pml_xmin', 'Epsilon', epr );
CSX = SetMaterialProperty( CSX, 'pml_xmin', 'Kappa', kappa0 );
CSX = SetMaterialProperty( CSX, 'pml_xmin', 'Sigma', kappa0 * MUE0/(EPS0*epr) );
CSX = SetMaterialWeight( CSX, 'pml_xmin', 'Kappa', [num2str(g) '^((abs(x)-' num2str(abs(mesh.x(6))) ')/(' num2str(deltal) '/' num2str(drawingunit) '))'] ); % g^(rho/deltal)*kappa0
CSX = SetMaterialWeight( CSX, 'pml_xmin', 'Sigma', [num2str(g) '^((abs(x)-' num2str(abs(mesh.x(6))) ')/(' num2str(deltal) '/' num2str(drawingunit) '))'] );
CSX = SetMaterialWeight( CSX, 'pml_xmin', 'Kappa', [num2str(g) '^((abs(x-100)-' num2str(abs(mesh.x(N_pml+1))) ')/(' num2str(deltal) '/' num2str(drawingunit) '))'] ); % g^(rho/deltal)*kappa0
CSX = SetMaterialWeight( CSX, 'pml_xmin', 'Sigma', [num2str(g) '^((abs(x-100)-' num2str(abs(mesh.x(N_pml+1))) ')/(' num2str(deltal) '/' num2str(drawingunit) '))'] );
start = [mesh.x(1), mesh.y(1), mesh.z(1)];
stop = [mesh.x(6), mesh.y(end), mesh.z(end)];
stop = [100, mesh.y(end), mesh.z(end)];
CSX = AddBox( CSX, 'pml_xmin', 1, start, stop );
figure
x = [-fliplr(pml_delta) 0];
plot( x, kappa0 * g.^((abs(x)-abs(mesh.x(6)))./(deltal/drawingunit)) );
x = [-fliplr(pml_delta) 50];
plot( x, kappa0 * g.^((abs(x-50)-abs(mesh.x(N_pml+1)))./(deltal/drawingunit)) ,'x-');
xlabel( 'x / m' );
ylabel( 'kappa' );
figure
@ -189,7 +190,7 @@ title( 'Reflection Coefficient' );
if exist('ref_1','var')
hold on
plot( f/1e9, ref_1,'Linewidth',2, 'Color', [1 0 0]);
plot( f/1e9, ref_1,'--','Linewidth',2, 'Color', [1 0 0]);
hold off
end
ref_1 = 20*log10(abs(gamma));

View File

@ -3,10 +3,10 @@ clear
clc
%% setup the simulation %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
length = 10000;
width = 1000;
height = 1000;
mesh_res = 20;
length = 5000;
width = 300;
height = 200;
mesh_res = 15;
abs_length = mesh_res*10;
EPS0 = 8.85418781762e-12;
@ -29,7 +29,7 @@ mkdir(Sim_Path);
%% setup FDTD parameter & excitation function %%%%%%%%%%%%%%%%%%%%%%%%%%%%%
FDTD = InitFDTD(5000,1e-5,'OverSampling',10);
FDTD = SetGaussExcite(FDTD,0.5e9,0.5e9);
BC = [1 1 0 0 0 0];
BC = [1 1 0 0 2 2];
FDTD = SetBoundaryCond(FDTD,BC);
%% setup CSXCAD geometry & mesh %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@ -39,32 +39,19 @@ mesh.y = -height/2 : mesh_res : height/2;
mesh.z = 0 : mesh_res : length;
CSX = DefineRectGrid(CSX, 1e-3,mesh);
%% fake pml %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
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);
%% apply the excitation %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
start=[-width/2 -height/2 0];
stop=[width/2 height/2 0];
start=[-width/2 -height/2 mesh.z(3)];
stop =[ width/2 height/2 mesh.z(3)];
CSX = AddExcitation(CSX,'excite',0,[0 1 0]);
CSX = AddBox(CSX,'excite',0 ,start,stop);
%% define dump boxes... %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
CSX = AddDump(CSX,'Et','FileType',1,'SubSampling','4,4,1');
CSX = AddDump(CSX,'Et','FileType',1,'SubSampling','4,4,4');
start = [mesh.x(1) , mesh.y(1) , mesh.z(1)];
stop = [mesh.x(end) , mesh.y(end) , mesh.z(end)];
CSX = AddBox(CSX,'Et',0 , start,stop);
CSX = AddDump(CSX,'Ht','DumpType',1,'FileType',1,'SubSampling','4,4,1','DumpMode',2);
CSX = AddDump(CSX,'Ht','DumpType',1,'FileType',1,'SubSampling','4,4,4','DumpMode',2);
CSX = AddBox(CSX,'Ht',0,start,stop);
%% Write openEMS compatoble xml-file %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

View File

@ -3,8 +3,7 @@ clear
clc
%% setup the simulation %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
abs_length = 250;
length = 4000;
length = 8000;
unit = 1e-3;
a = 1000;
width = a;
@ -34,7 +33,7 @@ func_Ey = [num2str(m/a/unit) '*sin(' num2str(m*pi/a) '*x)*cos(' num2str(n*pi/b)
openEMS_opts = '';
% openEMS_opts = [openEMS_opts ' --disable-dumps'];
% openEMS_opts = [openEMS_opts ' --debug-material'];
openEMS_opts = [openEMS_opts ' --engine=sse-compressed'];
openEMS_opts = [openEMS_opts ' --engine=fastest'];
Sim_Path = 'tmp';
Sim_CSX = 'rect_wg.xml';
@ -45,9 +44,9 @@ end
mkdir(Sim_Path);
%% setup FDTD parameter & excitation function %%%%%%%%%%%%%%%%%%%%%%%%%%%%%
FDTD = InitFDTD(500,1e-6,'OverSampling',6);
FDTD = SetSinusExcite(FDTD,f0);
BC = [0 0 0 0 0 0];
FDTD = InitFDTD(50000,1e-5,'OverSampling',6);
FDTD = SetGaussExcite(FDTD,f0,f0/3);
BC = [0 0 0 0 2 2];
FDTD = SetBoundaryCond(FDTD,BC);
%% setup CSXCAD geometry & mesh %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@ -57,24 +56,9 @@ mesh.y = 0 : mesh_res(2) : height;
mesh.z = 0 : mesh_res(3) : length;
CSX = DefineRectGrid(CSX, unit,mesh);
%% fake pml %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
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=[0 0 length-abs_length];
stop=[width height length];
CSX = AddBox(CSX,'pml',0 ,start,stop);
start=[0 0 -length+abs_length];
stop=[width height -length];
CSX = AddBox(CSX,'pml',0 ,start,stop);
%% apply the excitation %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
start=[0 0 0];
stop=[width height 0];
start=[0 0 mesh.z(3) ];
stop =[width height mesh.z(3) ];
CSX = AddExcitation(CSX,'excite',0,[1 1 0]);
weight{1} = func_Ex;
weight{2} = func_Ey;
@ -83,28 +67,16 @@ CSX = SetExcitationWeight(CSX,'excite',weight);
CSX = AddBox(CSX,'excite',0 ,start,stop);
%% define dump boxes... %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
CSX = AddDump(CSX,'Et','FileType',1,'SubSampling','4,4,4');
start = [mesh.x(1) , mesh.y(1) , mesh.z(1)];
stop = [mesh.x(end) , mesh.y(end) , mesh.z(end)];
CSX = AddDump(CSX,'Et','FileType',0,'SubSampling','4,4,1');
start = [mesh.x(1) , height/2 , mesh.z(1)];
stop = [mesh.x(end) , height/2 , mesh.z(end)];
CSX = AddBox(CSX,'Et',0 , start,stop);
CSX = AddDump(CSX,'Ht','DumpType',1,'FileType',1,'SubSampling','4,4,4');
CSX = AddBox(CSX,'Ht',0,start,stop);
% CSX = AddDump(CSX,'Ht','DumpType',1,'FileType',1,'SubSampling','4,4,4');
% CSX = AddBox(CSX,'Ht',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
args = [Sim_CSX ' ' openEMS_opts];
invoke_openEMS(args);
cd(savePath);
RunOpenEMS(Sim_Path, Sim_CSX, openEMS_opts)
%% do the plots %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
PlotArgs.slice = {mesh.x(round(end/2)) mesh.y(round(end/2)) mesh.z(round(end/2))};
PlotArgs.pauseTime=0.01;
PlotArgs.component=2;
PlotArgs.Limit = 'auto';
PlotHDF5FieldData('tmp/Et.h5',PlotArgs)