-
Notifications
You must be signed in to change notification settings - Fork 0
Sourcery refactored master branch #1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -985,17 +985,16 @@ def CM(self, wl=None): | |
|
|
||
| if wl is None: | ||
| wl = self.wl | ||
| Hs = [] | ||
| for K, neff, l1, l2 in zip(self.Ks, self.neffs, self.l1s, self.l2s): | ||
| Hs.append( | ||
| composeTMlist( | ||
| [ | ||
| Line(self.wl, neff, 0.0, neff, l1).TM(wl), | ||
| K.TM(wl), | ||
| Line(self.wl, neff, 0.0, neff, l2).TM(wl), | ||
| ] | ||
| ) | ||
| Hs = [ | ||
| composeTMlist( | ||
| [ | ||
| Line(self.wl, neff, 0.0, neff, l1).TM(wl), | ||
| K.TM(wl), | ||
| Line(self.wl, neff, 0.0, neff, l2).TM(wl), | ||
| ] | ||
| ) | ||
| for K, neff, l1, l2 in zip(self.Ks, self.neffs, self.l1s, self.l2s) | ||
| ] | ||
|
Comment on lines
-988
to
+997
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Function
|
||
| return composeCM(composeTMlist(Hs), self.Ks[-1].CM(wl)) | ||
|
|
||
|
|
||
|
|
@@ -1330,8 +1329,6 @@ def solve(self, wls): | |
| pf = SWG.pf400_25 | ||
| elif (self.w, self.T) == (400, 125): | ||
| pf = SWG.pf400_125 | ||
| elif (self.w, self.T) == (400, 225): | ||
| pf = SWG.pf400_225 | ||
|
Comment on lines
-1333
to
-1334
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Function
|
||
| elif self.w < 400 or self.w > 488 or self.T < 25 or self.T > 225: | ||
| raise ValueError("input out of bounds") | ||
| else: | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -157,10 +157,7 @@ def __init__(self, data=None, T0=300): | |
| self.T0 = T0 | ||
|
|
||
| def TOC(self, T): | ||
| if self.__data is not None: | ||
| return numpy.polyval(self.__data, T) | ||
| else: | ||
| return 0.0 | ||
| return numpy.polyval(self.__data, T) if self.__data is not None else 0.0 | ||
|
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Function
|
||
|
|
||
| def __call__(self, T): | ||
| return self.TOC(T) | ||
|
|
@@ -213,7 +210,7 @@ def isIsotropic(): | |
|
|
||
| def __str__(self): | ||
| """Return material name.""" | ||
| return self.name + ", isotropic" | ||
| return f"{self.name}, isotropic" | ||
|
Comment on lines
-216
to
+213
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Function
|
||
|
|
||
|
|
||
| class EpsilonTensor(object): | ||
|
|
@@ -255,7 +252,7 @@ def isIsotropic(): | |
|
|
||
| def __str__(self): | ||
| """Return material name.""" | ||
| return self.name + ", anisotropic" | ||
| return f"{self.name}, anisotropic" | ||
|
Comment on lines
-258
to
+255
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Function
|
||
|
|
||
|
|
||
| # Vacuum | ||
|
|
@@ -361,7 +358,7 @@ def get_10400_000_100(conc000): | |
| nE_ = numpy.interp(conc000, conc, epsE) ** 0.5 | ||
|
|
||
| return LiquidCrystal( | ||
| "10400_000_100_" + str(conc000) + "_" + str(100 - conc000), | ||
| f"10400_000_100_{str(conc000)}_{str(100 - conc000)}", | ||
|
Comment on lines
-364
to
+361
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Function
|
||
| nO_, | ||
| nE_, | ||
| nO_electrical_, | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -89,8 +89,7 @@ def __init__(self, wl, x, y, epsfunc, boundary, method="Ex"): | |
| def _get_eps(self, xc, yc): | ||
| eps = self.epsfunc(xc, yc) | ||
| eps = numpy.c_[eps[:, 0:1], eps, eps[:, -1:]] | ||
| eps = numpy.r_[eps[0:1, :], eps, eps[-1:, :]] | ||
| return eps | ||
| return numpy.r_[eps[0:1, :], eps, eps[-1:, :]] | ||
|
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Function
|
||
|
|
||
| def build_matrix(self): | ||
|
|
||
|
|
@@ -260,9 +259,7 @@ def build_matrix(self): | |
| J = numpy.r_[iall, i_e, i_w, i_n, i_s] | ||
| V = numpy.r_[Ap[iall], Ae[i_w], Aw[i_e], An[i_s], As[i_n]] | ||
|
|
||
| A = coo_matrix((V, (I, J))).tocsr() | ||
|
|
||
| return A | ||
| return coo_matrix((V, (I, J))).tocsr() | ||
|
Comment on lines
-263
to
+262
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Function
|
||
|
|
||
| def solve(self, neigs, tol): | ||
|
|
||
|
|
@@ -286,24 +283,21 @@ def solve(self, neigs, tol): | |
| # sort and save the modes | ||
| idx = numpy.flipud(numpy.argsort(neff)) | ||
| self.neff = neff[idx] | ||
| tmp = [] | ||
| for i in idx: | ||
| tmp.append(phi[i]) | ||
|
|
||
| if self.method == "scalar": | ||
| self.phi = tmp | ||
| elif self.method == "Ex": | ||
| tmp = [phi[i] for i in idx] | ||
| if self.method == "Ex": | ||
| self.Ex = tmp | ||
| if self.method == "Ey": | ||
| elif self.method == "Ey": | ||
| self.Ey = tmp | ||
|
|
||
| elif self.method == "scalar": | ||
| self.phi = tmp | ||
|
Comment on lines
-289
to
+293
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Function
|
||
| return self | ||
|
|
||
| def __str__(self): | ||
| descr = ( | ||
| "Semi-Vectorial Finite Difference Modesolver\n\tmethod: %s\n" % self.method | ||
| return ( | ||
| "Semi-Vectorial Finite Difference Modesolver\n\tmethod: %s\n" | ||
| % self.method | ||
| ) | ||
| return descr | ||
|
Comment on lines
-303
to
-306
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Function
|
||
|
|
||
|
|
||
| class VFDModeSolver(ModeSolver): | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -136,12 +136,7 @@ def translate(self): | |
| raise ValueError("Unknown boundary.") | ||
|
|
||
| def __str__(self): | ||
| return "xleft = %s, xright = %s, yleft = %s, yright = %s" % ( | ||
| self.xleft, | ||
| self.xright, | ||
| self.yleft, | ||
| self.yright, | ||
| ) | ||
| return f"xleft = {self.xleft}, xright = {self.xright}, yleft = {self.yleft}, yright = {self.yright}" | ||
|
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Function
|
||
|
|
||
|
|
||
| class Slice(object): | ||
|
|
@@ -289,15 +284,8 @@ def get_y(self, n=100): | |
| def eval(self, x_=None, y_=None): | ||
| """Evaluate the mode at x,y.""" | ||
|
|
||
| if x_ is None: | ||
| x = self.get_x() | ||
| else: | ||
| x = numpy.atleast_1d(x_) | ||
| if y_ is None: | ||
| y = self.get_y() | ||
| else: | ||
| y = numpy.atleast_1d(y_) | ||
|
|
||
| x = self.get_x() if x_ is None else numpy.atleast_1d(x_) | ||
| y = self.get_y() if y_ is None else numpy.atleast_1d(y_) | ||
|
Comment on lines
-292
to
+288
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Function
|
||
| nmodi = len(self.modie) | ||
| lenx = len(x) | ||
| leny = len(y) | ||
|
|
@@ -501,20 +489,12 @@ def fields(self, x=None, y=None): | |
|
|
||
| def intensity(self, x=None, y=None): | ||
| Ex, Ey, Ez, cBx, cBy, cBz = self.fields(x, y) | ||
| cSz = 0.5 * (Ex * numpy.conj(cBy) - Ey * numpy.conj(cBx)) | ||
| return cSz | ||
| return 0.5 * (Ex * numpy.conj(cBy) - Ey * numpy.conj(cBx)) | ||
|
Comment on lines
-504
to
+492
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Function
|
||
|
|
||
| def TEfrac_old(self, x_=None, y_=None): | ||
|
|
||
| if x_ is None: | ||
| x = self.get_x() | ||
| else: | ||
| x = numpy.atleast_1d(x_) | ||
| if y_ is None: | ||
| y = self.get_y() | ||
| else: | ||
| y = numpy.atleast_1d(y_) | ||
|
|
||
| x = self.get_x() if x_ is None else numpy.atleast_1d(x_) | ||
| y = self.get_y() if y_ is None else numpy.atleast_1d(y_) | ||
|
Comment on lines
-509
to
+497
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Function
|
||
| Ex, Ey, Ez, cBx, cBy, cBz, cSz = self.fields(x, y) | ||
| cSTE = 0.5 * EMpy.utils.trapz2(Ex * numpy.conj(cBy), y, x) | ||
| cSTM = 0.5 * EMpy.utils.trapz2(-Ey * numpy.conj(cBx), y, x) | ||
|
|
@@ -527,15 +507,8 @@ def TEfrac(self): | |
|
|
||
| def overlap_old(self, m, x_=None, y_=None): | ||
|
|
||
| if x_ is None: | ||
| x = self.get_x() | ||
| else: | ||
| x = numpy.atleast_1d(x_) | ||
| if y_ is None: | ||
| y = self.get_y() | ||
| else: | ||
| y = numpy.atleast_1d(y_) | ||
|
|
||
| x = self.get_x() if x_ is None else numpy.atleast_1d(x_) | ||
| y = self.get_y() if y_ is None else numpy.atleast_1d(y_) | ||
|
Comment on lines
-530
to
+511
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Function
|
||
| Ex, Ey, Ez, cBx, cBy, cBz = self.fields(x, y) | ||
| cSz = self.intensity(x, y) | ||
| norm = scipy.sqrt(EMpy.utils.trapz2(cSz, y, x)) | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -32,18 +32,18 @@ def save_for_FDTD(self, mode_id="", x=None, y=None): | |
| Ex_FDTD, Ey_FDTD, Ez_FDTD, Hx_FDTD, Hy_FDTD, Hz_FDTD = self.get_fields_for_FDTD( | ||
| x, y | ||
| ) | ||
| Ex_FDTD.real.T.tofile("ex" + mode_id + ".dat", sep=" ") | ||
| Ex_FDTD.imag.T.tofile("iex" + mode_id + ".dat", sep=" ") | ||
| Ey_FDTD.real.T.tofile("ey" + mode_id + ".dat", sep=" ") | ||
| Ey_FDTD.imag.T.tofile("iey" + mode_id + ".dat", sep=" ") | ||
| Ez_FDTD.real.T.tofile("ez" + mode_id + ".dat", sep=" ") | ||
| Ez_FDTD.imag.T.tofile("iez" + mode_id + ".dat", sep=" ") | ||
| Hx_FDTD.real.T.tofile("hx" + mode_id + ".dat", sep=" ") | ||
| Hx_FDTD.imag.T.tofile("ihx" + mode_id + ".dat", sep=" ") | ||
| Hy_FDTD.real.T.tofile("hy" + mode_id + ".dat", sep=" ") | ||
| Hy_FDTD.imag.T.tofile("ihy" + mode_id + ".dat", sep=" ") | ||
| Hz_FDTD.real.T.tofile("hz" + mode_id + ".dat", sep=" ") | ||
| Hz_FDTD.imag.T.tofile("ihz" + mode_id + ".dat", sep=" ") | ||
| Ex_FDTD.real.T.tofile(f"ex{mode_id}.dat", sep=" ") | ||
| Ex_FDTD.imag.T.tofile(f"iex{mode_id}.dat", sep=" ") | ||
| Ey_FDTD.real.T.tofile(f"ey{mode_id}.dat", sep=" ") | ||
| Ey_FDTD.imag.T.tofile(f"iey{mode_id}.dat", sep=" ") | ||
| Ez_FDTD.real.T.tofile(f"ez{mode_id}.dat", sep=" ") | ||
| Ez_FDTD.imag.T.tofile(f"iez{mode_id}.dat", sep=" ") | ||
| Hx_FDTD.real.T.tofile(f"hx{mode_id}.dat", sep=" ") | ||
| Hx_FDTD.imag.T.tofile(f"ihx{mode_id}.dat", sep=" ") | ||
| Hy_FDTD.real.T.tofile(f"hy{mode_id}.dat", sep=" ") | ||
| Hy_FDTD.imag.T.tofile(f"ihy{mode_id}.dat", sep=" ") | ||
| Hz_FDTD.real.T.tofile(f"hz{mode_id}.dat", sep=" ") | ||
| Hz_FDTD.imag.T.tofile(f"ihz{mode_id}.dat", sep=" ") | ||
|
Comment on lines
-35
to
+46
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Function
|
||
|
|
||
| def plot(self, x=None, y=None): | ||
| raise NotImplementedError() | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Function
RCWA.get_pitchrefactored with the following changes:remove-unnecessary-else)swap-if-else-branches)