Path: blob/main/latex-templates/templates/optics/gaussian_beam.tex
51 views
unlisted
\documentclass[a4paper, 11pt]{article}1\usepackage[utf8]{inputenc}2\usepackage[T1]{fontenc}3\usepackage{amsmath, amssymb}4\usepackage{graphicx}5\usepackage{siunitx}6\usepackage{booktabs}7\usepackage[makestderr]{pythontex}89\title{Optics: Gaussian Beam Propagation}10\author{Computational Science Templates}11\date{\today}1213\begin{document}14\maketitle1516\section{Introduction}17Gaussian beams are fundamental to laser optics and optical communication. They represent the lowest-order transverse electromagnetic mode (TEM$_{00}$) of optical resonators. This analysis computes the propagation characteristics of a Gaussian beam, including beam waist, divergence, Rayleigh range, and focuses on practical applications like focusing and optical system design using ABCD matrix methods.1819\section{Mathematical Framework}2021\subsection{Electric Field and Intensity}22The Gaussian beam electric field amplitude:23\begin{equation}24E(r, z) = E_0 \frac{w_0}{w(z)} \exp\left(-\frac{r^2}{w(z)^2}\right) \exp\left(i\left(kz + k\frac{r^2}{2R(z)} - \psi(z)\right)\right)25\end{equation}2627The intensity profile is:28\begin{equation}29I(r, z) = I_0 \left(\frac{w_0}{w(z)}\right)^2 \exp\left(-\frac{2r^2}{w(z)^2}\right)30\end{equation}3132\subsection{Key Parameters}33\begin{align}34w(z) &= w_0\sqrt{1 + \left(\frac{z}{z_R}\right)^2} & \text{(beam width)} \\35z_R &= \frac{\pi w_0^2}{\lambda} & \text{(Rayleigh range)} \\36R(z) &= z\left[1 + \left(\frac{z_R}{z}\right)^2\right] & \text{(wavefront curvature)} \\37\psi(z) &= \arctan\left(\frac{z}{z_R}\right) & \text{(Gouy phase)}38\end{align}3940\subsection{Beam Quality Factor}41The $M^2$ parameter characterizes beam quality:42\begin{equation}43M^2 = \frac{\pi w_0 \theta}{\lambda}44\end{equation}45where $\theta$ is the far-field divergence half-angle. For an ideal Gaussian beam, $M^2 = 1$.4647\section{Environment Setup}48\begin{pycode}49import numpy as np50import matplotlib.pyplot as plt51plt.rc('text', usetex=True)52plt.rc('font', family='serif')5354def save_plot(filename, caption=""):55plt.savefig(filename, bbox_inches='tight', dpi=150)56print(r'\begin{figure}[htbp]')57print(r'\centering')58print(r'\includegraphics[width=0.95\textwidth]{' + filename + '}')59if caption:60print(r'\caption{' + caption + '}')61print(r'\end{figure}')62plt.close()63\end{pycode}6465\section{Basic Beam Propagation}66\begin{pycode}67# Beam parameters68wavelength = 1064e-9 # Nd:YAG (m)69w0 = 100e-6 # Beam waist (m)7071# Rayleigh range72z_R = np.pi * w0**2 / wavelength7374# Propagation functions75def beam_width(z, w0, z_R):76return w0 * np.sqrt(1 + (z / z_R)**2)7778def radius_of_curvature(z, z_R):79z = np.where(z == 0, 1e-10, z)80return z * (1 + (z_R / z)**2)8182def gouy_phase(z, z_R):83return np.arctan(z / z_R)8485def intensity_profile(r, z, w0, z_R):86w = beam_width(z, w0, z_R)87return (w0 / w)**2 * np.exp(-2 * r**2 / w**2)8889# z array90z = np.linspace(-5 * z_R, 5 * z_R, 500)9192# Calculate beam parameters93w = beam_width(z, w0, z_R)94R = radius_of_curvature(z, z_R)95psi = gouy_phase(z, z_R)9697# Divergence angle98theta_div = wavelength / (np.pi * w0)99100# Beam profile at different z101z_positions = [0, z_R, 3*z_R]102r = np.linspace(-500e-6, 500e-6, 200)103104# Create plots105fig, axes = plt.subplots(2, 2, figsize=(10, 8))106107# Plot 1: Beam envelope108z_mm = z * 1000109w_um = w * 1e6110axes[0, 0].fill_between(z_mm, -w_um, w_um, alpha=0.3, color='red')111axes[0, 0].plot(z_mm, w_um, 'r-', linewidth=2)112axes[0, 0].plot(z_mm, -w_um, 'r-', linewidth=2)113axes[0, 0].axvline(x=z_R*1000, color='blue', linestyle='--', alpha=0.5, label=f'$z_R = {z_R*1000:.1f}$ mm')114axes[0, 0].axvline(x=-z_R*1000, color='blue', linestyle='--', alpha=0.5)115axes[0, 0].set_xlabel('Propagation distance (mm)')116axes[0, 0].set_ylabel('Beam radius ($\\mu$m)')117axes[0, 0].set_title('Gaussian Beam Envelope')118axes[0, 0].legend()119axes[0, 0].grid(True, alpha=0.3)120121# Plot 2: Intensity profiles at different z122colors = ['blue', 'green', 'red']123for z_pos, color in zip(z_positions, colors):124w_z = beam_width(z_pos, w0, z_R)125I = np.exp(-2 * r**2 / w_z**2)126label = f'$z = {z_pos/z_R:.0f} z_R$' if z_pos > 0 else '$z = 0$'127axes[0, 1].plot(r*1e6, I, color=color, linewidth=2, label=label)128129axes[0, 1].set_xlabel('Radial position ($\\mu$m)')130axes[0, 1].set_ylabel('Intensity (normalized)')131axes[0, 1].set_title('Intensity Profiles')132axes[0, 1].legend()133axes[0, 1].grid(True, alpha=0.3)134135# Plot 3: Radius of curvature136R_mm = R / 1000137axes[1, 0].plot(z_mm, R_mm, 'b-', linewidth=2)138axes[1, 0].axhline(y=0, color='gray', linestyle='-', alpha=0.3)139axes[1, 0].set_xlabel('Propagation distance (mm)')140axes[1, 0].set_ylabel('Radius of curvature (m)')141axes[1, 0].set_title('Wavefront Curvature')142axes[1, 0].set_ylim([-50, 50])143axes[1, 0].grid(True, alpha=0.3)144145# Plot 4: Gouy phase146axes[1, 1].plot(z_mm, np.rad2deg(psi), 'purple', linewidth=2)147axes[1, 1].axhline(y=90, color='gray', linestyle='--', alpha=0.5)148axes[1, 1].axhline(y=-90, color='gray', linestyle='--', alpha=0.5)149axes[1, 1].set_xlabel('Propagation distance (mm)')150axes[1, 1].set_ylabel('Gouy phase (degrees)')151axes[1, 1].set_title('Gouy Phase Shift')152axes[1, 1].grid(True, alpha=0.3)153154plt.tight_layout()155save_plot('gaussian_beam_basic.pdf', 'Basic Gaussian beam propagation: envelope, intensity profiles, wavefront curvature, and Gouy phase.')156157# Calculate beam quality factor158M2 = 1.0 # Ideal Gaussian159depth_of_focus = 2 * z_R160\end{pycode}161162\section{2D Beam Propagation Visualization}163\begin{pycode}164# Create 2D visualization of beam propagation165z_2d = np.linspace(-3*z_R, 3*z_R, 200)166r_2d = np.linspace(-3*w0, 3*w0, 100)167168Z, R_mesh = np.meshgrid(z_2d, r_2d)169170# Calculate intensity distribution171I_2d = np.zeros_like(Z)172for i, zv in enumerate(z_2d):173w_z = beam_width(zv, w0, z_R)174I_2d[:, i] = (w0/w_z)**2 * np.exp(-2 * r_2d**2 / w_z**2)175176fig, axes = plt.subplots(2, 2, figsize=(10, 8))177178# Plot 1: 2D intensity distribution (side view)179im = axes[0, 0].pcolormesh(Z*1000, R_mesh*1e6, I_2d, cmap='hot', shading='auto')180axes[0, 0].plot(z_2d*1000, beam_width(z_2d, w0, z_R)*1e6, 'w--', linewidth=1.5, label='$w(z)$')181axes[0, 0].plot(z_2d*1000, -beam_width(z_2d, w0, z_R)*1e6, 'w--', linewidth=1.5)182axes[0, 0].set_xlabel('$z$ (mm)')183axes[0, 0].set_ylabel('$r$ ($\\mu$m)')184axes[0, 0].set_title('Beam Intensity Distribution')185plt.colorbar(im, ax=axes[0, 0], label='Intensity')186187# Plot 2: Cross-section at waist188theta = np.linspace(0, 2*np.pi, 100)189r_cross = np.linspace(0, 3*w0, 100)190R_c, THETA = np.meshgrid(r_cross, theta)191X = R_c * np.cos(THETA)192Y = R_c * np.sin(THETA)193I_cross = np.exp(-2 * R_c**2 / w0**2)194195im2 = axes[0, 1].pcolormesh(X*1e6, Y*1e6, I_cross, cmap='hot', shading='auto')196circle = plt.Circle((0, 0), w0*1e6, fill=False, color='white', linestyle='--', linewidth=1.5)197axes[0, 1].add_patch(circle)198axes[0, 1].set_xlabel('$x$ ($\\mu$m)')199axes[0, 1].set_ylabel('$y$ ($\\mu$m)')200axes[0, 1].set_title('Cross-section at Waist')201axes[0, 1].set_aspect('equal')202203# Plot 3: Power through aperture204aperture_radii = np.linspace(0, 3*w0, 100)205power_fraction = 1 - np.exp(-2 * aperture_radii**2 / w0**2)206207axes[1, 0].plot(aperture_radii/w0, power_fraction*100, 'b-', linewidth=2)208axes[1, 0].axhline(y=86.5, color='gray', linestyle='--', alpha=0.7, label='$r = w_0$ (86.5\\%)')209axes[1, 0].axhline(y=99, color='gray', linestyle=':', alpha=0.7, label='$r = 1.5w_0$ (99\\%)')210axes[1, 0].axvline(x=1, color='red', linestyle='--', alpha=0.5)211axes[1, 0].axvline(x=1.5, color='red', linestyle=':', alpha=0.5)212axes[1, 0].set_xlabel('Aperture radius ($r/w_0$)')213axes[1, 0].set_ylabel('Transmitted power (\\%)')214axes[1, 0].set_title('Power Through Circular Aperture')215axes[1, 0].legend(fontsize=8)216axes[1, 0].grid(True, alpha=0.3)217218# Plot 4: Peak intensity vs z219z_peak = np.linspace(-5*z_R, 5*z_R, 200)220I_peak = (w0 / beam_width(z_peak, w0, z_R))**2221222axes[1, 1].plot(z_peak/z_R, I_peak, 'g-', linewidth=2)223axes[1, 1].axhline(y=0.5, color='gray', linestyle='--', alpha=0.7, label='Half maximum')224axes[1, 1].axvline(x=1, color='red', linestyle='--', alpha=0.5)225axes[1, 1].axvline(x=-1, color='red', linestyle='--', alpha=0.5)226axes[1, 1].set_xlabel('$z/z_R$')227axes[1, 1].set_ylabel('Peak intensity (normalized)')228axes[1, 1].set_title('Axial Intensity')229axes[1, 1].legend()230axes[1, 1].grid(True, alpha=0.3)231232plt.tight_layout()233save_plot('gaussian_beam_2d.pdf', '2D beam visualization: intensity distribution, cross-section, power transmission, and axial intensity.')234\end{pycode}235236\section{Focusing with a Lens}237\begin{pycode}238# Gaussian beam focusing with a lens239# Using ABCD matrix formalism240241def transform_gaussian_beam(q_in, ABCD):242"""Transform Gaussian beam complex parameter q through ABCD matrix."""243A, B, C, D = ABCD[0,0], ABCD[0,1], ABCD[1,0], ABCD[1,1]244q_out = (A * q_in + B) / (C * q_in + D)245return q_out246247def q_to_params(q, wavelength):248"""Extract beam waist position and size from complex beam parameter."""249# 1/q = 1/R - i*lambda/(pi*w^2)250inv_q = 1 / q251R = 1 / np.real(inv_q) if np.real(inv_q) != 0 else np.inf252w = np.sqrt(-wavelength / (np.pi * np.imag(inv_q)))253return R, w254255# Input beam parameters256w0_input = 1e-3 # 1 mm beam waist257z_R_input = np.pi * w0_input**2 / wavelength258259# Lens parameters260f = 100e-3 # 100 mm focal length261d1 = 200e-3 # Distance from waist to lens262d2_values = np.linspace(50e-3, 200e-3, 100)263264# Calculate focused spot sizes265focused_waists = []266waist_positions = []267268for d2 in d2_values:269# ABCD matrices270# Free propagation d1271M1 = np.array([[1, d1], [0, 1]])272# Thin lens273M_lens = np.array([[1, 0], [-1/f, 1]])274# Free propagation d2275M2 = np.array([[1, d2], [0, 1]])276277# Total system278M_total = M2 @ M_lens @ M1279280# Input complex beam parameter at waist281q_in = 1j * z_R_input282283# Transform284q_out = transform_gaussian_beam(q_in, M_total)285286# Extract parameters287R_out, w_out = q_to_params(q_out, wavelength)288focused_waists.append(w_out)289290# Find waist position (where R -> infinity)291# Waist is at q purely imaginary292293focused_waists = np.array(focused_waists)294295# Theoretical focused waist (thin lens approximation)296w0_focused_theory = wavelength * f / (np.pi * w0_input)297298fig, axes = plt.subplots(2, 2, figsize=(10, 8))299300# Plot 1: Focused beam waist vs distance after lens301axes[0, 0].plot(d2_values*1000, focused_waists*1e6, 'b-', linewidth=2)302axes[0, 0].axhline(y=w0_focused_theory*1e6, color='gray', linestyle='--', alpha=0.7,303label=f'Theory: {w0_focused_theory*1e6:.1f} $\\mu$m')304axes[0, 0].axvline(x=f*1000, color='red', linestyle='--', alpha=0.5, label=f'$f = {f*1000:.0f}$ mm')305axes[0, 0].set_xlabel('Distance after lens (mm)')306axes[0, 0].set_ylabel('Beam radius ($\\mu$m)')307axes[0, 0].set_title('Focused Beam Size')308axes[0, 0].legend()309axes[0, 0].grid(True, alpha=0.3)310311# Plot 2: Beam propagation through focusing system312z_total = np.linspace(0, d1 + f*2, 300)313w_propagation = []314315for z in z_total:316if z < d1:317# Before lens318q = 1j * z_R_input + z319else:320# After lens321M1 = np.array([[1, d1], [0, 1]])322M_lens = np.array([[1, 0], [-1/f, 1]])323M2 = np.array([[1, z - d1], [0, 1]])324M_total = M2 @ M_lens @ M1325q_in = 1j * z_R_input326q = transform_gaussian_beam(q_in, M_total)327328R_z, w_z = q_to_params(q, wavelength)329w_propagation.append(w_z)330331w_propagation = np.array(w_propagation)332333axes[0, 1].plot(z_total*1000, w_propagation*1e6, 'b-', linewidth=2)334axes[0, 1].plot(z_total*1000, -w_propagation*1e6, 'b-', linewidth=2)335axes[0, 1].fill_between(z_total*1000, -w_propagation*1e6, w_propagation*1e6, alpha=0.3)336axes[0, 1].axvline(x=d1*1000, color='green', linestyle='-', linewidth=3, label='Lens')337axes[0, 1].set_xlabel('$z$ (mm)')338axes[0, 1].set_ylabel('Beam radius ($\\mu$m)')339axes[0, 1].set_title('Beam Focusing Through Lens')340axes[0, 1].legend()341axes[0, 1].grid(True, alpha=0.3)342343# Plot 3: Effect of lens focal length on spot size344focal_lengths = np.linspace(20e-3, 200e-3, 100)345spot_sizes = wavelength * focal_lengths / (np.pi * w0_input)346347axes[1, 0].plot(focal_lengths*1000, spot_sizes*1e6, 'g-', linewidth=2)348axes[1, 0].set_xlabel('Focal length (mm)')349axes[1, 0].set_ylabel('Minimum spot size ($\\mu$m)')350axes[1, 0].set_title('Spot Size vs Focal Length')351axes[1, 0].grid(True, alpha=0.3)352353# Plot 4: Depth of focus of focused beam354NA = w0_input / f # Numerical aperture355DOF = 2 * wavelength / (NA**2)356357# Intensity along axis near focus358z_near_focus = np.linspace(-3*DOF, 3*DOF, 200)359z_R_focused = np.pi * w0_focused_theory**2 / wavelength360I_axial = 1 / (1 + (z_near_focus/z_R_focused)**2)361362axes[1, 1].plot(z_near_focus*1e6, I_axial, 'r-', linewidth=2)363axes[1, 1].axhline(y=0.5, color='gray', linestyle='--', alpha=0.7)364axes[1, 1].axvline(x=z_R_focused*1e6, color='blue', linestyle='--', alpha=0.5, label=f'$z_R = {z_R_focused*1e6:.1f}$ $\\mu$m')365axes[1, 1].axvline(x=-z_R_focused*1e6, color='blue', linestyle='--', alpha=0.5)366axes[1, 1].set_xlabel('Distance from focus ($\\mu$m)')367axes[1, 1].set_ylabel('Axial intensity (normalized)')368axes[1, 1].set_title('Depth of Focus')369axes[1, 1].legend()370axes[1, 1].grid(True, alpha=0.3)371372plt.tight_layout()373save_plot('gaussian_beam_focusing.pdf', 'Gaussian beam focusing: spot size, beam propagation through lens, and depth of focus.')374\end{pycode}375376\section{Higher-Order Hermite-Gaussian Modes}377\begin{pycode}378from scipy.special import hermite379380# Higher-order mode analysis381def hermite_gaussian(x, y, z, m, n, w0, wavelength):382"""Calculate Hermite-Gaussian mode amplitude."""383z_R = np.pi * w0**2 / wavelength384w = w0 * np.sqrt(1 + (z/z_R)**2)385R = z * (1 + (z_R/z)**2) if z != 0 else np.inf386psi = np.arctan(z/z_R)387388# Hermite polynomials389Hm = hermite(m)390Hn = hermite(n)391392# Mode amplitude393E = (1/w) * Hm(np.sqrt(2)*x/w) * Hn(np.sqrt(2)*y/w) * np.exp(-(x**2 + y**2)/w**2)394395return E396397# Create mode patterns398x = np.linspace(-3*w0, 3*w0, 100)399y = np.linspace(-3*w0, 3*w0, 100)400X, Y = np.meshgrid(x, y)401402fig, axes = plt.subplots(2, 3, figsize=(12, 8))403404modes = [(0, 0), (1, 0), (0, 1), (1, 1), (2, 0), (2, 2)]405titles = ['TEM$_{00}$', 'TEM$_{10}$', 'TEM$_{01}$', 'TEM$_{11}$', 'TEM$_{20}$', 'TEM$_{22}$']406407for ax, (m, n), title in zip(axes.flat, modes, titles):408E = hermite_gaussian(X, Y, 0, m, n, w0, wavelength)409I = np.abs(E)**2410411im = ax.pcolormesh(X*1e6, Y*1e6, I, cmap='hot', shading='auto')412ax.set_xlabel('$x$ ($\\mu$m)')413ax.set_ylabel('$y$ ($\\mu$m)')414ax.set_title(title)415ax.set_aspect('equal')416417plt.tight_layout()418save_plot('hermite_gaussian_modes.pdf', 'Hermite-Gaussian transverse modes TEM$_{mn}$ intensity patterns.')419\end{pycode}420421\section{Beam Quality Analysis}422\begin{pycode}423# M^2 beam quality analysis424# Compare ideal Gaussian to real beam with M^2 > 1425426M2_values = [1.0, 1.5, 2.0, 3.0]427colors_m2 = ['blue', 'green', 'orange', 'red']428429fig, axes = plt.subplots(2, 2, figsize=(10, 8))430431# Plot 1: Beam width for different M^2432z_m2 = np.linspace(-5*z_R, 5*z_R, 200)433434for M2, color in zip(M2_values, colors_m2):435w_m2 = w0 * np.sqrt(1 + (M2 * z_m2 / z_R)**2)436axes[0, 0].plot(z_m2/z_R, w_m2/w0, color=color, linewidth=2, label=f'$M^2 = {M2:.1f}$')437438axes[0, 0].set_xlabel('$z/z_R$')439axes[0, 0].set_ylabel('$w(z)/w_0$')440axes[0, 0].set_title('Beam Width vs $M^2$')441axes[0, 0].legend()442axes[0, 0].grid(True, alpha=0.3)443444# Plot 2: Divergence vs M^2445M2_range = np.linspace(1, 5, 100)446divergence = M2_range * wavelength / (np.pi * w0) * 1000 # mrad447448axes[0, 1].plot(M2_range, divergence, 'b-', linewidth=2)449axes[0, 1].set_xlabel('$M^2$')450axes[0, 1].set_ylabel('Divergence (mrad)')451axes[0, 1].set_title('Far-field Divergence vs Beam Quality')452axes[0, 1].grid(True, alpha=0.3)453454# Plot 3: Brightness (power density per solid angle)455P_total = 1 # Normalized power456brightness = P_total / (np.pi * (M2_range * wavelength / (np.pi * w0))**2)457brightness_norm = brightness / brightness[0]458459axes[1, 0].plot(M2_range, brightness_norm, 'g-', linewidth=2)460axes[1, 0].set_xlabel('$M^2$')461axes[1, 0].set_ylabel('Brightness (normalized)')462axes[1, 0].set_title('Beam Brightness vs $M^2$')463axes[1, 0].grid(True, alpha=0.3)464465# Plot 4: Focused spot size for different M^2466f_lens = 100e-3467w0_focused = M2_range * wavelength * f_lens / (np.pi * w0_input)468469axes[1, 1].plot(M2_range, w0_focused*1e6, 'r-', linewidth=2)470axes[1, 1].set_xlabel('$M^2$')471axes[1, 1].set_ylabel('Focused spot size ($\\mu$m)')472axes[1, 1].set_title(f'Focused Spot Size ($f = {f_lens*1000:.0f}$ mm)')473axes[1, 1].grid(True, alpha=0.3)474475plt.tight_layout()476save_plot('beam_quality.pdf', 'Beam quality analysis: effect of $M^2$ on propagation, divergence, brightness, and focusing.')477\end{pycode}478479\section{Optical Resonator Stability}480\begin{pycode}481# Stability of optical resonators482# Stable if 0 <= g1*g2 <= 1, where g = 1 - L/R483484def resonator_stability(g1, g2):485"""Return stability condition."""486return 0 <= g1 * g2 <= 1487488# Create stability diagram489g1_range = np.linspace(-2, 2, 200)490g2_range = np.linspace(-2, 2, 200)491G1, G2 = np.meshgrid(g1_range, g2_range)492493stability = np.logical_and(G1 * G2 >= 0, G1 * G2 <= 1)494495fig, axes = plt.subplots(2, 2, figsize=(10, 8))496497# Plot 1: Stability diagram498axes[0, 0].contourf(G1, G2, stability.astype(int), levels=[0.5, 1.5], colors=['lightblue'])499axes[0, 0].contour(G1, G2, stability.astype(int), levels=[0.5], colors=['blue'], linewidths=2)500501# Mark common resonator types502resonators = {503'Plane-plane': (1, 1),504'Confocal': (0, 0),505'Concentric': (-1, -1),506'Hemispherical': (1, 0),507'Concave-convex': (0.5, 2)508}509510for name, (g1, g2) in resonators.items():511if resonator_stability(g1, g2):512axes[0, 0].plot(g1, g2, 'go', markersize=8)513else:514axes[0, 0].plot(g1, g2, 'rx', markersize=8)515axes[0, 0].annotate(name, (g1, g2), xytext=(5, 5), textcoords='offset points', fontsize=8)516517axes[0, 0].set_xlabel('$g_1 = 1 - L/R_1$')518axes[0, 0].set_ylabel('$g_2 = 1 - L/R_2$')519axes[0, 0].set_title('Resonator Stability Diagram')520axes[0, 0].grid(True, alpha=0.3)521axes[0, 0].set_xlim([-2, 2])522axes[0, 0].set_ylim([-2, 2])523524# Plot 2: Mode waist in symmetric resonator525L = 0.5 # Cavity length (m)526R_range = np.linspace(0.3, 2, 100) # Mirror ROC (m)527g = 1 - L / R_range528529# Waist for symmetric resonator530w0_cavity = np.sqrt(wavelength * L / np.pi) * ((1 - g**2)**0.25 / np.sqrt(2 * (1 - g)))531w0_cavity = np.where(np.abs(g) < 1, w0_cavity, np.nan)532533axes[0, 1].plot(R_range*1000, w0_cavity*1e3, 'b-', linewidth=2)534axes[0, 1].axvline(x=L*1000, color='gray', linestyle='--', alpha=0.7, label=f'$R = L$ (confocal)')535axes[0, 1].set_xlabel('Mirror ROC (mm)')536axes[0, 1].set_ylabel('Mode waist (mm)')537axes[0, 1].set_title(f'Cavity Mode Waist ($L = {L*1000:.0f}$ mm)')538axes[0, 1].legend()539axes[0, 1].grid(True, alpha=0.3)540541# Plot 3: Mode at mirrors for symmetric resonator542w_mirror = np.sqrt(wavelength * L / np.pi) * (1 / (1 - g**2)**0.25)543w_mirror = np.where(np.abs(g) < 1, w_mirror, np.nan)544545axes[1, 0].plot(R_range*1000, w_mirror*1e3, 'r-', linewidth=2)546axes[1, 0].axvline(x=L*1000, color='gray', linestyle='--', alpha=0.7)547axes[1, 0].set_xlabel('Mirror ROC (mm)')548axes[1, 0].set_ylabel('Mode size at mirror (mm)')549axes[1, 0].set_title('Mode Size at Mirrors')550axes[1, 0].grid(True, alpha=0.3)551552# Plot 4: Free spectral range and finesse553FSR = 3e8 / (2 * L) # Free spectral range (Hz)554reflectivities = np.linspace(0.9, 0.999, 100)555finesse = np.pi * np.sqrt(reflectivities) / (1 - reflectivities)556557axes[1, 1].semilogy(reflectivities * 100, finesse, 'g-', linewidth=2)558axes[1, 1].set_xlabel('Mirror reflectivity (\\%)')559axes[1, 1].set_ylabel('Finesse')560axes[1, 1].set_title(f'Cavity Finesse (FSR = {FSR/1e9:.1f} GHz)')561axes[1, 1].grid(True, alpha=0.3, which='both')562563plt.tight_layout()564save_plot('resonator_stability.pdf', 'Optical resonator analysis: stability diagram, mode sizes, and cavity finesse.')565\end{pycode}566567\section{Results Summary}568\begin{pycode}569# Generate results table570print(r'\begin{table}[htbp]')571print(r'\centering')572print(r'\caption{Summary of Gaussian Beam Parameters}')573print(r'\begin{tabular}{lll}')574print(r'\toprule')575print(r'Parameter & Symbol & Value \\')576print(r'\midrule')577print(f'Wavelength & $\\lambda$ & {wavelength*1e9:.0f} nm \\\\')578print(f'Beam waist & $w_0$ & {w0*1e6:.0f} $\\mu$m \\\\')579print(f'Rayleigh range & $z_R$ & {z_R*1000:.2f} mm \\\\')580print(f'Divergence half-angle & $\\theta$ & {np.rad2deg(theta_div):.4f}$^\\circ$ \\\\')581print(f'Depth of focus & $2z_R$ & {depth_of_focus*1000:.2f} mm \\\\')582print(f'Beam quality factor & $M^2$ & {M2:.1f} \\\\')583print(r'\midrule')584print(f'Input waist (focusing) & $w_{{0,in}}$ & {w0_input*1e3:.0f} mm \\\\')585print(f'Focal length & $f$ & {f*1000:.0f} mm \\\\')586print(f'Focused spot size & $w_{{0,focus}}$ & {w0_focused_theory*1e6:.1f} $\\mu$m \\\\')587print(f'Focused Rayleigh range & $z_{{R,focus}}$ & {z_R_focused*1e6:.1f} $\\mu$m \\\\')588print(r'\bottomrule')589print(r'\end{tabular}')590print(r'\end{table}')591\end{pycode}592593\section{Statistical Summary}594\begin{itemize}595\item \textbf{Wavelength}: $\lambda = $ \py{f"{wavelength*1e9:.0f}"} nm596\item \textbf{Beam waist}: $w_0 = $ \py{f"{w0*1e6:.0f}"} $\mu$m597\item \textbf{Rayleigh range}: $z_R = $ \py{f"{z_R*1000:.2f}"} mm598\item \textbf{Divergence half-angle}: $\theta = $ \py{f"{np.rad2deg(theta_div)*1000:.2f}"} mrad599\item \textbf{Depth of focus}: $2z_R = $ \py{f"{depth_of_focus*1000:.2f}"} mm600\item \textbf{Power in $1/e^2$ radius}: 86.5\%601\item \textbf{Focused spot (diffraction limit)}: $w_0' = $ \py{f"{w0_focused_theory*1e6:.1f}"} $\mu$m602\item \textbf{Confocal cavity FSR}: \py{f"{FSR/1e9:.1f}"} GHz603\end{itemize}604605\section{Conclusion}606Gaussian beam propagation is characterized by the Rayleigh range $z_R$, where the beam width increases by $\sqrt{2}$. The product $w_0 \cdot \theta = \lambda/\pi$ is minimum for an ideal Gaussian beam, representing the diffraction limit. Understanding beam propagation is essential for optical system design, including laser focusing, fiber coupling, and resonator mode analysis. The ABCD matrix formalism provides a powerful tool for analyzing complex optical systems. Higher-order Hermite-Gaussian modes exhibit characteristic multi-lobed intensity patterns and are important in resonator analysis and mode-selective applications.607608\end{document}609610611