Jaime, Begum
This is for the ADTR project that aims to generate higher order modes for active PI damping (https://dcc.ligo.org/LIGO-L2400062). The goal of this script is to generate two phase masks to convert a gaussian mode to a higher order mode. I used the code from this paper (https://www.nature.com/articles/s41467-019-09840-4) and this repo (https://github.com/nicolassmith/alm) as a starting point.
The code starts with defining the grid which depends on the chosen pixel count and size as these will vary for different SLM's. Next the gaussian beam and target modes are chosen and the fields are placed in an array. I then defined a padded grid and padded transfer function of free space to avoid wrap-around on the edge of the simulation during the FFT propagation. Finally, I implemented the Gerchberg-Saxton algorithm for generating the phase masks needed to convert the gaussian mode to the desired mode.
Algorithmic workflow:
Forward propagation:
1) Update the first plane's phase mask by computing the local overlap ( dMask = [FwdField*conj(BwdField)]/sqrt(PwrFwdField*PwrBwdField) ), then finding the phase difference between dMask and the current mask ( dPhi = sum(dMask*conj(MASK)) ), and finally completing the update by adding the local overlap into the mask accumulator with a phase correction to ensure constructive interference with current mask ( MSK = MSK + dMask*exp(-i*np.angle(dPhi)) )
2) Apply the mask at the first plane
3) Pad the field (with lossy edges to get rid of numerical reflections from the edges of FoV) and propagate over the plane distance using the padded transfer function of free space
4) Crop the forward field back to original size and store it's values at the second plane
Backward propagation:
1) Update the second plane's phase mask
2) Apply the mask at the second plane
3) Pad the field and propagate backward over the plane distance using the conjugated transfer function of free space
4) Crop the backward field back to original size and store it's values at the first plane
Finally, I plot the masks and beams and calculate the overlap efficiency. Typically, after about 20-30 iterations, we get above 95% overlap between the propagated and target beams. I am attaching an example of calculated phase masks for converting to the LG(7,3) mode and an animation of the beam propagation including a line cut of the amplitude and phase along the x-axis. I also included a beam propagation animation with and without padding for converting to the LG(1,0) mode to illustrate the reduction of wrap-around in the simulation.