-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathfdtd1d.py
33 lines (25 loc) · 853 Bytes
/
fdtd1d.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import math
imp0 = 377.0 # property of free space (vacuum)
SIZE = 400 # dimension of space to model
sensorLocation = 250 # location of output sensor
maxTime = 400 # simulation time
sourcePeakTime = 30 # peak of the Gaussian source
sourceSdv = 7 # standard deviation of the Gaussian source
sourceSigma = 2 * sourceSdv**2
ez = [0.0] * SIZE
hy = [0.0] * SIZE
# do time stepping
for qTime in range(maxTime):
# update magnetic field
for mm in range(SIZE-1):
hy[mm] = hy[mm] + (ez[mm + 1] - ez[mm]) / imp0
# update electric field
for mm in range(SIZE):
ez[mm] = ez[mm] + (hy[mm] - hy[mm - 1]) * imp0
# hardwire a source node */
if qTime < sourceSigma:
ez[0] = math.exp(-(qTime - sourcePeakTime)**2 / sourceSigma)
else:
ez[0] = 0.0
print(ez[sensorLocation])
#done with time stepping loop