0% found this document useful (0 votes)
24 views

Simulation of Plane Sinusoidal Wave Propagation Through Lossy Dielectric Material Using Finite Difference Time Domain (FDTD) Modeling in Python

The document describes simulation of plane electromagnetic wave propagation through lossy dielectric material using finite difference time domain modeling in Python. It includes 9 figures showing wave propagation concepts like attenuation, phase constant, and complex wave number. It also presents a 2D FDTD simulation code to model wave passing through a dielectric with conductivity.

Uploaded by

Pritam Singh
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
24 views

Simulation of Plane Sinusoidal Wave Propagation Through Lossy Dielectric Material Using Finite Difference Time Domain (FDTD) Modeling in Python

The document describes simulation of plane electromagnetic wave propagation through lossy dielectric material using finite difference time domain modeling in Python. It includes 9 figures showing wave propagation concepts like attenuation, phase constant, and complex wave number. It also presents a 2D FDTD simulation code to model wave passing through a dielectric with conductivity.

Uploaded by

Pritam Singh
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 8

Simulation of Plane Sinusoidal Wave Propagation through Lossy

Dielectric Material using Finite Difference Time Domain (FDTD)


Modeling in Python

October 20, 2023

[ ]: '''Figure 1 : 3D plot of a traveling wave'''


import matplotlib.pyplot as plt
import numpy as np

fig = plt.figure()
ax3d = fig.add_subplot(111, projection='3d')

x = np.linspace(-2*np.pi, 2*np.pi , 200)


y = np.linspace(-2*np.pi, 2*np.pi , 200)

E_0 = 2
phi,tau = np.meshgrid(x,y)

E = E_0*np.sin(phi-tau)
ax3d.set_xlabel(r'$\tau$')
ax3d.set_ylabel(r'$\phi$')
ax3d.set_zlabel('E')
surf = ax3d.plot_surface( phi , tau , E , cmap='jet')
ax3d.view_init(17,208)
fig.show()

[ ]: '''Figure 2 : Evolution of a time-dependent plane sinusoidal wave at a specific␣


↪position in space in 3D'''

import matplotlib.pyplot as plt


import numpy as np

fig = plt.figure()
ax3d = fig.add_subplot(111, projection='3d')

T=2
x = np.linspace(0, 5, 100)
y = np.linspace(0, 4, 100)

t,y = np.meshgrid(x,y)

1
E_0 = 2
omega=(2*np.pi)/T
tau = omega*t
E = E_0*np.sin(tau)
ax3d.set_xlabel('t')
ax3d.set_zlabel('E')
ax3d.axes.yaxis.set_ticklabels([])
surf = ax3d.plot_surface( t , y , E, rstride=1,␣
↪cstride=1,cmap='jet',edgecolor='None')

fig.show()

[ ]: '''Figure 3 : Evolution of a time-dependent plane sinusoidal wave at a specific␣


↪position in space in 2D'''

import matplotlib.pyplot as plt


import numpy as np

fig = plt.figure()

T = 2
t = np.linspace(0, 5, 100)

E_0 = 2
omega=(2*np.pi)/T
tau = omega*t
E = E_0*np.sin(tau)

fig.set_figheight(3)
plt.xlabel('t (s)')
plt.ylabel('E (V/m)')
plt.xlim(0,5)
plt.plot(t,E)
plt.text(4.2,-1.3,'x=0m')
plt.text(4.2,-1.7,'T=2s')
plt.grid()
plt.show()

[ ]: '''Figure 4 : Snapshot of plane sinusoidal wave at a specific time in 2D'''


import matplotlib.pyplot as plt
import numpy as np

fig = plt.figure()

lam = 2
x = np.linspace(0, 5, 100)

E_0 = 2

2
k=(2*np.pi)/lam
phi = k*x
E = E_0*np.sin(phi)

fig.set_figheight(3)
plt.xlabel('x (m)')
plt.ylabel('E (V/m)')
plt.xlim(0,5)
plt.plot(x,E)
plt.text(4.2,-1.3,'t=0s')
plt.text(4.2,-1.7,r'$\lambda$=2m')
plt.grid()
plt.show()

[ ]: '''Figure 5 : Graph showing difference in wavelength in a dielectric as␣


↪compared to free space'''

import numpy as np
import matplotlib.pyplot as plt
import matplotlib

n_air=1
n_glass=1.5

lambda_air=2.5
lambda_glass=lambda_air*(n_air/n_glass)

x = np.linspace(0, 10, 200)


k0=(2*np.pi)/lambda_air
k1=(2*np.pi)/lambda_glass
k=np.ones(len(x))*k0
k[100:200]=k1

E_0=2
E = E_0*np.sin(k*x)

fig=plt.figure()
ax = fig.add_subplot(111)
rect1=matplotlib.patches.Rectangle((5,-3),5,6,fc=(1,1,0,0.5))
rect2=matplotlib.patches.Rectangle((0,-3),5,6,fc=(0,0,1,0.05))
fig.set_figheight(3)
plt.xlim(0,10)
plt.ylim(-3,3)
plt.xlabel('x (m)')
plt.ylabel('E (V/m)')
plt.plot(x,E)
ax.add_patch(rect1)
ax.add_patch(rect2)

3
plt.text(2.8,-1.9,'Air')
plt.text(2.5,-2.3,r'$\lambda$=2.5m')
plt.text(6.6,-1.9,'Glass')
plt.text(6.4,-2.3,r'$\lambda$=1.67m')
plt.grid()
plt.show()

[ ]: '''Figure 6 : Physical representation of attenuation coefficient and phase␣


↪constant'''

import numpy as np
import matplotlib.pyplot as plt

alpha=0.27
beta=2
E0=6

x=np.linspace(0,16.5,100)
y=[]
E=[]
for i in x:
y.append(E0*np.exp(-alpha*i))
E.append(E0*np.exp(-alpha*i)*np.cos(beta*i))

plt.figure(figsize=(7,4))
ax = fig.add_subplot(111)
plt.xlim(-2,22)
plt.ylim(-8,8)

plt.plot((0, 0), (-7, 7),color='black',lw=1.5)


plt.plot((0, 17.6), (0, 0),color='black',lw=1.5)
plt.text(-1.4,-0.2,'E',fontsize=11)
plt.text(18,-0.2,'x',fontsize=11)

plt.plot(x,y,color='red',lw=1,label=r'$E_0 e^{-\alpha x}$ (attenuation)')


