# How to generate two PEC boundary conditions in 1D FDTD?

2 views (last 30 days)
royed on 20 Sep 2020
Commented: RANIT ROY on 3 Mar 2021
I want to implement a boundary condition in a 1D FDTD for Maxwells Equations in which the field is Purely Reflected in Both the boundaries for the electric field.
In short :
How to generate two PEC walls in 1D FDTD ? What is the boundary condition?

Shouri Chatterjee on 3 Mar 2021
Edited: Shouri Chatterjee on 3 Mar 2021
I am using a template from Prof John B Schneider's book on understanding FDTD, with a minor modification. Increase the size of the E-field array by 1. The end edge of the E-field is now set to 0. Don't recompute this. Compute the H-field all the way to the end, based on this outer E-field.
Reference:
• Understanding the Finite-Difference Time-Domain Method, John B. Schneider, www.eecs.wsu.edu/~schneidj/ufdtd, 2010.
The below code is a modification of Program 3.1. Program 3.1 had a PEC at x=0, a PMC at x=200. The code below has a PEC at x=0, a PEC at x=201.
#include <stdio.h>
#include <math.h>
#define SIZE 200
int main()
{
double ez[SIZE+1] = {0.}, hy[SIZE] = {0.}, imp0=377.0;
int qTime, maxTime = 1000, mm;
char basename = "sim", filename;
int frame=0;
FILE* snapshot;
/* do time stepping */
for (qTime = 0; qTime < maxTime; qTime++) {
/* Magnetic field */
for(mm=0; mm < SIZE; mm++)
hy[mm] = hy[mm] + (ez[mm+1]-ez[mm])/imp0;
/* Electric field */
for(mm=1; mm < SIZE; mm++)
ez[mm] = ez[mm] + (hy[mm]-hy[mm-1]) * imp0;
/* Additive current source at node 50 */
ez += exp(-(qTime -30.) * (qTime - 30.) / 100.);
// Explicit forcing function at node 0
// ez = exp(-(qTime - 30.) * (qTime - 30.) / 100.);
if (qTime % 10 == 0) {
sprintf(filename, "%s.%d", basename, frame++);
snapshot = fopen(filename, "w");
for(mm=0; mm<SIZE+1; mm++)
fprintf(snapshot, "%g\n", ez[mm]);
fclose(snapshot);
}
}
return 0;
}
RANIT ROY on 3 Mar 2021
That seems interesting! So we are forcing a secondary source at the Magnetic Field Reflector! Thank You for suggesting this, I shall try this out.