Skip to content
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

sync docs with meep main #1

Merged
merged 2 commits into from
Dec 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
88 changes: 50 additions & 38 deletions doc/docs/Python_Tutorials/Basics.md
Original file line number Diff line number Diff line change
Expand Up @@ -572,31 +572,6 @@ wvl = f[:,1]
# create a 2d matrix for the wavelength by repeating the column vector for each angle
wvls = np.matlib.repmat(np.reshape(wvl, (wvl.size,1)),1,theta_in.size)

plt.figure()
plt.pcolormesh(kxs, wvls, Rmeep, cmap='hot', shading='gouraud', vmin=0, vmax=Rmeep.max())
plt.axis([kxs[0,0], kxs[0,-1], wvl[-1], wvl[0]])
plt.yticks([t for t in np.arange(0.4,0.9,0.1)])
plt.xlabel("Bloch-periodic wavevector ($k_x/2π$)")
plt.ylabel("wavelength (μm)")
plt.title("reflectance (meep)")
cbar = plt.colorbar()
cbar.set_ticks([t for t in np.arange(0,0.4,0.1)])
cbar.set_ticklabels(["{:.1f}".format(t) for t in np.arange(0,0.4,0.1)])
plt.show()

plt.figure()
plt.pcolormesh(thetas, wvls, Rmeep, cmap='hot', shading='gouraud', vmin=0, vmax=Rmeep.max())
plt.axis([thetas.min(), thetas.max(), wvl[-1], wvl[0]])
plt.xticks([t for t in range(0,100,20)])
plt.yticks([t for t in np.arange(0.4,0.9,0.1)])
plt.xlabel("angle of incident planewave (degrees)")
plt.ylabel("wavelength (μm)")
plt.title("reflectance (meep)")
cbar = plt.colorbar()
cbar.set_ticks([t for t in np.arange(0,0.4,0.1)])
cbar.set_ticklabels(["{:.1f}".format(t) for t in np.arange(0,0.4,0.1)])
plt.show()

n1=1
n2=3.5

Expand All @@ -606,25 +581,62 @@ theta_out = lambda theta_in: math.asin(n1*math.sin(theta_in)/n2)

# compute Fresnel reflectance for P-polarization in medium n2
# for incident planewave in medium n1 at angle theta_in
Rfresnel = lambda theta_in: math.fabs((n1*math.cos(theta_out(theta_in))-n2*math.cos(theta_in))/(n1*math.cos(theta_out(theta_in))+n2*math.cos(theta_in)))**2
Rfresnel = lambda theta_in: math.fabs((n1*math.cos(theta_out(theta_in)) -
n2*math.cos(theta_in)) /
(n1*math.cos(theta_out(theta_in)) +
n2*math.cos(theta_in)))**2

Ranalytic = np.empty((50, theta_in.size))
for m in range(wvl.size):
for n in range(theta_in.size):
Ranalytic[m,n] = Rfresnel(math.radians(thetas[m,n]))

plt.figure()
plt.pcolormesh(thetas, wvls, Ranalytic, cmap='hot', shading='gouraud', vmin=0, vmax=Ranalytic.max())
plt.axis([thetas.min(), thetas.max(), wvl[-1], wvl[0]])
plt.xticks([t for t in range(0,100,20)])
plt.yticks([t for t in np.arange(0.4,0.9,0.1)])
plt.xlabel("angle of incident planewave (degrees)")
plt.ylabel("wavelength (μm)")
plt.title("reflectance (analytic)")
cbar = plt.colorbar()
cbar.set_ticks([t for t in np.arange(0,0.4,0.1)])
cbar.set_ticklabels(["{:.1f}".format(t) for t in np.arange(0,0.4,0.1)])
plt.show()
fig, axs = plt.subplots(nrows=2, ncols=2, figsize=(9,6))

wvl_idx = 0
axs[0, 0].plot(theta_in,Rmeep[wvl_idx,:], 'bo-', label="meep")
axs[0, 0].plot(theta_in,Ranalytic[wvl_idx,:], 'ro-', label="analytic")
axs[0, 0].set_xlabel("angle of incident planewave (degrees)")
axs[0, 0].set_ylabel(f"reflectance at $\lambda$ = {wvl[wvl_idx]:.1f} μm")
axs[0, 0].legend()

pc = axs[0, 1].pcolormesh(kxs, wvls, Rmeep, cmap='hot_r', shading='gouraud',
vmin=0, vmax=Rmeep.max())
axs[0, 1].axis([kxs[0,0], kxs[0,-1], wvl[-1], wvl[0]])
axs[0, 1].set_yticks([t for t in np.arange(wvl[-1], wvl[0] + 0.1, 0.1)])
axs[0, 1].set_xlabel("Bloch-periodic wavevector ($k_x/2π$)")
axs[0, 1].set_ylabel("wavelength (μm)")
axs[0, 1].set_title("reflectance (meep)")
cbar = fig.colorbar(pc, ax=axs[0, 1])
cbar.set_ticks([t for t in np.arange(0, 0.4, 0.1)])
cbar.set_ticklabels(["{:.1f}".format(t) for t in np.arange(0, 0.4, 0.1)])

pc = axs[1, 0].pcolormesh(thetas, wvls, Rmeep, cmap='hot_r', shading='gouraud',
vmin=0, vmax=Rmeep.max())
axs[1, 0].axis([thetas.min(), thetas.max(), wvl[-1], wvl[0]])
axs[1, 0].set_xticks([t for t in range(0,100,20)])
axs[1, 0].set_yticks([t for t in np.arange(wvl[-1], wvl[0] + 0.1, 0.1)])
axs[1, 0].set_xlabel("angle of incident planewave (degrees)")
axs[1, 0].set_ylabel("wavelength (μm)")
axs[1, 0].set_title("reflectance (meep)")
cbar = fig.colorbar(pc, ax=axs[1, 0])
cbar.set_ticks([t for t in np.arange(0, 0.4, 0.1)])
cbar.set_ticklabels(["{:.1f}".format(t) for t in np.arange(0, 0.4, 0.1)])

pc = axs[1, 1].pcolormesh(thetas, wvls, Ranalytic, cmap='hot_r', shading='gouraud',
vmin=0, vmax=Ranalytic.max())
axs[1, 1].axis([thetas.min(), thetas.max(), wvl[-1], wvl[0]])
axs[1, 1].set_xticks([t for t in range(0,100,20)])
axs[1, 1].set_yticks([t for t in np.arange(wvl[-1], wvl[0] + 0.1, 0.1)])
axs[1, 1].set_xlabel("angle of incident planewave (degrees)")
axs[1, 1].set_ylabel("wavelength (μm)")
axs[1, 1].set_title("reflectance (analytic)")
cbar = fig.colorbar(pc, ax=axs[1, 1])
cbar.set_ticks([t for t in np.arange(0, 0.4, 0.1)])
cbar.set_ticklabels(["{:.1f}".format(t) for t in np.arange(0, 0.4, 0.1)])

fig.tight_layout()
fig.savefig('reflectance_angular_spectrum.png', bbox_inches='tight', dpi=150)
```

![](../images/reflectance_angular_spectrum.png#center)
Expand Down
Binary file modified doc/docs/images/reflectance_angular_spectrum.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading