****************************** Tutorial 2 - General 1D cavity ****************************** In this part we see how to define a general cavity system using a more general method: ABCD matrices, this is a more general and powerful way to define multi-elements cavity with different arrangements (V-shaped, bow-tie...etc), and it is the preferable way of defining optical cavities in OpenCavity. In this tutorial we show three ways of defining a general optical cavity using the function ``build_1D_cav_ABCD(a,npts,A,B,C,D)``. You may wonder why learn 3 ways when we can just getting things done by learning one method and stick with it?. The reason is that every one of the three techniques we show here, is best suited for some particular situations, as we will see in next tutorials. These three ways of defining a general cavity design we address here are: - Using the global ABCD matrix of the cavity. - Using g1,g2 parameters of the cavity. - Using phase masks and cascading subsystems System definition using ABCD matrices ===================================== Let’s start now and take the same cavity system of the previous tutorial. This simple two-mirrors linear resonator (radius of curvature R1 and R2) represented below is equivalent to a periodic sequence made of two thin lenses with focal lengths equal to f1 (=R1/2) and f2 (=R2/2), spaced by a distance Lc. .. image:: _static/Optical_cavity_lens.png The T transfer matrix of such a system is .. math:: \begin{bmatrix} A & B \\ C & D \end{bmatrix}= \begin{bmatrix} 1 & 0 \\ -2/R1 & 1 \end{bmatrix} \times \begin{bmatrix} 1 & Lc \\ 0 & 1 \end{bmatrix} \times \begin{bmatrix} 1 & 0 \\ -2/R2 & 1 \end{bmatrix} \times \begin{bmatrix} 1 & Lc \\ 0 & 1 \end{bmatrix} Defining this system is quite straightforward , all what we have to do for now is calculating the global matrix. .. ipython:: In [1]: import opencavity.modesolver as ms; #importing the opencavity module In [2]: R1=1e13; R2=10*1e3; Lc=8*1e3; npts=120; a=150; # cavity parameters In [3]: A1=1; B1=0; C1=-2/R1; D1=1; #concave mirror M1 In [4]: A2=1; B2=Lc; C2=0; D2=1; #propagation distance Lc In [5]: A3=1; B3=0; C3=-2/R2; D3=1; #concave mirror M2 In [6]: A4=1; B4=Lc; C4=0; D4=1; #propagation distance Lc Making the matrices using ``numerical python``:``np`` , note here that we use numerical python from inside imported ``opencavity`` module that we called ``ms``, this is possible because ``numerical python`` or ``numpy`` is already imported inside ``opencavity``, but importing it again at the beginning of the script will work too as we did in other tutorials. The same holds for ``matplotlib`` module imported as ``plt`` in ``opencavity``. .. ipython:: In [7]: M1=ms.np.array([[A1,B1 ],[C1, D1]]); In [8]: M2=ms.np.array([[A2, B2],[C2, D2]]); In [9]: M3=ms.np.array([[A3, B3],[C3, D3]]); In [4]: M4=ms.np.array([[A4, B4],[C4, D4]]); Calculating the dot product (matrix of the global system) .. ipython:: In [10]: M=M4.dot(M3).dot(M2).dot(M1) # calculating the global matrix (note the inversed order) Till now we haven't use the OpenCavity package yet and we haven't done any mode calculation, all what we did is some matrix manipulation to create the ABCD matrix of the cavity. Let's get the elements of this matrix and enter them into a *solver* system, we call it *opsys* (for optical system) .. ipython:: In [11]: A=M[0,0]; B=M[0,1]; C=M[1,0]; D=M[1,1] In [12]: opsys=ms.CavEigenSys() #creating a ms object In [13]: opsys.build_1D_cav_ABCD(a,npts,A,B,C,D) # enter the ABCD matrix and build the system-Kerenl to find and show the modes of the cavity .. ipython:: In [14]: opsys.solve_modes() # by default find the 30 first modes @savefig tuto2_plot_mode0_E_1D.png width=4in In [15]: opsys.show_mode(0) # the fundamental mode E-field @savefig tuto2_plot_mode2_I_1D.png width=4in In [15]: opsys.show_mode(2,what='intensity') @savefig tuto2_plot_mode0_P_1D.png width=4in In [15]: opsys.show_mode(0,what='phase') voilà! these figures show the E-field of the fundamental mode and the intensity of the 2nd one. The third figure shows the phase of the fundamental mode. The cleaned code ================ .. literalinclude:: tuto_source/tuto_2_1D_ABCD_2mirrors.py .. _tuto2-using-g1g2-label System definition using g1, g2 parameters ========================================= g1 and g2 parameters are usually used to study the stability of resonators, they are defined as `g1=1-Lc/R1, g2=1-Lc/R2`. the resonator is sable if 0