% initialize the matlab workspace
 clear all; close all; clc;

% maximum number of time steps to run FDTD simulation
number_of_time_steps = 50; 

% A factor that determines duration of a time step
% wrt CFL limit
courant_factor = 0.9;

% A factor determining the accuracy limit of FDTD results
number_of_cells_per_wavelength = 20;    

% Dimensions of a unit cell in x and y directions (meters)
dx = 0.1e-2;    
dy = 0.1e-2;   

disp('initializing FDTD parameters and arrays');

% constant parameters
eps_0 = 8.854187817e-12; % permittivity of free space               
mu_0  = 4*pi*1e-7; % permeability of free space                    
c = 1/sqrt(mu_0*eps_0); % speed of light in free space

% Duration of a time step in seconds
dt = 1/(c*sqrt((1/dx^2)+(1/dy^2)));
dt = courant_factor*dt;

% time array
time = ([1:number_of_time_steps]-0.5)*dt;

% define source waveform types and parameters
%waveforms.gaussian(1).number_of_cells_per_wavelength = 0; 
%waveforms.gaussian(2).number_of_cells_per_wavelength = 15; 
waveforms.edwingray(1).frequency = 1e7;

disp('initializing source waveforms');

% initialize sinpulse waveforms
if isfield(waveforms,'edwingray')
    for ind=1:size(waveforms.edwingray,2)
        waveforms.edwingray(ind).waveform = sin(2 * pi * waveforms.edwingray(ind).frequency * time);
    end
    for step=30:50
        waveforms.edwingray(ind).waveform(step) = 0;
    end
end

waveforms.edwingray(1).waveform
