def plot(): nb_points = 4001 f_range = 64e9 f_start = 500e9 f_stop = f_start + f_range fs = np.linspace(f_start, f_stop, nb_points) observable = fs <= 504e9 b0s = np.zeros(nb_points, dtype=complex) b5s = np.zeros(nb_points, dtype=complex) for i, f in enumerate(fs): b0s[i], b5s[i] = setup(f) y0s = np.abs(b0s) ** 2 y5s = np.abs(b5s) ** 2 # Direct. plt.plot(fs[observable] / 1.e9, y0s[observable], color=style.COLORS_STD[1]) plt.plot(fs[observable] / 1.e9, y5s[observable], color=style.COLORS_STD[2]) plt.xlabel(style.latexT("Frequency [\\si{\\giga\\hertz}]")) plt.ylabel(style.latexT("Power coupling [1]")) plt.ylim((-.1, 1.1)) if USE_PDF: plt.savefig("simple_cavity_direct.pdf", bbox_inches='tight') else: plt.show() # FFT. L = .5 prediction = scipy.constants.speed_of_light / (2 * L) / 1.e6 h = np.hanning(nb_points) y0s = np.abs(np.fft.rfft(y0s * h)) y5s = np.abs(np.fft.rfft(y5s * h)) cutat = len(y0s) p = np.fft.fftfreq(nb_points, f_range / (nb_points))[:cutat] # In Hz-1. p = 1 / p # In Hz. p /= 1.e6 # In MHz. # p = p[3:] # y0s = y0s[3:] # y5s = y5s[3:] plt.clf() # plt.axvline(prediction / 2, linestyle='-', color='#878686', linewidth=1) # plt.axvline(prediction, linestyle='-', color='#878686', linewidth=1) plt.plot(p, y0s, '-', color=style.COLORS_STD[1]) plt.plot(p, y5s, '--', color=style.COLORS_STD[2]) plt.xlabel(style.latexT("Period [\\si{\\mega\\hertz}]")) plt.ylabel(style.latexT("FFT power coupling [arbitrary]")) plt.annotate(style.latexM("c/2d"), xy=(prediction, 0), xytext=(prediction, -5), horizontalalignment='center', verticalalignment='center') plt.annotate(style.latexM("c/4d"), xy=(prediction / 2, 0), xytext=(prediction / 2, -5), horizontalalignment='center', verticalalignment='center') plt.xlim((0, 500)) plt.ylim((-10, 70)) if USE_PDF: plt.savefig("simple_cavity_fft.pdf", bbox_inches='tight') else: plt.show()
def plot(): plt.clf() f = 500e9 omega = 2 * np.pi * f n = 1 c = scipy.constants.speed_of_light / n lambda_ = c / f k = 2 * np.pi / lambda_ phi = 0 x = np.linspace(0, 1e-3, 1000) ts = np.linspace(0, 1 / f / 2, 5) legends = [] for i, t in enumerate(ts): y = np.cos(omega * t - k * x + phi) j = len(ts) - 1 - i col = j / (j + 1) plt.plot(x * 1000, y, color=(col, col, col)) plt.ylim([-1.1, 1.1]) plt.xlabel(style.latexT("Position $z$ [\\si{\\milli\\meter}]")) plt.ylabel(style.latexT("Amplitude $e(z, t)$ [\\si{\\volt\\per\\meter}]")) legend = style.latexM("t=\\SI{%04.2f}{\\pico\\second}" % (t * 1e12)) legends.append(legend) plt.legend(legends, loc="lower right") if USE_PDF: plt.savefig("plane_wave_propagation.pdf", bbox_inches='tight') else: plt.show()
def plot(): fs_normal = np.linspace(1, 90, 90) fs_critical = np.linspace(41.8103, 41.8104, 10) # High resolution around critical angle. fs = np.concatenate((fs_normal, fs_critical)) fs.sort() fs = np.radians(fs) nb_points = len(fs) rAhs = np.zeros(nb_points, dtype=complex) rAvs = np.zeros(nb_points, dtype=complex) tAhs = np.zeros(nb_points, dtype=complex) tAvs = np.zeros(nb_points, dtype=complex) rBhs = np.zeros(nb_points, dtype=complex) rBvs = np.zeros(nb_points, dtype=complex) tBhs = np.zeros(nb_points, dtype=complex) tBvs = np.zeros(nb_points, dtype=complex) n1 = 1 n2 = 1.5 Z1 = Z0 / n1 # True for dielectrics only. Z2 = Z0 / n2 # True for dielectrics only. for i, f in enumerate(fs): rh, rv, th, tv = setup(n1, n2, f) # P = EH and E=ZH => P = E**2 / Z. rAhs[i] = np.linalg.norm(rh) ** 2 / Z1 rAvs[i] = np.linalg.norm(rv) ** 2 / Z1 tAhs[i] = np.linalg.norm(th) ** 2 / Z2 tAvs[i] = np.linalg.norm(tv) ** 2 / Z2 # rh, rv, th, tv = setup(n2, n1, f) rBhs[i] = np.linalg.norm(rh) ** 2 / Z2 rBvs[i] = np.linalg.norm(rv) ** 2 / Z2 tBhs[i] = np.linalg.norm(th) ** 2 / Z1 tBvs[i] = np.linalg.norm(tv) ** 2 / Z1 crit_b = np.degrees(np.arcsin(n1.real / n2.real)) brew_a = np.degrees(np.arctan(n2.real / n1.real)) brew_b = np.degrees(np.arctan(n1.real / n2.real)) xs = np.degrees(fs) plt.subplot(3, 2, 1) plt.axvline(brew_a, linestyle=':', color=style.COLORS_STD[0], label=style.latexT("Brewster")) plt.plot(xs, tAhs, '-', color=style.COLORS_STD[1], label=style.latexM("T_\perp")) plt.plot(xs, tAvs, '-', color=style.COLORS_STD[2], label=style.latexM("T_\parallel")) plt.ylabel(style.latexT("Power coupling [1]")) plt.title(style.latexM("n_i=1.0, n_t=1.5"), fontsize=10) plt.xlim((0, 90)) plt.ylim((-.1, 1.1)) plt.legend(loc='center left', prop={"size":6}) plt.subplot(3, 2, 2) plt.axvline(crit_b, linestyle='--', color=style.COLORS_STD[0], label=style.latexT("Critical")) plt.axvline(brew_b, linestyle=':', color=style.COLORS_STD[0], label=style.latexT("Brewster")) plt.plot(xs, tBhs, '-', color=style.COLORS_STD[1], label=style.latexM("T_\perp")) plt.plot(xs, tBvs, '-', color=style.COLORS_STD[2], label=style.latexM("T_\parallel")) plt.title(style.latexM("n_i=1.5, n_t=1.0"), fontsize=10) plt.xlim((0, 90)) plt.ylim((-.1, 1.1)) plt.legend(loc='upper right', prop={"size":6}) plt.subplot(3, 2, 3) plt.axvline(brew_a, linestyle=':', color=style.COLORS_STD[0], label=style.latexT("Brewster")) plt.plot(xs, rAhs, '-', color=style.COLORS_STD[1], label=style.latexM("R_\perp")) plt.plot(xs, rAvs, '-', color=style.COLORS_STD[2], label=style.latexM("R_\parallel")) plt.ylabel(style.latexT("Power coupling [1]")) plt.xlim((0, 90)) plt.ylim((-.1, 1.1)) plt.legend(loc='upper left', prop={"size":6}) plt.subplot(3, 2, 4) plt.axvline(crit_b, linestyle='--', color=style.COLORS_STD[0], label=style.latexT("Critical")) plt.axvline(brew_b, linestyle=':', color=style.COLORS_STD[0], label=style.latexT("Brewster")) plt.plot(xs, rBhs, '-', color=style.COLORS_STD[1], label=style.latexM("R_\perp")) plt.plot(xs, rBvs, '-', color=style.COLORS_STD[2], label=style.latexM("R_\parallel")) plt.xlim((0, 90)) plt.ylim((-.1, 1.1)) plt.legend(loc='upper right', prop={"size":6}) plt.subplot(3, 2, 5) plt.plot(xs, tAhs + rAhs, '-', color=style.COLORS_STD[1], label=style.latexT("Sum $\perp$")) plt.plot(xs, tAvs + rAvs, '--', color=style.COLORS_STD[2], label=style.latexT("Sum $\parallel$")) plt.ylabel(style.latexT("Power coupling [1]")) plt.xlabel(style.latexT("Incidence angle [\\si{\\degree}]")) plt.xlim((0, 90)) plt.ylim((-.1, 1.1)) plt.legend(loc='center left', prop={"size":6}) plt.subplot(3, 2, 6) plt.axvline(crit_b, linestyle='--', color=style.COLORS_STD[0], label=style.latexT("Critical")) plt.plot(xs, tBhs + rBhs, '-', color=style.COLORS_STD[1], label=style.latexT("Sum $\perp$")) plt.plot(xs, tBvs + rBvs, '--', color=style.COLORS_STD[2], label=style.latexT("Sum $\parallel$")) plt.xlabel(style.latexT("Incidence angle [\\si{\\degree}]")) plt.xlim((0, 90)) plt.ylim((-.1, 1.1)) plt.legend(loc='upper right', prop={"size":6}) if USE_PDF: plt.savefig("interface_oblique_verification.pdf", bbox_inches='tight') else: plt.show()