Example:

```
G1 = Grid(256,0.4);
IM1 = Interface(G1,'RoC',1420,'CA',0.33,'T',0.014);
Offset_X = 0.01;
Offset_Y = 0.03;
IM1.mask = circshift(IM1.mask,[round(-Offset_Y/G1.Step), round(Offset_X/G1.Step)]);
imagesc(G1.Axis,G1.Axis,(IM1.surface-5E-6).*IM1.mask); axis square; colormap gray
```

]]>First example, calculation of the steady state high finesse cavity.

Grid size | Calculation time on the CPU | Calculation time on the GPU |
---|---|---|

1024 x 1024 | 1 | 0.34 |

512 x 512 | 0.18 | 0.04 |

256 x 256 | 0.08 | 0.02 |

Second example, calculation time for a cavity FSR scan. To be noted, this procedure has been particularly optimised for the GPU, see this article.

Calculation time on the CPU | Calculation time on the GPU |
---|---|

1 | 0.06 |

The second idea would be to decrease the accuracy, a number which determines when we estimate that we have converged to the steady state field. It could be changed as an option to the function using the accelerated converge:

`C1 = Calculate_Fields_AC(C1,'accuracy',1E-10);`

With C1 an object of class Cavity 1. By default the accuracy is set to 1E-12. Below an empirical table to show the impact of this parameter and the speed gain for a cavity of finesse 30 000 with mirror maps and substantial clipping loss (RTL).

Accuracy | Cavity gain | RTL [ppm] | Gain speed |
---|---|---|---|

1E-12 | 5496.9 | 179.44 | 1 |

1E-10 | 5493.4 | 179.44 | 1.6 |

1E-8 | 5480.1 | 179.44 | 2.8 |

1E-6 | 5336.9 | 179.43 | 6.1 |

1E-4 | 5011.7 | 179.44 | 33 |

As we can see from the table, the RTL is pretty robust to the accuracy, whereas the cavity gain is more sensitive dropping by 3% when the accuracy is reduced from 1E-12 to 1E-6.

A third option, more obvious is to reduce the grid size. It has the direct drawback to cut part of the highest spatial frequencies of the surface maps. Here an example of possible gain with the same cavity:

Grid dimension | Cavity gain | RTL [ppm] | Gain speed |
---|---|---|---|

1064 x 1064 | 5478.5 | 180.0 | 1 |

512 x 512 | 5493.4 | 179.4 | 5.7 |

256 x 256 | 5484.0 | 179.8 | 13.6 |

128 x 128 | 5551.5 | 177.4 | 76 |

In a next post, we will explore the benefits of running the code on the GPU.

]]>Then go to the OSCAR Gitlab page and at the bottom of the readme file, you will find a button named Open in MATLAB Online:

It should open directly a Matlab window in your browser with git repository installed:

Then one can navigate in the folder examples and run them with the green arrow on top:

Et voilĂ !

(to be transparent you only have a monthly free number of calculation hours with Matlab online but it is still an amazing product)

The advantage of the ABCD matrix is to propose very quick calculations to validate a design (or confirm we have entered the right parameters). For example, with an object of class Cavity1, the ABCD matrix of the cavity round trip will automatically be calculated. So we can derive the beam parameters on the input mirror as well as the beam size evolution or the accumulated Gouy phase during the propagation over one cavity length:

Those results will be available with function Check_Stability()

]]>`C1 = Cavity_Scan(C1);`

Display_Scan(C1);

However one may want to also record the reflected power. One way to do that would be to scan the cavity manually setting a different round trip phase for each iteration. Concretely, once the cavity C1 is defined it looks like:

```
C1 = Cavity1(IM,EM,1000,E_input); % the cavity is misaligned and not well matched to the input beam
C1 = Cavity_Resonance_Phase(C1); % will be overwritten later
Nb_point = 400; % Number of points for the scan
Phase_scan = zeros(Nb_point,1);
Power_transmitted = zeros(Nb_point,1);
Power_reflected = zeros(Nb_point,1);
for ii=1:Nb_point
Phase_scan(ii) = ii*(2*pi)/Nb_point; % Scan the round trip phase shift from 0 to 2 pi
C1.Resonance_phase = exp(1i*Phase_scan(ii)); % Set the round trip phase shift for the cavity
C1 = Calculate_Fields_AC(C1,'accuracy',1E-5);
Power_transmitted(ii) = Calculate_Power(C1.Field_trans); % store the transmitted power
Power_reflected(ii) = Calculate_Power(C1.Field_ref); % and also the reflected one
end
```

And we can then plot the transmitted power (top plot) and the reflected power (bottom one):

The technique presented here could also be used to only display a certain sideband during a scan (or an arbitrary sum of sidebands).

]]>For large Radii of Curvature (RoC >> size of the grid), it is possible to input directly an astigmatic surface. For example in the following code we define a RoC of 998m in X and 1002 in Y for the *Interfac*e EM_HR:

```
EM_HR = Interface(G1,'RoC',inf,'T',5E-6);
Astigma_RoC = 2;
RoC_X = -1000 - Astigma_RoC;
RoC_Y = -1000 + Astigma_RoC;
EM_HR.surface = (1/(2*RoC_X)*G1.D2_X.^2 + 1/(2*RoC_Y)*G1.D2_Y.^2); % G1 is the simulation grid, could be found also from EM_HR.Grid
```

If someone has the universal formula for parabolic mirrors, with no approximation I am interested.

]]>```
G1 = Grid(512,0.16);
E1 = E_Field(G1,'w0',0.01);
E2 = E1;
Offset_X = 0.01;
Offset_Y = 0.03;
E2.Field = circshift(E2.Field,[round(Offset_Y/G1.Step), round(Offset_X/G1.Step)]);
figure(1); E_Plot(E1)
figure(2); E_Plot(E2)
```

**Be sure to have a large enough grid to not clip the Gaussian beam.** The function circshift() will not clip the beam but rather shift the pixels to the other side of the grid. It is wise to always visually check the results by displaying the beam.

```
G1 = Grid(512,0.4);
E_input = E_Field(G1,'w',0.02,'R',-300);
```

We can now choose to display the waist of the beam:

```
Fit_TEM00(E_input,'Output','W_P') % the output in the command window will be:
Beam waist [m]: 0.00492386 Position of the waist [m]: -281.817
```

A negative waist position indicates the beam is focusing and so as we propagate the beam will be reduced in size. It is all possible to display all the parameters:

```
Fit_TEM00(E_input,'Output','all') % the output is now:
Beam radius [m]: 0.02 Wavefront curvature [m]: -300
Beam waist [m]: 0.00492386 Position of the waist [m]: -281.817
```

Let’s check that the size and position is correct:

```
Fit_TEM00(Propagate_E(E_input,281.82)) % and the answer is:
Beam radius [m]: 0.00492386 Wavefront curvature [m]: 1.55193e+06
```

All good! it is also possible to save values in variables (and suppress the output):

`[w,R,w0,Pos] = Fit_TEM00(E_input);`

The updated function is available in the git folder, master branch: here.

]]>The function attached calculates the Gouy phase of a TEM00 beam for a propagation length defined by the user. The principle behind it is to calculate the phase of the field and subtract the phase of the corresponding plane wave.

The example script shows how to use the function. From the output of the function is possible to plot the evolution of the Gouy phase as shown in the following picture

The waist size and position can be calculated from the Gouy phase plot, which is suppose to be symmetric respect to it. In the example the expected waist size and position is calculated with Matlab interpolation function. The results is then compared to the values obtained from the OSCAR Fit_TEM00 function

Through the Fit_TEM00 function is also possible to see how the beam size change in the propagation

So far the function works well only for the TEM00 mode. However we plan to adjust it in order to make it work also for arbitrary beams (i.e. HOM).

]]>