plt.plot(x,E,color='whitesmoke',lw=3)
plt.plot(x,E,color='green',lw=2)
plt.plot([1.5,1.5,1.5],[-4,-5,-6.3],'--',color='blue',lw=1,label=r'describing␣
↪$e^{-j\beta x}$ (oscillation factor)')

plt.plot([4.6,4.6,4.6],[-1.8,-4,-6.3],'--',color='blue',lw=1)
plt.plot([1.7,4.5],[-6,-6],color='blue',lw=1)
plt.arrow(1.9,-6,-0.1,0,width=0.01,head_width=0.1,color='blue')
plt.arrow(4.2,-6,0.1,0,width=0.01,head_width=0.1,color='blue')
plt.arrow(17.4, 0, 0.01, 0, width = 0.07,color='black')
plt.arrow(0, 7, 0, 0.01, width = 0.07,color='black')
plt.arrow(0, -7, 0, -0.01, width = 0.07,color='black')
plt.legend()
plt.text(2.8,-6.8,r'$\lambda$',color='blue')

4
plt.text(12,-4,'Equation of the wave',color='darkgreen')
plt.text(12.3,-5.2,'E(x)',color='darkgreen')
plt.text(13.6,-5.2,r' = $E_0$',color='black')
plt.text(15.5,-5.2,r'$e^{-\alpha x}$',color='red')
plt.text(17.3,-5.2,r'$e^{-j\beta x}$',color='blue')
plt.text(-1,5.8,r'$E_0$',color='red')
plt.axis('off')
plt.show()

[ ]: '''Figure 7 : Visualization of plane wave with purely real k'''


import matplotlib.pyplot as plt
import numpy as np

fig = plt.figure()
ax3d = fig.add_subplot(111, projection='3d')

T=3.5

x = np.linspace(0, 10, 100)


y = np.linspace(0, 4, 100)

t,y = np.meshgrid(x,y)

E_0 = 2
omega=(2*np.pi)/T
tau = omega*t
E = E_0*np.sin(tau)
surf = ax3d.plot_surface( t , y , E, rstride=1,␣
↪cstride=1,cmap='jet',edgecolor='None')

plt.axis('off')
fig.show()

[ ]: '''Figure 8 : Visualization of a plot having purely imaginary k'''


import matplotlib.pyplot as plt
import numpy as np

fig = plt.figure()
ax3d = fig.add_subplot(111, projection='3d')

x = np.linspace(0, 10, 100)


y = np.linspace(0, 4, 100)

t,y = np.meshgrid(x,y)

E_0 = 2
alpha=0.2
power=-alpha*t

5
E=E_0*np.exp(power)

surf = ax3d.plot_surface( t , y , E, rstride=1,␣


↪cstride=1,cmap='jet',edgecolor='None')

plt.axis('off')
fig.show()

[ ]: '''Figure 9 : Plot of a sinusoidal plane wave having complex wave vector'''


import matplotlib.pyplot as plt
import numpy as np

fig = plt.figure()
ax3d = fig.add_subplot(111, projection='3d')

x = np.linspace(0, 10, 100)


y = np.linspace(0, 4, 100)

t,y = np.meshgrid(x,y)

E_0 = 2
E=[]
alpha=0.05
beta=2.1
for i in y:
E.append([])
for j in x:
E[-1].append(E_0*np.exp(-alpha*j)*np.cos(beta*j))

E=np.array(E)

surf = ax3d.plot_surface( t , y , E, rstride=1,␣


↪cstride=1,cmap='jet',edgecolor='None')

plt.axis('off')
fig.show()

[ ]: '''2D simulation : plane EM wave passing through a lossy dielectric'''


#Importing required libraries
import numpy as np
import matplotlib.pyplot as plt
import matplotlib

#Defining constants
eps_0=8.854187817e-12
mu_0=1.25663706144e-6
c_0=1/np.sqrt(eps_0*mu_0)
imp_0=np.sqrt(mu_0/eps_0)

6
#Defining FDTD cells
j_max=500
i_max=1000
j_source=0
interface=200

#Defining E and H field arrays


Ez=np.zeros(j_max)
Hy=np.zeros(j_max)

#Defining various variable arrays for free space and the lossy medium
epsilon=np.ones(j_max)*eps_0
eps_r = 3.8
epsilon[interface:]=eps_r*eps_0
cond=np.zeros(j_max)
sigma = 0.04
cond[interface:]=sigma

#Defining space and time steps


lambda_min=0.1
delta_x=lambda_min/20
delta_t=delta_x/c_0

#Expression in E and H update equations


R=(cond*delta_t)/(2*epsilon)

#Defining source function


def pulse(t):
T=1.43e-9
omega=2*np.pi/T
return np.cos(omega*t*delta_t)

#FDTD loops
for i in range(i_max): #Time variable loop
for j in range(1,j_max): #Space variable loop for E
#Update equation for E
Ez[j] = ((1-R[j])/(1+R[j]))*Ez[j] + (Hy[j]-Hy[j-1])/((1+R[j])*eps_r)
#Updating E source
Ez[j_source] = Ez[j_source] + pulse(i+1)
for j in range(j_max-1): #Space variable loop for H
#Update equation for H
Hy[j] = Hy[j] + Ez[j+1]-Ez[j]
#Updating H source
Hy[j_source-1] = Hy[j_source-1] + pulse(i)/imp_0

#Plotting E after 10 time steps for video effect


if i%10==0:

7
fig=plt.figure(figsize=(8, 2.5))
ax = fig.add_subplot(111)
rect1=matplotlib.patches.Rectangle((-2,-25),interface,50,fc=(0,0,1,0.05))
rect2=matplotlib.patches.
↪Rectangle((interface,-25),502-interface,50,fc=(1,1,0,0.5))

ax.add_patch(rect1)
ax.add_patch(rect2)
plt.plot(Ez,color='orangered')
plt.xlim(-2,502)
plt.ylim(-25,25)
plt.xlabel('FDTD cells')
plt.ylabel(r'$E_z$')
plt.text(50, -18, r'$\epsilon_r$ = 1')
plt.text(50, -22, r'$\sigma$ = 0 S/m')
plt.text(350, -18, r'$\epsilon_r$ = ' + str(eps_r))
plt.text(350, -22, r'$\sigma$ = ' + str(sigma) + ' S/m')
plt.text(200, 19, 'T = ' + str(i))
plt.show()

You might also like