-
Notifications
You must be signed in to change notification settings - Fork 1
/
excitation.py
39 lines (32 loc) · 1.21 KB
/
excitation.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
34
35
36
import numpy as np
from math import cos, sin
from cmath import exp
class Planewave():
""" Class that handles a simple planewave
"""
def __init__(self, numPlws, startPhi, endPhi):
""" Init the object planewave
"""
self.numPlws = numPlws
self.startPhi = np.deg2rad(startPhi)
self.endPhi = np.deg2rad(endPhi)
self.phiInc = np.linspace(startPhi, endPhi, numPlws)
#--------------------------------------------
def computeEinc(self, kb, msh):
""" Compute the incident electric field at each point of the mesh
"""
if self.numPlws <=0:
raise RuntimeError("No. of excitations (planewave) must be > 0")
numCells = len(msh)
Einc = np.zeros((numCells,self.numPlws), dtype=np.complex)
# start looping for each cell and plw
for i in range(self.numPlws):
cosPhi = np.cos(self.phiInc[i])
sinPhi = np.sin(self.phiInc[i])
for j in range(numCells):
xc = msh.cells[j].x * cosPhi
yc = msh.cells[j].y * sinPhi
e0 = exp(-1j*kb*(xc + yc))
Einc[j,i] =e0
return Einc
#--------------------------------------------