220 likes | 371 Views
EEE 431 Computational Methods in Electrodynamics. Lecture 10 By Dr. Rasime Uyguroglu Rasime.uyguroglu@emu.edu.tr. FINITE DIFFERENCE TIME DOMAIN METHOD (FDTD). FINITE DIFFERENCE TIME DOMAIN METHOD (FDTD). One dimensional free space formulation:
E N D
EEE 431Computational Methods in Electrodynamics Lecture 10 By Dr. Rasime Uyguroglu Rasime.uyguroglu@emu.edu.tr
FINITE DIFFERENCE TIME DOMAIN METHOD (FDTD) • One dimensional free space formulation: • Assume a plane wave with the electric filed having Ex, magnetic field having Hy components and traveling in the z direction.
FINITE DIFFERENCE TIME DOMAIN METHOD (FDTD) • Maxwell’s Equations become:
FINITE DIFFERENCE TIME DOMAIN METHOD (FDTD) • Taking central difference approximation for both temporal and spectral derivatives:
FINITE DIFFERENCE TIME DOMAIN METHOD (FDTD) • /* Bare-bones 1D FDTD simulation . */ • #include <stdio.h> • #include <math.h> • #define KE 200 • int main() • { • double ez[KE]={0.}, hy[KE]={0.}; • float dz=.1,c=3e8, eps0=8.85e-12,mu0=1.25663e-6; • float dt=dz/(2*c); • float dtedz=dt/(eps0*dz), dtmdz=dt/(mu0*dz); • int n, nTime=1000, k; • FILE *fp,*fp1; • fp1=fopen("E.dat","w");
FINITE DIFFERENCE TIME DOMAIN METHOD (FDTD) • /* do time stepping */ • for (n=0; n<nTime; n++) { • // printf( " %6.2f\n",nTime); • /* update magnetic field */ • for (k=0; k<KE-1; k++) • hy[k] = hy[k] + dtmdz*(ez[k+1] - ez[k]); • /* update electric field */ • for (k=1; k<KE; k++) • ez[k] = ez[k] + dtedz*(hy[k] - hy[k-1]); • /* hardwire a source node */ • ez[100] = exp(-(n-30.)*(n-30)/100);
FINITE DIFFERENCE TIME DOMAIN METHOD (FDTD) • fprintf(fp1,"%g\n",ez[50]); • if(n==150){ • fp=fopen("Ez.dat","w"); • for (k=1;k<=KE;k++) • {fprintf(fp,"%6.2f\n",ez[k]);} • fclose(fp); • /* Write Hy in a file "Hy"*/ • fp=fopen("Hy.dat","w"); • for(k=1;k<=KE;k++) • {fprintf(fp," %6.2f\n",hy[k]);} • fclose(fp);} • } • fclose(fp1); • return 0; • }
FINITE DIFFERENCE TIME DOMAIN METHOD (FDTD) • Source at k=0, field at k=50 w.r.t. the time, 250 time steps.
FINITE DIFFERENCE TIME DOMAIN METHOD (FDTD) • Source at k=100,Ex at k=100
FINITE DIFFERENCE TIME DOMAIN METHOD (FDTD) • Ez w.r.t. space steps
FINITE DIFFERENCE TIME DOMAIN METHOD (FDTD) • Ez w.r.t. the time steps.
FINITE DIFFERENCE TIME DOMAIN METHOD (FDTD) • Ez w.r.t. the time steps
FINITE DIFFERENCE TIME DOMAIN METHOD (FDTD) with ABC’s • Using the boundary condition discussed in Lecture 9 : • Store a value of Ex(1) for two time steps and then put it in Ex(0).
FINITE DIFFERENCE TIME DOMAIN METHOD (FDTD) with ABC’s • A.B.C.in C computer code assume that the domain ends at k=KE:
FINITE DIFFERENCE TIME DOMAIN METHOD (FDTD) with ABC’s • Ez w.r.t. the time steps
FINITE DIFFERENCE TIME DOMAIN METHOD (FDTD) with ABC’s • /* Bare-bones 1D FDTD simulation .with abc */ • #include <stdio.h> • #include <math.h> • #define KE 200 • int main() • { • double ez[KE]={0.}, hy[KE]={0.}; • float ez_low_m1=0,ez_low_m2=0,ez_high_m1=0,ez_high_m2=0; • float dz=.1,c=3e8; • float eps0=8.85e-12,mu0=1.25663e-6; • float dt=dz/(2*c); • float dtedz=dt/(eps0*dz); • float dtmdz=dt/(mu0*dz); • int n, nTime=1000, k; • FILE *fp,*fp1; • fp1=fopen("E.dat","w");
FINITE DIFFERENCE TIME DOMAIN METHOD (FDTD) with ABC’s • /* do time stepping */ • for (n=0; n<nTime; n++) { • // printf( " %6.2f\n",nTime); • /* update magnetic field */ • for (k=0; k<KE-1; k++) • hy[k] = hy[k] + dtmdz*(ez[k+1] - ez[k]); • /* update electric field */ • for (k=1; k<KE; k++) • ez[k] = ez[k] + dtedz*(hy[k] - hy[k-1]); • /*Absorbing Boundary Conditions*/ • ez[0] = ez_low_m2; • ez_low_m2 = ez_low_m1; • ez_low_m1 = ez[1]; • ez[KE-1] = ez_high_m2; • ez_high_m2 = ez_high_m1; • ez_high_m1 = ez[KE-2]; • /* hardwire a source node */
FINITE DIFFERENCE TIME DOMAIN METHOD (FDTD) with ABC’s • ez[100] = exp(-(n-30.)*(n-30)/100); • fprintf(fp1,"%g\n",ez[50]); • if(n==150){ • fp=fopen("Ez.dat","w"); • for (k=1;k<=KE;k++) • {fprintf(fp,"%6.2f\n",ez[k]);} • fclose(fp); • /* Write Hy in a file "Hy"*/ • fp=fopen("Hy.dat","w"); • for(k=1;k<=KE;k++) • {fprintf(fp," %6.2f\n",hy[k]);} • fclose(fp);} • } • fclose(fp1); • return 0; • }
FINITE DIFFERENCE TIME DOMAIN METHOD (FDTD) with ABC’s • Ez with ABC and without ABC