Beruflich Dokumente
Kultur Dokumente
EXAMPLE 1.1
Click any to open the MATLAB script solving this exercise. Run script to read question and calculate solution.
On 1st run, the exercise is solved and the results are stored in .mat file. Parameters can be modified to solve
exercise variations. MATLAB student licences are cheap and there is a type that does not even require to be
registered in any university or college. All comments welcome.
To download and install MATLAB as well as review help on specific commands click any MATLAB icon:
Contents
Introduction
Quick solution to example 1.1
1D Basic Modelling Scenarios
[ED] 1D FDTD starting example
So why the low timing of [ED] opening example?
Solution: Split simulation and display
Saving and retrieving simulated E H
Absorbing materials on boundaries
Simulating How to Measure relative permittivity
[WRK1] 1D Example
Literature References
Notes
[ED] Original Appendix A : 1D wave slow simulation
Support functions to [ED] Example
Appendix A to [ED] : Original 1D wave slow simulation
______________________________________________________________________________________________________________________________
John Bofarull Guix jgb2012@sky.com attached: -- 1 / 26
POZAR chapter 01: example 01 24/12/2020 08:42:56.
Introduction
Electromagnetism is one of the branches of physics [VIK1].
Maxwell equations, the base to classical electromagnetism, are explained, among others, in detail in professor Fitzpatrick Lectures, read [FPAT].
Attached to this documents, copy of [ORF1] chapter 1 and chapter 2. Also attached solutions manual to exercises in [ORF1] chapters 1 and 2.
In my opinion the most concise, compact and at the same time useful text explaining the constitutive equations of electromagnetism is [SDK1] 3rd edition
(still with Fortran routines)and the 4th edition, same title with all support code in MATLAB.
A perfectly flat plane wave travelling through an infinite homogeneous material is equivalent to a 1D wave propagation/attenuation model.
______________________________________________________________________________________________________________________________
John Bofarull Guix jgb2012@sky.com attached: -- 2 / 26
POZAR chapter 01: example 01 24/12/2020 08:42:56.
pozar_01_example_01.m
c0=299795856; % [m/s]
etha0=120*pi; % [ohm]
f0=5e9 f0 =
5.000000000000000e+09
% probably out of direct measurement, wavelength is provided
lambda=.03 lambda =
0.030000000000000
Next, a 1st contact with Finite Difference Time Domain to solve 1D wave equations.
In order to work with Electric and Magnetic fields efficiently, any engineer knows that either you work with spectrum analysers and tools of the trade,
meaning real measurements from real signals, or the next best thing, under certain limited circumstances (these circumstances being time and simulation
tools availability) one models, simulates and develops designs efficiently, preventing design problems propagate to field operations and down to production
lines, store shelves, and worst case would be to customers.
To this purpose literature references [ED] [TXEP] [WRK1] are included as support sources while solving [POZAR] with MATLAB.
[ED] is among the best literature references I have found so far to simulate electromagnetic fields with the FDTD method. I have modified [ED] Appendix
A, a 1D FDTD starter script example (comment [1]).
4. Calculate and T
5. Multiple materials
______________________________________________________________________________________________________________________________
John Bofarull Guix jgb2012@sky.com attached: -- 3 / 26
POZAR chapter 01: example 01 24/12/2020 08:42:56.
When dimensioning the space to simulate, one cannot simply double or halve for
instance domain_source , or make the cavity larger or smaller without the simulation
potentially suffering dispersion.
[ED] Appendix A script shows heavy numerical dispersion. Because the script is so slow,
the amount of time iterations is so low that only the 1st bouncing shows up, if the
spectators have patience to wait.
And it's even not half way the total number_of_time_steps and just a couple
bounces.
______________________________________________________________________________________________________________________________
John Bofarull Guix jgb2012@sky.com attached: -- 4 / 26
POZAR chapter 01: example 01 24/12/2020 08:42:56.
I0 is the pulse amplitude, that has to be modified accordingly because the display
box is static, doesn´t shrink or expand to meet the signals inside.
So this is [ED] suggested pulse, with the signal source located right in the middle of
the 1D grid, in between perfect metal reflectors.
Since example 1.1 is about calculating wave parameters of a 5GHz plane wave
travelling through lossless dielectric medium, electric field wave with expression
E0*cos(2*pi*f0*t-beta*z), then replacing the Gaussian test pulse with sin^2
seems reasonable.
Again, with the initial script parameters dx and dt, the dispersion is again excessive
for a burst of sin^2 pulses.
Following, code lines to build a single frequency burst of pulses, overlapped, in red, the Gaussian pulse.
figure;plot(time,Jz_waveform);grid on
hold all
plot(time,Jz_waveform_ref);title('test signal + reference')
close all
______________________________________________________________________________________________________________________________
John Bofarull Guix jgb2012@sky.com attached: -- 5 / 26
POZAR chapter 01: example 01 24/12/2020 08:42:56.
f0=1e8
I0=.3
domain_size=1.25
dx=1e-2
dt=1e-13
nt=75000
n3=1 % dx=n3*dx;dt=n3*dt
n2=3 % main loop time step
After playing a bit with different values of dx and dt as shown in following fdtd_1d_4_1.m , [ED] Appendix A simulations starts going somewhere.
Free space defined in initialize_fields_and_materials_1.m
[ED] shows the good practice of building different modules instead of writing all code in same single file. I have modified [ED] start script in Appendix A,
into the fddtd_1d_4_1.m . All support functions to run fdtd_1d_4_1.m are:
check_cell2lambda.m
check_numerical_stability.m
E_display_loop.n
init_E_display_loop.m
initialize_fdtdt_coefficients.m
initialize_fields_and_materials_1.m
initialize_plotting_parameters.m
measure_numerical_dispersion.m
plot_fields_while_solving_fdtd.m
Just once more, I have renamed [ED] plot_fields.m to plot_fields_while_solving_fdtd.m to highlight the point that it's not an efficient practice to
nest plot inside for loops. Even more considering that at each iteration electromagnetic fields coefficients are updated, that for relatively large models,
there is where the computing capacity has to go, not to repeating command plot every time fields are updated.
______________________________________________________________________________________________________________________________
John Bofarull Guix jgb2012@sky.com attached: -- 6 / 26
POZAR chapter 01: example 01 24/12/2020 08:42:56.
% fdtd_1d_4_1_1.m
n4=1/2
eps_0=n4*eps_0;
mu_0=n4*mu_0;
% GEOMETRY
n3=1
% eps_0=n3*eps_0
% mu_0=n3*mu_0
domain_size=n3*domain_size
dx=n3*dx
dt=n3*dt
% BAND
f0=5e7;
lambda0=c0/f0
check_numerical_stability
% gauss pulse; here used as reference only, test carried out with burst of
single freq sin cycles
% t0=2e-10
% % t0=0
% tau0=5e-10 changed amplitude, frequency, and length material under test.
% % Jz_waveform_ref = I0*exp(-((time-t0)/tau0).^2)';
% Jz_waveform_ref = I0*exp(-((time-t0)/tau0))';
measure_numerical_dispersion
check_cell2lambda % Nlambda>10 at least
initialize_fdtd_coefficients
initialize_plotting_parameters;
Hy_sim=zeros([nt size(Hy)]);
Ez_sim=zeros([nt size(Ez)]);
Jz(source_position_index) = Jz_waveform(kt);
Hy(1:nx) =...
Chyh(1:nx).*Hy(1:nx)+Chyez(1:nx).*(Ez(2:nx+1)-...
Ez(1:nx))+Chym(1:nx).*My(1:nx);
Ez(2:nx) =...
Ceze(2:nx).*Ez(2:nx)+Cezhy(2:nx).*(Hy(2:nx)-...
Hy(1:nx-1))+Cezj(2:nx).*Jz(2:nx);
if kt<=n0
Ez(source_position_index-1)=0;
end
plot_fields_while_solving_fdtd;
end
toc
init_E_display_loop
%% E DISPLAY LOOP
E_display_loop
%% H DISPLAY LOOP
initialize_fields_and_materials_1.m
% initialize_fields_and_materials_1.m
% support function for fdtd_1d_4_1.m
% free space
Ceze = zeros(nx+1,1);
Cezhy = zeros(nx+1,1);
Cezj = zeros(nx+1,1);
Ez = zeros(nx+1,1);
Jz = zeros(nx+1,1);
eps_r_z = ones(nx+1,1); % free space
sigma_e_z = zeros(nx+1,1); % free space
% sigma_e_z = 4.4e-4*ones(nx+1,1); % Silicon
% sigma_e_z = 2e-4*ones(nx+1,1); % distilled water
% sigma_e_z = 4*ones(nx+1,1); % sea water
% sigma_e_z=5.823e7 % Cu
% sigma_e_z=6.173e7 % Ag
% sigma_e_z=5 % sea water
% sigma_e_z=9.52e7 % Pt
Chyh = zeros(nx,1);
Chyez = zeros(nx,1);
Chym = zeros(nx,1);
Hy = zeros(nx,1);
My = zeros(nx,1);
mu_r_y = ones (nx,1); % free space
sigma_m_y = zeros(nx,1); % free space
______________________________________________________________________________________________________________________________
John Bofarull Guix jgb2012@sky.com attached: -- 8 / 26
POZAR chapter 01: example 01 24/12/2020 08:42:56.
I tried scaling permittivity and permeability in [ED] Appendix A script but there was no reduction in processing time.
nt=7500000
dt=1e-13
Also tried mu_0=1 and eps_0= eps_0/mu_0 but far worse, nothing starts, yet all busy.
Applying tic toc with nt=7.5e6 and plot_fields.m suppressed, then it only takes 41 seconds to generate all data.
..
% plot_fields;
end
toc
When attempting to store all simulated values the required size of the variables where storing simulated fields may exceed MATLAB default matrix roof size:
Hy_sim=zeros([size(Hy) nt]);
Ez_sim=zeros([size(Ez) nt]); Error using zeros
Requested 12500x1x7500000 (698.5GB) array exceeds maximum array
.. size preference. Creation of arrays greater than this limit may
take a long time and cause MATLAB to become unresponsive. See
for kt=1:n2:nt array size limit or preference panel for more information.
..
Hy_sim(:,kt)=Hy;
Ez_sim(:,kt)=Ez;
..
end
n2 only for test purposes. One cannot use n2 too high or the shape of the test signal is lost. Also, n2>1 in the time loop compresses the signal in space.
The signal is still going to bounce back wherever a reflector is found, but then domain_size reduction may be the only way to get the signal getting to any
boundary, for the same nt.
I found it useful to collect main parameters in Excel spread sheet fdtd_budget.xls and shift values up and down before applying them in the script:
c0 2.9981E+08
f0 5.0000E+07
lambda0 5.9963E+00
domain_size 1.0250E+01 2.0250E+01
Yee cell size: dx 1.0000E-02 1.0000E-02
amount space samples: nx 1.0250E+03 2.0250E+03
observation_time
amount time samples: dt 7.5000E+06 7.5000E+04
time resolution: dt 1.0000E-09 1.0000E-11
______________________________________________________________________________________________________________________________
John Bofarull Guix jgb2012@sky.com attached: -- 9 / 26
POZAR chapter 01: example 01 24/12/2020 08:42:56.
Splitting the main loop into two loops, one for simulation calculations, and
the other one to display values, fdtd_1d_4_1_2.m
This approach allows to simulate fields with wait time a fraction only of that
required to run [ED] Appendix A script. The pace of the simulation display
can also be changed without having to recalculate every single time. On the
right hand side the start pulse that correctly bounces on both side boundary
perfect conductors.
At the cost of a few more lines, I have copied all necessary files to run fdtd_1d_4_2.m into a separate folder. This is another point that perhaps [ED]
should consider in next edition, because while the abundance of working scripts helps read and understand a text, having to guess what files to reuse from
previous chapters doesn't help.
init_E_display_loop.m
% init_E_display_loop.m
case dloc_dot<2
L1=L1([1:find(L1=='.')+length(L1)-loc_dot]);
case dloc_dot>=2
L1=L1([1:find(L1=='.')+2]);
otherwise
end
end
cell_x_ruler{sk3}=L1;
end
hf2.CurrentAxes.XTickLabel=cell_x_ruler;
title(hf2.CurrentAxes,'simulated Ez')
E_display_loop.m
if kt>1
E_frame(floor(kt/n20))=getframe; % ignore 1st frame
end
drawnow
end
sigma_e_z = 4.4e-4*ones(nx+1,1)
______________________________________________________________________________________________________________________________
John Bofarull Guix jgb2012@sky.com attached: -- 11 / 26
POZAR chapter 01: example 01 24/12/2020 08:42:56.
The main purpose of including fields simulation in the very 1st example of [POZAR] solved with MATLAB is to build and upgrade tools needed when
working with electromagnetic fields. Since potentially many models my require considerable time or even need graphics card, read [ED] closing chapter,
in this example I have a 1st contact with the need of efficient storage of the simulated fields. A basic start point may be function save_load_fields.m
appended at the end of this note.
Why recalculate it all every time? here I briefly attempted adding storage support function for calculated fields, including clause to choose whether use
stored fields, if in same folder, or just recalculate. With
dx = 0.010000000000000
dt = 9.999999999999999e-12
f0 = 50000000
nt = 75000
nx = 2025
then
nt*nx =
151875000
Yet stored field in file size, for different parameters used, for just Ez_sim , it exceeds 2GB.
I also check whether getframe would somehow save disk space for same simulated field size.
% E_display_loop.m
if kt>1
E_frame(floor(kt/n20))=getframe; % ignore 1st frame
end
drawnow
end
movie can be used to reproduce simulation directly from workspace, with movie(E_frame)
save('E_frame.mat','E_frame')
filename=E_frame.mat
load(filename)
or
load('E_frame.mat')
______________________________________________________________________________________________________________________________
John Bofarull Guix jgb2012@sky.com attached: -- 12 / 26
POZAR chapter 01: example 01 24/12/2020 08:42:56.
However, it's a back-to-square-one effort: using getframe and movie doesn't save file size. There is no data compression because E_frame.mat and
E_sim_field.mat have same size.
Saving 1st derivative dE/dt, instead of E halves the size of the .mat file, but given the large amount of zeros, there has to be a far more efficient way to
save simulated fields data.
Edot_sim=diff(Ez_sim);
save Edot_sim.mat 'Edot_sim'
zip('Edot_sim.zip','Edot_sim.mat')
L3=dir('E*field*') L3 =
2×1 struct array with fields:
name
folder
date
bytes
isdir
datenum
L3.bytes =
1.112588546000000e+09
=
1.112596480000000e+09
Efficiently compressing fields data is one of the many benchmarks of commercial electromagnetic simulators. No further time will be spent on this point.
______________________________________________________________________________________________________________________________
John Bofarull Guix jgb2012@sky.com attached: -- 13 / 26
POZAR chapter 01: example 01 24/12/2020 08:42:56.
https://leadertechinc.com/blog/different-types-rf-absorbers/
eps =eps0*er
I tried the following to simulate the so called Perfect Matched Layer PML
Ez(nx+1)=-Ez(nx)
the simple single code line, magic effortless single line of code that solves it all. But this IT mentality, that a single line of code can solve all, in line with the
thinking that a hand held calculator suffices to master electromagnetics, or a canoe rowing pad can do instead of a Sea King chopper. Don't want to
disappoint any one, but it doesn't work this way. Just shifting electric field phase 180° does not behave as PML, it's just another way to implement a
reflector.
______________________________________________________________________________________________________________________________
John Bofarull Guix jgb2012@sky.com attached: -- 14 / 26
POZAR chapter 01: example 01 24/12/2020 08:42:56.
However, a magnetic wall, although not exactly a PML, it approaches the equivalent wave impedance to that of free space, as if the boundary layer were RF
'transparent'. To such purpose, replace
with
Ez(nx+1) = -Ez(nx);
Hy(1) = 0;
Hy(nx+1) = 0;
Ez(nx+1)=Cezxe_border1*Ez(nx)+Cezxby_border1*(Hz(nx+1)-Hz(nx))
Cezxe_border1=1
Cezxby_border1=dt/(eps_0*dx)
When using initialize_fields_and_materials_1.m lossless material, with With initialize_fields_and_materials_4.m , lossy material,
a hold all right before calling E_display_loop the following s obtained: Appreciate that the green line showing the return is far lower than when
If just 'some' absorption is ok, 'some' as in how many dB do you need, then an approximation of matched layer for 1D absorber would be a magnetic wall:
This is not a thick PML, just an approximation of PML code solution provide in [ED] chapter 7, but sometimes combining a thin absorber with lossy material
may be ok.
______________________________________________________________________________________________________________________________
John Bofarull Guix jgb2012@sky.com attached: -- 15 / 26
POZAR chapter 01: example 01 24/12/2020 08:42:56.
There's no need for absorber, or even to cut the transmission line at a specific
length. Not even to know the exact value of the load, but the closer to a short
the better to get as much return as possible.
However, a far longer train of pulses is needed, otherwise only 2 peaks would
show up when near reflection, and let's apply example 1.1 parameters.
In fdtd_1d_4_5.m the following FDTD parameters matching example 1.1 question are applied
domain_size = .25;
dx = 1e-3;
nt = 175000;
dt = 1e-13;
f0=5e9;
source_position = .01
I0=1
Np=5
(176-145)*dx =
0.031000000000000
or directly
mean_Ez_sim=mean(Ez_sim,1);
figure;plot(x,mean_Ez_sim);grid on
xlabel('x');ylabel('Ez sim')
figure;plot(x,mean_Ez_sim);grid on
xlabel('x');ylabel('|Ez sim|')
title('stationary wave to measure \lambda')
[row,col,v]=findpeaks(mean_Ez_sim)
______________________________________________________________________________________________________________________________
John Bofarull Guix jgb2012@sky.com attached: -- 16 / 26
POZAR chapter 01: example 01 24/12/2020 08:42:56.
x_peaks=x(col)
x_peaks =
0.008 0.016 0.045 0.075 0.107 0.143 0.175 0.206 0.235
hold all;plot(x(col),mean_Ez_sim(col),'ro')
Once lambda has been measured, then it's time to plug the initial lines calculate wave constant kz propagation velocity vp and relative permittivity er
When producing enough pulses against any load other than PML or a matched load, if watching
long enough, then wave peaks are observable, similarly to [POZAR] example 2.4 supplied
measurement.
______________________________________________________________________________________________________________________________
John Bofarull Guix jgb2012@sky.com attached: -- 17 / 26
POZAR chapter 01: example 01 24/12/2020 08:42:56.
[WRK1] 1D Example
Pre-processing: eps0=8.854e-12
mu0=4*pi*1e-7
For a single Gaussian pulse from left to right across 2 different materials, c0=1/(eps0*mu0)^.5
from higher relative permittivity in left hand side material to er=1 on right
hand side. epsr1=2
epsr2=1
In the post-processing part the reflection coefficient obtained out the c1=c0/(epsr1)^.5
simulation is compared with direct calculation. c2=c0/(epsr2)^.5
D=1
tmax=3*4.5e-9
r=1
NX=1e2
dx=D/(NX-1)
dt=r*dx/c0
NT=ceil(tmax/dt)
x=[0:dx:D];
t0=60*dt
s=10*dt % pulse width
u1=zeros(NX,1);
u2=zeros(NX,1);
u3=zeros(NX,1);
idx2=find(x>D/2)
a1(idx2)=(c2*dt/dx)^2;
hf1=figure(1)
hf1.OuterPosition=[672 550 776 513]
ax1=gca
axis([0 1 -2 2])
rectangle('Position',[0 -2 .5 4],...
'FaceColor',[.5 .8 .8],...
'EdgeColor','none')
grid on
hold on
hp1=plot(ax1,[.5 .5],[-2 2],'--')
ax1.DataAspectRatio=[1 4 1]
L1=line(x,u3)
L1.LineWidth=1.5
drawnow
hold off
for n=1:1:NT
t=n*dt;
u3(1)=exp(-(t-t0)^2/(2*s^2)); % source left hand side
u3(NX)=u2(NX-1) + a2*(u3(NX-1)-u2(NX));
% absorbing boundary right hand side
L1.YData=u3
G1.String=[num2str(t/1e-9,2) ' ns'];
drawnow
end
idx1=find(x<D/2);
______________________________________________________________________________________________________________________________
John Bofarull Guix jgb2012@sky.com attached: -- 19 / 26
POZAR chapter 01: example 01 24/12/2020 08:42:56.
idx1=find(x<D/2)
R1=u3(idx2) R1 =
-0.172177960854231
% Exact reflection coefficient er=1 to er=2
R2=(sqrt(1/epsr2)-1/sqrt(epsr1))/(sqrt(1/epsr2)+sqrt(1/epsr1)) R2 =
-0.171572875253810
I also repeated with er=1 to er=20 same tmax and these are the
results
______________________________________________________________________________________________________________________________
John Bofarull Guix jgb2012@sky.com attached: -- 20 / 26
POZAR chapter 01: example 01 24/12/2020 08:42:56.
R1=u3(idx2) R1 =
-0.642044721718689
% Exact reflection coefficient er=1 to er=20
R2=(sqrt(1/epsr2)-1/sqrt(epsr1))/(sqrt(1/epsr2)+sqrt(1/epsr1)) R2 =
-0.634512004736886
Run attached script example_1D_2_materials_KWarnick.m to obtain all these graphs and results.
Literature References
[VIK1]
https://en.wikipedia.org/wiki/Electromagnetism
Classical
Classical mechanics Acoustics Classical electromagnetism Optics Thermodynamics Statistical mechanics
Modern Quantum mechanics Special relativity General relativity Particle physics Nuclear physics Quantum chromodynamics
Atomic, molecular, and optical physics Condensed matter physics Cosmology Astrophysics
Interdisciplinary Atmospheric physics Biophysics Chemical physics Engineering physics Geophysics Materials science
Mathematical physics
[FPAT]
by Richard Fitzpatrick
http://farside.ph.utexas.edu/teaching/em/lectures/lectures.html
[ORF1]
orfanidi@ece.rutgers.edu www.ece.rutgers.edu/~orfanidi/ewa
[SDK1]
by Matthew Sadiku
https://www.amazon.co.uk/Numerical-Techniques-Electromagnetics-MATLAB-Third/dp/142006309X/ref=sr_1_fkmr0_1?ie=UTF8&qid=1523113439&sr=8-1fkmr0&keywords=Sadiki+Electromagnetics+MATLAB
______________________________________________________________________________________________________________________________
John Bofarull Guix jgb2012@sky.com attached: -- 21 / 26
POZAR chapter 01: example 01 24/12/2020 08:42:56.
[RAO1]
by Sathyanarayan Rao
attached copy
https://uk.mathworks.com/matlabcentral/fileexchange/55301-two-dimensional-wave-
interference-using-finite-difference-time-domain-method-fdtd?s_tid=prof_contriblnk
[WRK1]
Numerical Methods for Engineering an introduction using MATLAB and computational electromagnetics examples
by K.Warnick
[CHT1]
S. Chatterjee
attached copy
https://uk.mathworks.com/matlabcentral/fileexchange/31941-horn-antenna-s-fdtd-simulation?s_tid=srchtitle
[AKZK]
Permittivity of pure water, at standard atmospheric pressure, over the frequency range 0-25 Thz and the temperature range 0-100 C.
W. Ellison,
J. Phys. Chem. Ref. Data 36, 1–18 (2007).
Notes
[1] : [ED] Appendix A 1D script consumes too much time, not for the pulse to get to the boundaries only, but just for the pulse to show up on screen,
right after having launched the script. It's about 10 seconds! before the pulse shows up!? The reason is the nested plot in the main for loop. As often as
possible: generate 1st simulation data, and display AFTER, not while calculating simulations.
______________________________________________________________________________________________________________________________
John Bofarull Guix jgb2012@sky.com attached: -- 22 / 26
POZAR chapter 01: example 01 24/12/2020 08:42:56.
function [str150_vars_file,num123,rload]=save_load_fields(A,str_field_name,n1,n2,field_type)
%
% FILE NAME: load_results_if_available.m
%
% DESCRIPTION: Support function for fdtd_4_1_3.m
%
%
%
% MATLAB script author: John Bofarull.
% jgb2012@sky.com jgb2014@live.co.uk
num123(1)=n1;
num123(2)=n2;
num123(3)=field_type;
rload=0 % 0: no results stored or script told to recalculate regardless of possibly available results.
% 1: results available, may reload and avoid recalculate.
Ldir=ls('*.mat'); % assume already in right directory: get list .mat files within same directory.
s=0 % s: amount .mat files with file name matching str150_var_file
% OS should have policy of unique file names in same folder active
k1=1
if size(Ldir,1)>0 % Ldir not empty
while s==0 && k1<=size(Ldir,1)
Ldir1=Ldir(k1,:);
if strcmp(str150_vars_file,Ldir1) % remove trailing heading possible blank characters in name.
s=1;
rload=1;
k1=k1+1;
else
s=0;
rload=0;
k1=k1+1;
end
end
end
if s==0 % Ldir empty = list doesn't contain str150_vars_file, results not available.
disp(['No previous ' str150_vars_file ' stored in folder, saving ' str_field_type ' field in .mat file.'])
save(str150_vars_file,A)
rload=1;
return
end
prompt='Results already stored. Do you want to recalculate? Y/N [Y]: '; % list contains str150_vars_file, results available.
str150_input=input(prompt,'s');
if isempty(str150_input) || str150_input=='y' || str150_input=='Y'
rload=1;
return % recalculating
end
if str150_input=='n' || str150_input=='N'
______________________________________________________________________________________________________________________________
John Bofarull Guix jgb2012@sky.com attached: -- 23 / 26
POZAR chapter 01: example 01 24/12/2020 08:42:56.
rload=0;
hw=whos;
Lvars={}
for k2=1:1:size(hw,1) % list with all .mat file names
if ~isequal(hw(k2).name,'str150_vars_file')
Lvars=[Lvars hw(k2).name];
end
end
pause(2)
disp('Stored results loaded.') % exit to avoid recalculating just loaded results
rload=0
num123(1)=n1;
num123(2)=n2;
num123(3)=field_type;
end
end
fdtd_solve.m
Chyh = zeros(nx,1);
Chyez = zeros(nx,1);
Chym = zeros(nx,1);
Hy = zeros(nx,1);
My = zeros(nx,1);
mu_r_y = ones (nx,1); % free space
sigma_m_y = zeros(nx,1); % free space
initialize_plotting_parameters.m
plot_fields.m
______________________________________________________________________________________________________________________________
John Bofarull Guix jgb2012@sky.com attached: -- 25 / 26
POZAR chapter 01: example 01 24/12/2020 08:42:56.
This exercise is part of the collection of exercises Microwave Engineering POZAR 4th ed solved with MATLAB available in this website:
https://jgb2012.wixsite.com/microwave-eng-matlab
______________________________________________________________________________________________________________________________
John Bofarull Guix jgb2012@sky.com attached: -- 26 / 26