LightPipes Optical Toolbox

repository·master·Indexed 43 days ago

https://github.com/opticspy/lightpipes

A toolbox for simulating coherent optical phenomena where diffraction is essential. LightPipes models optical fields using 2D arrays of complex amplitudes to simulate apertures, lenses, beam-splitters, and free-space propagation. It includes specialized functions for generating non-diffracting beams such as Airy beams (via AiryBeam1D and AiryBeam2D), Bessel beams, and Laguerre-Gauss doughnut modes.

Tokens
22.4K
Snippets
66
Records
99
Agent score
55%

What's inside LightPipes

  1. Overview of LightPipes computer experiments

    master

    The LightPipes computer practical provides simulations of real optical problems for educational purposes. These simulations use advanced propagation routines to solve the Fresnel-Kirchhoff integral in two dimensions, providing realistic physical optics modeling.

    How experiments work

    • Interaction: Experiments are performed by changing parameters (such as wavelength, radius, or thickness) and measuring characteristic data, typically using a mouse.
    • Goal: Students are tasked with deriving expressions for unknown parameters based on measurements.
    • Randomization: Each simulation generates a random number to determine the specific parameter to be measured, which is used for verification in reports.
    • Underlying Engine: The simulations utilize the LightPipes optical toolbox for propagation, apertures, lenses, and other optical components.
  2. Determine the constant $c$ for beam propagation

    master

    The constant $c$ is a parameter used in the ABCD matrix formulation to describe beam propagation. It can be determined using two primary methods:

    Method 1: Heisenberg Uncertainty Relation

    Using the uncertainty of impulse and position in the transverse direction, the constant is derived as:

    $$c=\frac{\lambda}{4\sqrt{2}w_0}$$

    Method 2: Physical Optics Comparison

    By comparing geometric results with the physical optics solution for a round beam (where $z_R=\frac{\pi{w_0^2}}{\lambda}$), the constant is found to be:

    $$c=\frac{\lambda}{\pi{\sqrt{2}w_0}}$$

    Note: There may be slight discrepancies between these methods depending on the assumed geometry (e.g., slab vs. cylinder).

  3. Understand the concept of a Fresnel zone plate

    master

    A Fresnel zone plate is a diffractive element composed of concentric rings that alternate between transparent and opaque.

    • Focusing Mechanism: By blocking either the odd or even Fresnel zones, the plate acts as a focusing lens when a plane wave is incident upon it.
    • Imaging: The plate can be configured to function as an imaging element.
    • Resolving Power: The resolving power of a zone plate is determined by the size of its outermost ring ($\Delta r$). The relationship is defined as:

    $$\mathit{w}=\frac{\lambda }{2\sin\theta}=\frac{\lambda }{2}\frac{2\Delta r}{\lambda }=\Delta r$$

    Where $\mathit{w}$ is the resolving power and $\Delta r$ is the width of the outermost ring.

  4. Core Concepts of LightPipes Simulations

    master

    LightPipes models coherent optical devices by operating on a large data structure: a square two-dimensional array of complex amplitudes representing the optical field of a propagating light beam.

    Simulation Workflow

    1. Initialization: Generate an initial field (e.g., a plane wave) using a command like Begin.
    2. Optical Elements: Apply functions that represent physical components like apertures (CircAperture), filters, beam-splitters, or lenses to the field.
    3. Propagation: Use propagation models (e.g., Fresnel) to simulate how the light field travels through free space.
    4. Combination: Combine multiple fields (e.g., after passing through different apertures) using commands like BeamMix.
    5. Analysis: Calculate physical properties like intensity (Intensity) for visualization or measurement.
  5. Use pyFFTW for faster propagation

    master
    LightPipes propagation routines like LightPipes.Fresnel and LightPipes.Forvard can use pyFFTW for improved performance. If pyFFTW is not installed, LightPipes automatically falls back to numpy FFT. You can explicitly control the FFT backend via command options or by modifying the global configuration.
  6. Split and mix beams for interferometry

    master

    To model interferometers like Young's interferometer, you can split a field structure using IntAttenuator (which performs amplitude division) and then recombine the resulting fields using BeamMix. This allows you to process two separate beams (e.g., beams with different hole positions) and then mix them to observe interference patterns.

    # Conceptual workflow for an interferometer
    # 1. Split the field
    field1, field2 = IntAttenuator(field, ...)
    
    # 2. Process fields separately (e.g., shift holes)
    # ...
    
    # 3. Mix the beams
    mixed_field = BeamMix(field1, field2)
  7. Use spherical coordinates for efficient lens propagation

    master

    When modeling diffraction to a focal point, using a standard rectangular coordinate system with Lens followed by Fresnel can be computationally expensive, requiring very large grids.

    Instead, use a 'floating' spherical coordinate system. This involves using a weak phase mask with Lens and a strong geometrical coordinate transform with LensFresnel. This method results in a much smaller grid and faster execution.

    Workflow:

    1. Apply a weak lens: Lens(f1, 0, 0, F)
    2. Apply spherical propagation: LensFresnel(f2, f, F2) (where f2 is the bending parameter and f is the propagation distance).
    3. Convert back to rectangular coordinates: Convert(F2).

    Note: Avoid calling LensForvard or LensFresnel with parameters that result in a zero-size grid (e.g., at the exact geometrical focal point), as this will cause a floating-point exception.

    # Example: Spherical coordinate method for diffraction to focus
    labda=1000*nm;
    size=10*mm;
    f=100*cm
    w=5*mm;
    f1=10*m
    f2=f1*f/(f1-f)
    frac=f/f1
    newsize=frac*size
    
    F=Begin(size,labda,N);
    F=RectAperture(w,w,0,0,0,F);
    F2=Lens(f1,0,0,F);
    F2=LensFresnel(f2,f,F2);
    F2=Convert(F2);
    phi2=Phase(F2);phi2=PhaseUnwrap(phi2)
    I2=Intensity(0,F2);
  8. Generate Bessel beams

    master

    Bessel beams are non-diffracting beams that maintain a narrow focus over large distances. There are several ways to generate them using LightPipes:

    1. Using an Axicon: Convert a laser beam into a Bessel beam using an axicon lens.
    2. Using an Annular Slit and Lens: Combine an annular slit with a positive lens or concave mirror.
    3. Using a Poisson Spot: Illuminate a circular disk with a plane monochromatic beam. If the disk is positioned at the primary focus of a positive lens, the waves from the edge of the disk will be collimated, resulting in a non-diffracting Bessel beam.
  9. Describe ray propagation using ABCD matrices

    master

    In the paraxial approximation (small angles), a periodic system like a laser resonator can be described using a 1-pass propagation matrix $\mathbf{M} = \begin{bmatrix} A & B \ C & D \end{bmatrix}$.

    A ray is defined by its position $y$ and angle $\theta$ as a vector $\mathbf{R} = \begin{bmatrix} y \ \theta \end{bmatrix}$.

    Propagation through the system is calculated by matrix multiplication:

    • After 1 roundtrip: $\mathbf{R_1} = \mathbf{M} \mathbf{R_0}$
    • After $n$ roundtrips: $\mathbf{R_n} = \mathbf{M}^n \mathbf{R_0}$

    For any physical system, the determinant of the ABCD matrix must be 1 ($AD - BC = 1$) due to the principle of ray reversibility.

    # Conceptual representation of ray propagation
    # R_n = M^n * R_0
    import numpy as np
    
    M = np.array([[A, B], [C, D]])
    R0 = np.array([y0, theta0])
    R_n = np.linalg.matrix_power(M, n) @ R0
  10. Understand the transition from Poisson spot to Bessel beam

    master

    When a monochromatic plane wave illuminates a disk (annular slit), the waves originating from the edges act as in-phase spherical waves. These waves interfere constructively to create a Poisson spot (also known as an Arago spot) near the optical axis.

    Under certain conditions, this interference pattern can be modeled as a non-diffractive Bessel beam. The intensity distribution near the axis is approximately described by the squared zeroth-order Bessel function of the first kind:

    I(r,z) ≈ I₀ J₀²( (2παr) / λ )

    Where:

    • α = a/r is the angle of the wavefront near the axis.
    • 2a is the diameter of the disk.
    • λ is the wavelength.
    • r is the radial distance from the axis.
    • z is the propagation distance.

    The beam width w(z) is proportional to the distance z and is given by:

    w(z) = (2.44 / π) * (λz / a)

  11. Memory considerations for field structures

    master

    Field structures in LightPipes are two-dimensional arrays of complex numbers. Memory usage scales with the grid dimension:

    • 256 x 256: ~1 MB
    • 512 x 512: > 4 MB
    • 1024 x 1024: ~16 MB

    While common PCs and laptops can handle grids up to 2000 x 2000 points, be aware that some commands require additional internal arrays, which increases the total memory footprint.

  12. Calculate image properties using the lens formula (Level 2)

    master

    For higher precision (secondary education, HBO, or university level), use mathematical formulas to predict image distance and magnification instead of graphical ray tracing.

    The Lens Formula

    To find the image distance ($b$) given the object distance ($v$) and focal length ($f$): $$\frac{1}{v} + \frac{1}{b} = \frac{1}{f}$$

    Alternatively, to plot a linear graph ($y = ax + b$): $$\frac{1}{b} = -\frac{1}{v} + \frac{1}{f}$$ In this form, the slope $a = -1$ and the y-intercept is $\frac{1}{f}$.

    Magnification Formula

    To find the magnification ($V$): $$V = -\frac{b}{v}$$

    To plot a linear graph for magnification, plot $\frac{1}{V}$ against $v$ using the derived formula: $$\frac{1}{V} = -\frac{1}{f}v + 1$$

    Variable Definitions

    • $v$: Object distance (distance from slide to lens).
    • $b$: Image distance (distance from lens to screen).
    • $f$: Focal length of the lens.
    • $V$: Magnification (ratio of image size to object size). Note: The negative sign indicates the image is inverted.