Skip to content

Commit

Permalink
refactor: black compliant
Browse files Browse the repository at this point in the history
  • Loading branch information
lucasgrjn committed Feb 29, 2024
1 parent 3020694 commit 78e3fa0
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 16 deletions.
2 changes: 1 addition & 1 deletion docs/photonics/examples/waveguide_modes.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@
for mode in modes:
print(f"Effective refractive index: {mode.n_eff:.4f}")
mode.show("E", part="real", colorbar=True)
mode.show("E", part="imag", colorbar=True)
mode.show("E", part="imag", colorbar=True)


# %% [markdown]
Expand Down
26 changes: 14 additions & 12 deletions femwell/maxwell/waveguide.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Waveguide analysis based on https://doi.org/10.1080/02726340290084012."""

from dataclasses import dataclass
from functools import cached_property
from typing import List, Literal, Tuple
Expand Down Expand Up @@ -281,13 +282,14 @@ def plot(self, field, plot_vectors=False, colorbar=True, direction="y", title="E
)

def plot_component(
self,
field_name: Literal["E", "H"],
component: Literal["x", "y", "z"],
part: Literal["real", "imag", "abs"]="real",
boundaries: bool=True,
colorbar: bool=False,
ax: Axes=None):
self,
field_name: Literal["E", "H"],
component: Literal["x", "y", "z"],
part: Literal["real", "imag", "abs"] = "real",
boundaries: bool = True,
colorbar: bool = False,
ax: Axes = None,
):
from mpl_toolkits.axes_grid1 import make_axes_locatable

if part == "real":
Expand Down Expand Up @@ -333,7 +335,7 @@ def plot_component(
# self.basis.mesh.draw(ax=ax, boundaries=True, boundaries_only=True)
# for subdomain in self.basis.mesh.subdomains.keys() - {"gmsh:bounding_entities"}:
# self.basis.mesh.restrict(subdomain).draw(ax=ax, boundaries_only=True, color="w")
#plot_basis.mesh.draw(ax=ax, boundaries=True, boundaries_only=True)
# plot_basis.mesh.draw(ax=ax, boundaries=True, boundaries_only=True)
for subdomain in plot_basis.mesh.subdomains.keys() - {"gmsh:bounding_entities"}:
plot_basis.mesh.restrict(subdomain).draw(ax=ax, boundaries_only=True, color="k")
if colorbar:
Expand All @@ -348,11 +350,11 @@ def plot_component(
def show(
self,
field_name: Literal["E", "H"],
part: Literal["real", "imag", "abs"]="real",
boundaries: bool=True,
colorbar: bool=False,
part: Literal["real", "imag", "abs"] = "real",
boundaries: bool = True,
colorbar: bool = False,
):
fig, axs = plt.subplots(1,3, subplot_kw=dict(aspect=1))
fig, axs = plt.subplots(1, 3, subplot_kw=dict(aspect=1))

for id_ax, comp in enumerate("xyz"):
self.plot_component(field_name, comp, part, boundaries, colorbar, axs[id_ax])
Expand Down
4 changes: 1 addition & 3 deletions femwell/pn_analytical.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,7 @@ def dn_carriers(wavelength: float, dN: float, dP: float) -> float:
return -2.98 * 1e-22 * np.power(dN, 1.016) - 1.25 * 1e-18 * np.power(dP, 0.835)
else:
wavelength *= 1e-6
return -3.64 * 1e-10 * wavelength**2 * dN - 3.51 * 1e-6 * wavelength**2 * np.power(
dP, 0.8
)
return -3.64 * 1e-10 * wavelength**2 * dN - 3.51 * 1e-6 * wavelength**2 * np.power(dP, 0.8)


def dalpha_carriers(wavelength: float, dN: float, dP: float) -> float:
Expand Down

0 comments on commit 78e3fa0

Please sign in to comment.