/* 1D FDTD simulation with a simple absorbing boundary condition * and a TFSF boundary between hy[49] and ez[50]. */ #include #include #define SIZE 200 int main() { double ez[SIZE] = {0.}, hy[SIZE] = {0.}, imp0 = 377.0; int qTime, maxTime = 451, mm; char basename[80]="sim", filename[100]; int frame = 0; FILE *snapshot; /* do time stepping */ for (qTime = 0; qTime < maxTime; qTime++) { /* simple ABC for hy[size - 1] */ hy[SIZE - 1] = hy[SIZE - 2]; /* update magnetic field */ for (mm = 0; mm < SIZE - 1; mm++) hy[mm] = hy[mm] + (ez[mm + 1] - ez[mm]) / imp0; /* correction for Hy adjacent to TFSF boundary */ hy[49] -= exp(-(qTime - 30.) * (qTime - 30.) / 100.) / imp0; /* simple ABC for ez[0] */ ez[0] = ez[1]; /* update electric field */ for (mm = 1; mm