2010-04-30 12:56:46 +00:00
|
|
|
close all
|
|
|
|
clear
|
2010-03-22 22:15:04 +00:00
|
|
|
clc
|
|
|
|
|
2010-04-24 14:47:40 +00:00
|
|
|
%% setup the simulation %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
2010-03-23 22:48:32 +00:00
|
|
|
feed_length=10;
|
|
|
|
wire_rad = sqrt(1.4/pi);
|
2010-04-17 20:10:33 +00:00
|
|
|
mesh_size = wire_rad;
|
2010-03-23 22:48:32 +00:00
|
|
|
coil_rad = 10;
|
|
|
|
coil_length = 50;
|
|
|
|
coil_turns = 8;
|
|
|
|
coil_res = 10;
|
2010-04-17 20:10:33 +00:00
|
|
|
port_length = mesh_size; %coil_length/2;
|
|
|
|
port_resist = 1000;
|
2010-03-23 22:48:32 +00:00
|
|
|
|
2010-04-17 20:10:33 +00:00
|
|
|
f_max = 100e6;
|
2010-04-28 15:54:27 +00:00
|
|
|
f_excite = 300e6;
|
2010-03-23 22:48:32 +00:00
|
|
|
|
2010-04-30 12:56:46 +00:00
|
|
|
%% define openEMS options %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
2010-03-22 22:15:04 +00:00
|
|
|
openEMS_opts = '';
|
2010-05-25 10:17:09 +00:00
|
|
|
% openEMS_opts = [openEMS_opts ' --debug-material'];
|
|
|
|
% openEMS_opts = [openEMS_opts ' --debug-boxes'];
|
2010-03-29 20:12:01 +00:00
|
|
|
% openEMS_opts = [openEMS_opts ' --debug-operator'];
|
2010-03-22 22:15:04 +00:00
|
|
|
|
2010-06-09 07:22:54 +00:00
|
|
|
openEMS_opts = [openEMS_opts ' --disable-dumps --engine=fastest'];
|
|
|
|
% openEMS_opts = [openEMS_opts ' --engine=sse-compressed'];
|
2010-05-25 10:17:09 +00:00
|
|
|
|
2010-03-22 22:15:04 +00:00
|
|
|
Sim_Path = 'tmp';
|
|
|
|
Sim_CSX = 'helix.xml';
|
|
|
|
|
2010-04-30 12:56:46 +00:00
|
|
|
[status, message, messageid] = rmdir(Sim_Path,'s');
|
|
|
|
[status,message,messageid] = mkdir(Sim_Path);
|
2010-03-22 22:15:04 +00:00
|
|
|
|
2010-04-24 14:47:40 +00:00
|
|
|
%% setup FDTD parameter & excitation function %%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
2010-04-28 15:54:27 +00:00
|
|
|
FDTD = InitFDTD(30000,1e-6);
|
2010-03-29 20:12:01 +00:00
|
|
|
FDTD = SetGaussExcite(FDTD,f_excite/2,f_excite/2);
|
2010-03-22 22:15:04 +00:00
|
|
|
BC = [1 1 1 1 1 1];
|
|
|
|
FDTD = SetBoundaryCond(FDTD,BC);
|
|
|
|
|
2010-04-24 14:47:40 +00:00
|
|
|
%% setup CSXCAD geometry & mesh %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
2010-03-30 06:19:41 +00:00
|
|
|
add_Lines = mesh_size * 1.5.^(1:10);
|
|
|
|
add_Lines = add_Lines(find(add_Lines<(3e8/f_excite)/10*1e3));
|
2010-03-29 20:12:01 +00:00
|
|
|
|
2010-03-23 22:48:32 +00:00
|
|
|
CSX = InitCSX();
|
2010-03-29 20:12:01 +00:00
|
|
|
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.y = -coil_rad-mesh_size : mesh_size : coil_rad+mesh_size;
|
|
|
|
mesh.y = [mesh.y(1)-add_Lines mesh.y mesh.y(end)+add_Lines ];
|
|
|
|
mesh.z = -mesh_size : mesh_size : coil_length+mesh_size;
|
|
|
|
mesh.z = [mesh.z(1)-add_Lines mesh.z mesh.z(end)+add_Lines ];
|
2010-03-23 22:48:32 +00:00
|
|
|
CSX = DefineRectGrid(CSX, 1e-3,mesh);
|
|
|
|
|
2010-04-24 14:47:40 +00:00
|
|
|
%% build/define helix %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
2010-03-23 22:48:32 +00:00
|
|
|
CSX = AddMaterial(CSX,'copper');
|
|
|
|
CSX = SetMaterialProperty(CSX,'copper','Kappa',56e6);
|
|
|
|
|
|
|
|
dt = 1.0/coil_res;
|
|
|
|
height=0;
|
|
|
|
wire.Vertex = {};
|
2010-03-29 20:12:01 +00:00
|
|
|
p(1,1) = coil_rad + feed_length;
|
|
|
|
p(2,1) = 0;
|
|
|
|
p(3,1) = 0.5*(coil_length-port_length);
|
|
|
|
p(1,2) = coil_rad + feed_length;
|
|
|
|
p(2,2) = 0;
|
|
|
|
p(3,2) = 0;
|
|
|
|
count=2;
|
2010-03-23 22:48:32 +00:00
|
|
|
for n=0:coil_turns-1
|
|
|
|
for m=0:coil_res
|
|
|
|
count = count + 1;
|
|
|
|
p(1,count) = coil_rad * cos(2*pi*dt*m);
|
|
|
|
p(2,count) = coil_rad * sin(2*pi*dt*m);
|
|
|
|
p(3,count) = height + coil_length/coil_turns * dt*m;
|
|
|
|
end
|
|
|
|
height = height + coil_length/coil_turns;
|
|
|
|
end
|
2010-03-29 20:12:01 +00:00
|
|
|
p(1,count+1) = coil_rad + feed_length;
|
|
|
|
p(2,count+1) = 0;
|
|
|
|
p(3,count+1) = coil_length;
|
|
|
|
p(1,count+2) = coil_rad + feed_length;
|
|
|
|
p(2,count+2) = 0;
|
|
|
|
p(3,count+2) = 0.5*(coil_length+port_length);
|
2010-03-23 22:48:32 +00:00
|
|
|
CSX = AddWire(CSX, 'copper', 0, p, wire_rad);
|
|
|
|
|
2010-04-24 14:47:40 +00:00
|
|
|
%% apply the excitation & resist as a current source%%%%%%%%%%%%%%%%%%%%%%%
|
2010-03-23 22:48:32 +00:00
|
|
|
CSX = AddMaterial(CSX,'resist');
|
2010-03-29 20:12:01 +00:00
|
|
|
kappa = port_length/port_resist/wire_rad^2/pi/1e-3;
|
2010-03-23 22:48:32 +00:00
|
|
|
CSX = SetMaterialProperty(CSX,'resist','Kappa',kappa);
|
|
|
|
|
2010-03-29 20:12:01 +00:00
|
|
|
start=[coil_rad+feed_length 0 (coil_length-port_length)/2];
|
|
|
|
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;
|
2010-03-23 22:48:32 +00:00
|
|
|
CSX = AddCylinder(CSX,'resist',5 ,start,stop,wire_rad);
|
|
|
|
|
|
|
|
CSX = AddExcitation(CSX,'excite',0,[0 0 1]);
|
|
|
|
CSX = AddCylinder(CSX,'excite', 0 ,start,stop,wire_rad);
|
|
|
|
|
2010-04-24 14:47:40 +00:00
|
|
|
%% define voltage calc boxes %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
2010-03-23 22:48:32 +00:00
|
|
|
%voltage calc
|
|
|
|
CSX = AddProbe(CSX,'ut1',0);
|
2010-03-29 20:12:01 +00:00
|
|
|
CSX = AddBox(CSX,'ut1', 0 ,stop,start);
|
2010-03-23 22:48:32 +00:00
|
|
|
|
|
|
|
%current calc
|
|
|
|
CSX = AddProbe(CSX,'it1',1);
|
2010-04-17 20:10:33 +00:00
|
|
|
start(3) = coil_length/2+mesh_size;stop(3) = coil_length/2+mesh_size;
|
2010-03-23 22:48:32 +00:00
|
|
|
start(1) = start(1)-2;start(2) = start(2)-2;
|
|
|
|
stop(1) = stop(1)+2;stop(2) = stop(2)+2;
|
|
|
|
CSX = AddBox(CSX,'it1', 0 ,start,stop);
|
2010-03-22 22:15:04 +00:00
|
|
|
|
2010-04-24 14:47:40 +00:00
|
|
|
%% define dump boxes... %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
2010-04-07 10:57:45 +00:00
|
|
|
CSX = AddDump(CSX,'Et_');
|
2010-03-29 20:12:01 +00:00
|
|
|
start = [mesh.x(1) , 0 , mesh.z(1)];
|
|
|
|
stop = [mesh.x(end) , 0 , mesh.z(end)];
|
|
|
|
CSX = AddBox(CSX,'Et_',0 , start,stop);
|
|
|
|
|
2010-04-07 10:57:45 +00:00
|
|
|
CSX = AddDump(CSX,'Ht_','DumpType',1);
|
2010-03-29 20:12:01 +00:00
|
|
|
start = [mesh.x(1) , 0 , mesh.z(1)];
|
|
|
|
stop = [mesh.x(end) , 0 , mesh.z(end)];
|
|
|
|
CSX = AddBox(CSX,'Ht_',0 , start,stop);
|
|
|
|
|
2010-04-24 14:47:40 +00:00
|
|
|
%% Write openEMS compatoble xml-file %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
2010-03-22 22:15:04 +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-22 22:15:04 +00:00
|
|
|
|
2010-04-24 14:47:40 +00:00
|
|
|
%% postproc & do the plots %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
2010-03-29 20:12:01 +00:00
|
|
|
U = ReadUI('ut1','tmp/');
|
|
|
|
I = ReadUI('it1','tmp/');
|
|
|
|
|
2010-04-17 20:10:33 +00:00
|
|
|
delta_t_2 = I.TD{1}.t(1) - U.TD{1}.t(1); % half time-step (s)
|
|
|
|
I.FD{1}.val = I.FD{1}.val .* exp(-1i*2*pi*I.FD{1}.f*delta_t_2); % compensate half time-step advance of H-field
|
|
|
|
|
2010-03-29 20:12:01 +00:00
|
|
|
Z = U.FD{1}.val./I.FD{1}.val;
|
|
|
|
f = U.FD{1}.f;
|
|
|
|
L = imag(Z)./(f*2*pi);
|
|
|
|
R = real(Z);
|
|
|
|
ind = find(f<f_max);
|
|
|
|
|
|
|
|
subplot(2,1,1);
|
|
|
|
plot(f(ind)*1e-6,L(ind)*1e9,'Linewidth',2);
|
|
|
|
xlabel('frequency (MHz)');
|
|
|
|
ylabel('coil inductance (nH)');
|
|
|
|
grid on;
|
|
|
|
subplot(2,1,2);
|
|
|
|
plot(f(ind)*1e-6,R(ind),'Linewidth',2);
|
2010-04-17 20:10:33 +00:00
|
|
|
hold on
|
|
|
|
plot(f(ind)*1e-6,imag(Z(ind)),'r','Linewidth',2);
|
2010-03-29 20:12:01 +00:00
|
|
|
xlabel('frequency (MHz)');
|
2010-04-28 15:54:27 +00:00
|
|
|
ylabel('resistance (Ohm)');
|
|
|
|
grid on;
|
|
|
|
legend( {'real','imaginary'}, 'location', 'northwest' )
|
|
|
|
|
|
|
|
figure
|
|
|
|
plot(U.TD{1}.t/1e-6,U.TD{1}.val,'Linewidth',2);
|
|
|
|
xlabel('time (us)');
|
|
|
|
ylabel('amplitude (V)');
|
2010-03-29 20:12:01 +00:00
|
|
|
grid on;
|