Code block to create optical phase tilt/wedge requested

6 views (last 30 days)
Hi All,
For starters, I am not a Fourier optics guru, nor do I pretend to be one. I have a situation where I'm hoping a small block of code from the community can solve my current issue.
I'm propagating an optical electric field through free space and encounter a media with refractive index n (n is actually spatially varying in 2D) at an angle (the input facet of the media is not normal to the direction of the electric field propagation). Inside of the medium, I want to use my normal FFT algorithm to propagate the beam and have the beam tilt applied without any special modifications. I've currently cheated so far by simply propagating to the geometric center of the interface and then applying a phase shift in the appropriate direction INTERNALLY to the media for each propagation step inside of the media to translate the electric field. I've reached the limits of the usefulness of this approximation.
I'm looking for a block of code that will add the appropriate phase shift/tilt to the optical electric fields when the interface is at an arbitrary angle "theta" and has an refractive index n that is not constant, but the perturbations to n are quite small. The tilt only needs to be in 1D to start, but those brave enough to show-off a bit are encouraged to provide a general code block for phase shifts/tilts in both principal planes.
My final potential request is that the spatial frequency grid should not change. I'm trying to avoid methods that involve nuffts and rotation of the plane in spatial frequency space, as this would require all sorts of unpleasant modifications to the rest of my current code, on top of the fact that some of the electric fields (in the cavity) may never return to a previous k-vector direction with respect to the media with refractive n tilted at an angle theta. That is, the angle theta may actively change, and I don't (currently) analyze the Zernike polynomials to get the tilts of the electric fields when they hit the media with refractive index n and angle theta.
As a working example, the math I use for free space diffraction is as follows: k=2*pi*1e6/lambda; H = exp(-i.*dz*((sx.^2 + sy.^2)./(2*k))); E=fftshift(ifft2(fft2(ifftshift(E)).*fftshift(H))). My grid is usually 256x256 points, 10x10 mm, and UV/visible wavelengths. I'm aware my grid point area is much larger than normal, but it works very well for my application.
Any and all help is appreciated, thanks in advance!

Answers (1)

Umar
Umar on 11 Dec 2024

Hi @Robert Stegeman,

To address your query effectively, you need to incorporate the necessary mathematical principles that govern wave propagation in media with varying refractive indices and implement them into a suitable code block. Given your requirements, you need to create a code snippet that applies phase shifts due to refraction without altering the spatial frequency grid. When light propagates through a medium with a refractive index (n(x,y)) at an angle \( theta), the wave vector mathbf{k} can be described as:

   [mathbf{k} = frac{2\pi}{\lambda} \begin{pmatrix} n_x \\ n_y \\ n_z 
   \end{pmatrix}]

Where (n_x) and (n_y) are influenced by the angle of incidence. The phase shift introduced by the refractive index can be expressed as:

[Delta \phi(x,y) = -frac{2\pi}{\lambda} (n(x,y) - 1) d]

Here, (d) is the distance traveled within the medium. The electric field can be modified as follows:

1. Compute the phase shift based on the varying refractive index. 2. Apply this phase shift to the electric field in each propagation step.

Below is an example MATLAB code snippet that demonstrates how to propagate an electric field through a medium with a spatially varying refractive index while maintaining a constant spatial frequency grid.

% Parameters
lambda = 500e-9; % Wavelength in meters (e.g., 500 nm)
dx = 10e-5; % Grid point size in meters
dz = 1e-3; % Propagation distance in meters
grid_size = 256; % Size of the grid
n0 = 1.0; % Refractive index outside the medium
theta = pi/4; % Angle of incidence in radians
% Spatial frequency grid
fx = (-grid_size/2:grid_size/2-1)/(grid_size*dx);
fy = (-grid_size/2:grid_size/2-1)/(grid_size*dx);
[FX, FY] = meshgrid(fx, fy);
% Example synthetic data for electric field E
E = rand(grid_size) + 1i*rand(grid_size); % Random complex field
% Define spatially varying refractive index (small perturbations)
n_variation = 0.01 * rand(grid_size); % Example variation
n = n0 + n_variation;
% Compute wavenumber
k = 2*pi/lambda;
% Create transfer function for free space propagation
H = exp(-1i * dz * ((n0 * FX * cos(theta)) + (n0 * FY * sin(theta))).^2 / (2*k));
% Apply FFT-based propagation with phase correction
E_propagated = fftshift(ifft2(fft2(ifftshift(E)) .* fftshift(H)));
% Apply phase shift due to varying refractive index
for ix = 1:grid_size
  for iy = 1:grid_size
      phase_shift = exp(-1i * (n(ix, iy) - n0) * k * dz);
      E_propagated(ix, iy) = E_propagated(ix, iy) * phase_shift;
  end
end
% Final results visualization
figure;
imagesc(abs(E_propagated)); 
colorbar;
title('Magnitude of Propagated Electric Field');
xlabel('X Position');
ylabel('Y Position');

Please see attached.

Here are some further additional insights to help you further.

Phase Shift Calculation: The code calculates a phase shift based on both the incident angle and the local refractive index at each grid point. This approach preserves the spatial frequency characteristics without requiring extensive changes to your existing framework.

Optimization: For larger grids or more complex variations of \( n(x,y) \), consider vectorizing operations to enhance performance. MATLAB’s built-in functions are generally optimized for matrix operations.

Validation: It is crucial to validate this method against known solutions or experimental data to ensure accuracy, particularly when dealing with small perturbations in refractive indices.

Further Generalization: If you later decide to extend this approach into two principal planes or non-linear variations of n(x,y) similar principles can be applied while adjusting the phase shift calculations accordingly.

This implementation should serve as a robust starting point for your optical simulations while adhering to your constraints regarding spatial frequency grids and minimal modifications to existing code structures.

Hope this helps.

Categories

Find more on Accelerators & Beams in Help Center and File Exchange

Products


Release

R2024b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!