Beruflich Dokumente
Kultur Dokumente
CAPITULO 1
1)Programa en C++
/* FD1D_1.1C. 1D FDTD simulation in free espace */
#include<iostream>
#include<conio.h>
#include<iomanip>
#include<math.h>
#include<stdlib.h>
#include<stdio.h>
#define KE 200 /* KE is the number of cells to be used*/
void main ()
{
float ex [KE], hy [KE];
int n,k,kc,ke,NSTEPS;
float T;
float to, spread, pulse;
FILE *fp, *fopen (const char[3],const char[3]);
/* initialize*/
for ( k=1; k<KE; k++)
{
ex[k] =0;
hy [k] =0; }
hy [k]=hy[k]+ .5*(ex[k]-ex[k+1]);}
}
/* End of the Main FDTD loop */
Programa en Matlab
c=1:200;
KE=200;
ex(1,200)=0;
hy(1,200)=0;
ex_low_m1=0;
ex_low_m2=0;
ex_high_m1=0;
ex_high_m2=0;
y=2;
%/* Initializate */
T=T+1;
%/* Main FDTD loop*/
% /* Calculate of Ex field*/
for(k=2:KE)
ex(k)=ex(k)+0.5.*(hy(k-1)-hy(k));
end
%/* put a Gaussian Pulse in the midle */
pulse=exp((-0.5)*((t0-T)/spread)^y);
ex(kc)=ex(kc)+pulse;
Integrantes:
Nelly Catherine Barbosa Caldern 2080621
David Andrs Sarmiento Nova 2080281
Ivn Daro Corredor Garca 2081537
ex(KE)=ex_high_m2;
ex_high_m2=ex_high_m1;
ex_high_m1=ex(KE-1);
%/* Calculate of Hy field*/
for(k=1:KE-1)
hy(k)=hy(k)+0.5*(ex(k)-ex(k+1));
end
end
%/* End of the main FDTD loop*/
%/* At the end of the calculation, print out the Ex and Hy fields*/
end
figure
plot (c,hy)
grid on;
xlabel('T');
ylabel('Hy');
title('Campo magntico vs. Numero de pasos');
figure
plot (c,ex)
grid on;
xlabel('T');
ylabel('Ex');
title('Campo elctrico vs. Numero de pasos');
Graficas
Integrantes:
Nelly Catherine Barbosa Caldern 2080621
David Andrs Sarmiento Nova 2080281
Ivn Daro Corredor Garca 2081537
hy Vs. T
1
0.8
0.6
0.4
0.2
hy
-0.2
-0.4
-0.6
-0.8
-1
0 20 40 60 80 100 120 140 160 180 200
T
ex Vs. T
1
0.9
0.8
0.7
0.6
ex
0.5
0.4
0.3
0.2
0.1
0
0 20 40 60 80 100 120 140 160 180 200
T
hy Vs. T
0.4
0.2
-0.2
hy
-0.4
-0.6
-0.8
-1
0 20 40 60 80 100 120 140 160 180 200
T
ex Vs. T
1
0.8
0.6
0.4
0.2
ex
-0.2
-0.4
-0.6
-0.8
-1
0 20 40 60 80 100 120 140 160 180 200
T
Integrantes:
Nelly Catherine Barbosa Caldern 2080621
David Andrs Sarmiento Nova 2080281
Ivn Daro Corredor Garca 2081537
Diagramas de flujo
DFD
2) Programa en C++
Integrantes:
Nelly Catherine Barbosa Caldern 2080621
David Andrs Sarmiento Nova 2080281
Ivn Daro Corredor Garca 2081537
#include<iostream>
#include<conio.h>
#include<iomanip>
#include<math.h>
#include<stdlib.h>
#include<stdio.h>
#define KE 200 /* KE is the number of cells to be used*/
void main ()
{
float ex [KE], hy [KE];
int n,k,kc,ke,NSTEPS;
float T;
float to, spread, pulse;
float ex_low_m1,ex_low_m2,ex_high_m1,ex_high_m2;
FILE *fp, *fopen (const char[3],const char[3]);
/* initialize*/
for ( k=1; k<KE; k++)
{
ex[k] =0;
hy [k] =0; }
ex[0] = ex_low_m2;
ex_low_m2 = ex_low_m1;
ex_low_m1 = ex[1];
Integrantes:
Nelly Catherine Barbosa Caldern 2080621
David Andrs Sarmiento Nova 2080281
Ivn Daro Corredor Garca 2081537
Programa en Matlab
c=1:200;
KE=200;
ex(1,200)=0;
hy(1,200)=0;
cb(1,200)=0;
ex_low_m1=0;
ex_low_m2=0;
ex_high_m1=0;
ex_high_m2=0;
y=2;
%/* Initializate */
while(NSTEPS>0)
T=T+1;
%/* Main FDTD loop*/
% /* Calculate of Ex field*/
for(k=2:KE)
ex(k)=ex(k)+0.5.*(hy(k-1)-hy(k));
end
%/* put a Gaussian Pulse in the midle */
pulse=exp((-0.5)*((t0-T)/spread)^y);
ex(kc)=ex(kc)+pulse;
ex(KE)=ex_high_m2;
ex_high_m2=ex_high_m1;
ex_high_m1=ex(KE-1);
%/* Calculate of Hy field*/
for(k=1:KE-1)
hy(k)=hy(k)+0.5*(ex(k)-ex(k+1));
end
end
%/* End of the main FDTD loop*/
%/* At the end of the calculation, print out the Ex and Hy fields*/
end
figure
plot (c,hy)
grid on;
xlabel('T');
ylabel('Hy');
title('Campo magntico vs. Numero de pasos');
figure
plot (c,ex)
grid on;
xlabel('T');
ylabel('Ex');
title('Campo elctrico vs. Numero de pasos');
Integrantes:
Nelly Catherine Barbosa Caldern 2080621
David Andrs Sarmiento Nova 2080281
Ivn Daro Corredor Garca 2081537
GRAFICAS
(NSTEPS) nmero de pasos= 250
Campo elctrico vs. Numero de pasos
0.8
0.7
0.6
0.5
0.4
Ex
0.3
0.2
0.1
-0.1
0 20 40 60 80 100 120 140 160 180 200
T
0.6
0.4
0.2
Hy
-0.2
-0.4
-0.6
0 20 40 60 80 100 120 140 160 180 200
T
Integrantes:
Nelly Catherine Barbosa Caldern 2080621
David Andrs Sarmiento Nova 2080281
Ivn Daro Corredor Garca 2081537
NSTEPS = 100
0.8
0.6
Ex
0.4
0.2
-0.2
0 20 40 60 80 100 120 140 160 180 200
T
0.5
Hy
-0.5
-1
-1.5
0 20 40 60 80 100 120 140 160 180 200
T
Integrantes:
Nelly Catherine Barbosa Caldern 2080621
David Andrs Sarmiento Nova 2080281
Ivn Daro Corredor Garca 2081537
NSTEPS = 225
0.8
0.6
Ex
0.4
0.2
-0.2
0 20 40 60 80 100 120 140 160 180 200
T
0.5
Hy
-0.5
-1
-1.5
0 20 40 60 80 100 120 140 160 180 200
T
Diagrama de flujo
DFD 2
Integrantes:
Nelly Catherine Barbosa Caldern 2080621
David Andrs Sarmiento Nova 2080281
Ivn Daro Corredor Garca 2081537
1 2
Integrantes:
Nelly Catherine Barbosa Caldern 2080621
David Andrs Sarmiento Nova 2080281
Ivn Daro Corredor Garca 2081537
3) Programa en c++
PROGRAMA 3
/* FD1D_1.3.c. */
/* Simulation of a pulse hitting a dielectric medium */
#include<iostream>
#include<conio.h>
#include<iomanip>
#include<math.h>
#include<stdlib.h>
#include<stdio.h>
#define KE 200 /* KE is the number of cells to be used*/
void main ()
{
float ex [KE], hy [KE];
int n,k,kc,ke,nsteps,kstart;
float ddx,dt,T,epsz,epsilon,sigma,eaf;
float ex_low_m1,ex_low_m2,ex_high_m1,ex_high_m2;
float cb[KE];
float to, spread, pulse;
FILE *fp, *fopen (const char[3],const char[3]);
/* initialize*/
Integrantes:
Nelly Catherine Barbosa Caldern 2080621
David Andrs Sarmiento Nova 2080281
Ivn Daro Corredor Garca 2081537
while (nsteps>0)
{
printf ("nsteps- - - >");
scanf ("%d", &nsteps);
printf ("%d \n", nsteps);
ex[0] = ex_low_m2;
ex_low_m2 = ex_low_m1;
ex_low_m1 = ex[1];
{
hy[k]=hy[k]+ .5*(ex[k]- ex[k+1]);}}
/* End of the main FDTD loop */
/* At the end of the calculation, print out the Ex and Hy fields */
for (k=1; k<= KE; k++)
{ printf ("%3d %6.2f %6.2f\n",k,ex[k],hy[k]); }
Programa (matlab)
c=1:200;
KE=200;
ex(1,200)=0;
hy(1,200)=0;
cb(1,200)=0;
y=2;
ex_low_m1=0;
ex_low_m2=0;
ex_high_m1=0;
ex_high_m2=0;
for k=2:KE
cb(k)=0.5;
end
for(k=kstart:KE)
cb(k)=((0.5)./Epsilon);
Integrantes:
Nelly Catherine Barbosa Caldern 2080621
David Andrs Sarmiento Nova 2080281
Ivn Daro Corredor Garca 2081537
end
while(NSTEPS>0)
for(n=1:NSTEPS)
T=T+1;
%Calculate of Ex field
for k=2:KE,
ex(k)= ex(k)+ (0.5).*(hy(k-1)-hy(k));
end
pulse=exp((-.5)*((t0-T)/spread)^y);
ex(6)=ex(6)+pulse;
ex(1)=ex_low_m2;
ex_low_m2=ex_low_m1;
ex_low_m1=ex(2);
ex(KE)= ex_high_m2;
ex_low_m2 = ex_low_m1;
ex_low_m1 = ex(KE-1);
% Calculate of Hy field*/
for k=1:KE-1,
hy(k)= hy(k)+ (0.5).*(ex(k)-ex(k+1));
end
end
end
figure
plot(c,hy)
grid on;
xlabel('T');
ylabel('Hy');
title('Campo magntico vs. Numero de pasos');
figure
plot (c,ex)
grid on;
xlabel('T');
ylabel('Ex');
title('Campo elctrico vs. Numero de pasos');
GRAFICAS
K DIELECTRICA = 4
EPSILON = 4
NSTEPS = 100
0.8
0.6
Ex
0.4
0.2
-0.2
0 20 40 60 80 100 120 140 160 180 200
T
Integrantes:
Nelly Catherine Barbosa Caldern 2080621
David Andrs Sarmiento Nova 2080281
Ivn Daro Corredor Garca 2081537
0.8
0.6
Hy
0.4
0.2
-0.2
0 20 40 60 80 100 120 140 160 180 200
T
K DIELECTRICA = 4
EPSILON = 4
NSTEPS = 220
0.8
0.6
Ex
0.4
0.2
-0.2
0 20 40 60 80 100 120 140 160 180 200
T
Integrantes:
Nelly Catherine Barbosa Caldern 2080621
David Andrs Sarmiento Nova 2080281
Ivn Daro Corredor Garca 2081537
0.8
0.6
Hy
0.4
0.2
-0.2
0 20 40 60 80 100 120 140 160 180 200
T
K DIELECTRICA = 4
EPSILON = 4
NSTEPS = 320
0.8
0.6
Ex
0.4
0.2
-0.2
0 20 40 60 80 100 120 140 160 180 200
T
Integrantes:
Nelly Catherine Barbosa Caldern 2080621
David Andrs Sarmiento Nova 2080281
Ivn Daro Corredor Garca 2081537
0.8
0.6
Hy
0.4
0.2
-0.2
0 20 40 60 80 100 120 140 160 180 200
T
Diagramas de flujo
DFD
Integrantes:
Nelly Catherine Barbosa Caldern 2080621
David Andrs Sarmiento Nova 2080281
Ivn Daro Corredor Garca 2081537
1 2
Integrantes:
Nelly Catherine Barbosa Caldern 2080621
David Andrs Sarmiento Nova 2080281
Ivn Daro Corredor Garca 2081537
4) Programa en c++
/* FD1D_1.4.c. */
/* Simulation of a sinusoidal wave hitting a dielectric mdium */
#include<iostream>
#include<conio.h>
#include<iomanip>
#include<math.h>
#include<stdlib.h>
#include<stdio.h>
#define KE 200 /* KE is the number of cells to be used*/
void main ()
{
int n,k,kc,ke,nsteps,kstart;
float ddx,dt,T,epsz,epsilon,sigma,eaf;
float freq_in;
float ex [KE], hy [KE];
float cb[KE];
Integrantes:
Nelly Catherine Barbosa Caldern 2080621
David Andrs Sarmiento Nova 2080281
Ivn Daro Corredor Garca 2081537
T=0;
nsteps =1;
while (nsteps>0) {
printf ("nsteps - -> ");
scanf ("%d", &nsteps);
printf ("%d \n", nsteps);
pulse = sin(2*3.14159*freq_in*dt*T);
ex[5]=ex[5]+pulse;
printf ("%5.1f %6.2f %6.2f\n", T,pulse, ex[5]);
ex[0] = ex_low_m2;
ex_low_m2 = ex_low_m1;
ex_low_m1 = ex[1];
Programa en Matlab
c=1:200;
KE=200;
ex(1,200)=0;
hy(1,200)=0;
cb(1,200)=0;
ex_low_m1=0;
ex_low_m2=0;
ex_high_m1=0;
ex_high_m2=0;
y=2;
ddx=0.01;
dt=ddx./(2.*3e8);
for(k=2:KE)
cb(k)=0.5;
end
for(k=kstart:KE)
cb(k)=0.5/epsilon;
end
kc=KE/2;% Center of the problem space*/
t0=40; % Center of the incident pulse */
spread=12; % Width of the incident pulse */
T=0;
NSTEPS=1;
while(NSTEPS>0)
for(n=1:NSTEPS)
T=T+1;
Integrantes:
Nelly Catherine Barbosa Caldern 2080621
David Andrs Sarmiento Nova 2080281
Ivn Daro Corredor Garca 2081537
for(k=2:KE)
ex(k)=ex(k)+cb(k)*(hy(k-1)-hy(k));
end
pulse=sin(2*pi*freq_in*dt*T);
ex(6)=ex(6)+pulse;
ex(1)=ex_low_m2;
ex_low_m2=ex_low_m1;
ex_low_m1=ex(2);
ex(KE)=ex_high_m2;
ex_high_m2=ex_high_m1;
ex_high_m1=ex(KE-1);
%% /* Calculate of Hy field*/
for(k=2:KE-1)
hy(k)=hy(k)+0.5*(ex(k)-ex(k+1));
end
end
end
GRAFICAS
NSTEPS=425
Epsilon=4
Kdielectrica = 4
Frecuencia (MHz)=700
Integrantes:
Nelly Catherine Barbosa Caldern 2080621
David Andrs Sarmiento Nova 2080281
Ivn Daro Corredor Garca 2081537
0
Ex
-1
-2
-3
-4
0 20 40 60 80 100 120 140 160 180 200
T
0
T
-1
-2
-3
-4
-5
0 20 40 60 80 100 120 140 160 180 200
Hy
5) Programa c++
#include<conio.h>
#include<iomanip>
#include<math.h>
#include<stdlib.h>
#include<stdio.h>
#define KE 200 /* KE is the number of cells to be used*/
using namespace System;
using namespace std;
void main ()
{
float ex [KE], hy [KE];
int n,k,kc,ke,nsteps,kstart;
float ddx,dt,T,epsz,epsilon,sigma,eaf;
float to, spread, pulse;
float ca[KE], cb[KE];
float ex_low_m1,ex_low_m2,ex_high_m1,ex_high_m2;
epsz=8.85419e-12;
eaf=dt*sigma/(2*epsz*epsilon);
printf (" %6.4f \n", eaf);
for (k=kstart; k<=KE; k++)
{
ca[k]=(1.-eaf)/(1+eaf);
cb[k]=(.5/epsilon*(1+eaf));
}
while (NSTEPS>0)
{
printf ("NSTEPS -->"); /*NSTEPS is the number of times the*/
scanf ("%d", &NSTEPS); /* main loop has executed */
printf ("%d \n", NSTEPS);
n=0;
ex[0] = ex_low_m2;
ex_low_m2 = ex_low_m1;
ex_low_m1 = ex[1];
Programa en MATLAB
c=1:200;
KE = 200;
ex(1,200)=0;
hy(1,200)=0;
cb(1,200)=1;
ca(1,200)=1;
ex_low_m1 = 0;
ex_low_m2 = 0;
ex_high_m1 = 0;
ex_high_m2 = 0;
epsz = 8.85419e-12;
ca=1;
ddx = 0.01;
dt = ddx./(2.*3e8);
eaf = dt.*sigma/(2.*epsz.*epsilon);
for (k=kstart:KE)
cb(k) = 0.5./epsilon;
ca(k) = (1-eaf)./(1+eaf);
end
ex(1) = ex_low_m2;
ex_low_m2 = ex_low_m1;
ex_low_m1 = ex(2);
ex(KE) = ex_high_m2;
ex_low_m2 = ex_low_m1;
ex_low_m1 = ex(KE-1);
%Calculate of Hy field
for k=1:1:(KE-1);
hy(k) = hy(k) + 0.5.*(ex(k)-ex(k+1));
end
end
end
figure();
plot(c,ex);
grid on;
xlabel('T');
ylabel('Campo electrico');
title('Campo electrico vs. T');
figure
plot(c,hy);
Integrantes:
Nelly Catherine Barbosa Caldern 2080621
David Andrs Sarmiento Nova 2080281
Ivn Daro Corredor Garca 2081537
grid on;
xlabel('T');
ylabel('Campo magnetico');
title('Campo magnetico vs.T');
GRAFICAS
NSTEPS=500
Epsilon=4
Kdielectrica = 4
Conductividad = 0.04
Frecuencia (MHz)=700
1.5
0.5
Campo electrico
-0.5
-1
-1.5
-2
-2.5
0 20 40 60 80 100 120 140 160 180 200
T
Integrantes:
Nelly Catherine Barbosa Caldern 2080621
David Andrs Sarmiento Nova 2080281
Ivn Daro Corredor Garca 2081537
4
Campo magnetico
-2
-4
-6
0 20 40 60 80 100 120 140 160 180 200
T