/* 1D FDTD simulation with a simple absorbing boundary * condition, a TFSF boundary between hy[49] and ez[50], and * a dielectric material starting at ez[100] */ #include #include #define SIZE 200 int main() { double ez[SIZE], hy[SIZE - 1], epsR[SIZE], imp0 = 377.0; int qTime, maxTime = 450, mm; char basename[80] = "sim", filename[100]; int frame = 0; FILE *snapshot; /* initialize electric field */ for (mm = 0; mm < SIZE; mm++) ez[mm] = 0.0; /* initialize magnetic field */ for (mm = 0; mm < SIZE - 1; mm++) hy[mm] = 0.0; /* set relative permittivity */ for (mm = 0; mm < SIZE; mm++) if (mm < 100) epsR[mm] = 1.0; else epsR[mm] = 9.0; /* do time stepping */ for (qTime = 0; qTime < maxTime; qTime++) { /* update magnetic field */ for (mm = 0; mm