Skip to content

Commit

Permalink
Black'd
Browse files Browse the repository at this point in the history
  • Loading branch information
lbolla committed Mar 2, 2024
1 parent d526f67 commit e564dbf
Show file tree
Hide file tree
Showing 8 changed files with 1 addition and 92 deletions.
8 changes: 0 additions & 8 deletions EMpy/RCWA.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,6 @@ def dispersion_relation_extraordinary(kx, ky, k, nO, nE, c):
kz = S.empty_like(kx)

for ii in range(0, kx.size):

alpha = nE**2 - nO**2
beta = kx[ii] / k * c[0] + ky[ii] / k * c[1]

Expand Down Expand Up @@ -234,7 +233,6 @@ def solve(self, wls):
dlt = (i == 0).astype(int)

for iwl, wl in enumerate(self.wls):

# free space wavevector
k = 2 * pi / wl

Expand Down Expand Up @@ -287,7 +285,6 @@ def solve(self, wls):
MTp1.fill(0.0)
MTp2.fill(0.0)
for nlayer in range(nlayers - 2, 0, -1): # internal layers

layer = multilayer[nlayer]
d = layer.thickness

Expand Down Expand Up @@ -315,13 +312,11 @@ def solve(self, wls):
A = S.diag((kx / k) ** 2) - E

if S.absolute(K[2] / k) > 1e-10:

raise ValueError(
"First Order Helmholtz Operator not implemented, yet!"
)

elif ky == 0 or S.allclose(S.diag(Ky / ky * k), 1):

# lalanne
# H_U_reduced = S.dot(Ky, Ky) + A
H_U_reduced = (ky / k) ** 2 * I + A
Expand Down Expand Up @@ -395,7 +390,6 @@ def solve(self, wls):
)

else:

ValueError("Second Order Helmholtz Operator not implemented, yet!")

# M = S.asarray(S.bmat([-MR, MT]))
Expand Down Expand Up @@ -516,7 +510,6 @@ def solve(self, wls):
dlt = (i == 0).astype(int)

for iwl, wl in enumerate(self.wls):

nO1 = nE1 = multilayer[0].mat.n(wl).item()
nO3 = nE3 = multilayer[-1].mat.n(wl).item()

Expand Down Expand Up @@ -653,7 +646,6 @@ def solve(self, wls):
M.fill(0.0)

for nlayer in range(nlayers - 2, 0, -1): # internal layers

layer = multilayer[nlayer]
thickness = layer.thickness

Expand Down
1 change: 0 additions & 1 deletion EMpy/devices.py
Original file line number Diff line number Diff line change
Expand Up @@ -1297,7 +1297,6 @@ class SWG(Device):
pf400_225 = [1.255208385485759e-007, -1.784557912270417e-003, 4.737972109281652e000]

def __init__(self, w, h, T):

self.w = w
self.h = h # not used!
self.T = T
Expand Down
1 change: 0 additions & 1 deletion EMpy/materials.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,6 @@ class RefractiveIndex:
def __init__(
self, n0_const=None, n0_poly=None, n0_smcoeffs=None, n0_known=None, n0_func=None
):

if n0_const is not None:
self.get_rix = partial(self.__from_const, n0_const)

Expand Down
16 changes: 1 addition & 15 deletions EMpy/modesolvers/FD.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,6 @@ def _get_eps(self, xc, yc):
return eps

def build_matrix(self):

from scipy.sparse import coo_matrix

wl = self.wl
Expand Down Expand Up @@ -134,7 +133,6 @@ def build_matrix(self):
# three methods: Ex, Ey and scalar

if method == "Ex":

# Ex

An = 2 / n / (n + s)
Expand Down Expand Up @@ -164,7 +162,6 @@ def build_matrix(self):
Ap = ep * k**2 - An - As - Ae * ep / ee - Aw * ep / ew

elif method == "Ey":

# Ey

An = (
Expand Down Expand Up @@ -194,7 +191,6 @@ def build_matrix(self):
Ap = ep * k**2 - An * ep / en - As * ep / es - Ae - Aw

elif method == "scalar":

# scalar

An = 2 / n / (n + s)
Expand All @@ -204,7 +200,6 @@ def build_matrix(self):
Ap = ep * k**2 - An - As - Ae - Aw

else:

raise ValueError("unknown method")

ii = numpy.arange(nx * ny).reshape(nx, ny)
Expand Down Expand Up @@ -260,7 +255,6 @@ def build_matrix(self):
return A

def solve(self, neigs, tol):

from scipy.sparse.linalg import eigen

self.nmodes = neigs
Expand Down Expand Up @@ -388,7 +382,6 @@ def _reshape(tmp):
return epsxx, epsxy, epsyx, epsyy, epszz

def build_matrix(self):

from scipy.sparse import coo_matrix

wl = self.wl
Expand Down Expand Up @@ -814,7 +807,6 @@ def build_matrix(self):
return A

def compute_other_fields(self, neffs, Hxs, Hys):

from scipy.sparse import coo_matrix

wl = self.wl
Expand All @@ -827,7 +819,6 @@ def compute_other_fields(self, neffs, Hxs, Hys):
Eys = []
Ezs = []
for neff, Hx, Hy in zip(neffs, Hxs, Hys):

dx = numpy.diff(x)
dy = numpy.diff(y)

Expand Down Expand Up @@ -2123,7 +2114,7 @@ def solve(self, neigs=4, tol=0, guess=None):
[Hzs, Exs, Eys, Ezs] = self.compute_other_fields(neffs, Hxs, Hys)

self.modes = []
for (neff, Hx, Hy, Hz, Ex, Ey, Ez) in zip(neffs, Hxs, Hys, Hzs, Exs, Eys, Ezs):
for neff, Hx, Hy, Hz, Ex, Ey, Ez in zip(neffs, Hxs, Hys, Hzs, Exs, Eys, Ezs):
self.modes.append(
FDMode(
self.wl, self.x, self.y, neff, Ex, Ey, Ez, Hx, Hy, Hz
Expand Down Expand Up @@ -2165,7 +2156,6 @@ def get_y(self, n=None):
return numpy.linspace(self.y[0], self.y[-1], n)

def get_field(self, fname, x=None, y=None):

if fname == "Ex":
f = self.Ex
centered = True
Expand Down Expand Up @@ -2246,7 +2236,6 @@ def normalize(self):
return self

def overlap(self, m, x=None, y=None):

x1 = EMpy.utils.centered1d(self.x)
y1 = EMpy.utils.centered1d(self.y)

Expand Down Expand Up @@ -2423,7 +2412,6 @@ def plot(self):


def stretchmesh(x, y, nlayers, factor, method="PPPP"):

# OKKIO: check me!

# This function can be used to continuously stretch the grid
Expand Down Expand Up @@ -2479,9 +2467,7 @@ def stretchmesh(x, y, nlayers, factor, method="PPPP"):
factor *= numpy.ones(4)

for idx, (n, f, m) in enumerate(zip(nlayers, factor, method.upper())):

if n > 0 and f != 1:

if idx == 0:
# north boundary
kv = numpy.arange(len(y) - 1 - n, len(y))
Expand Down
Loading

0 comments on commit e564dbf

Please sign in to comment.