Package: beamtrace
Simple ABCD matrix propagator.Main file in this directory is tracer.py.InstallationYou can install usingpipathttps://pypi.org/project/beamtrace/pip install beamtracethen in a python scipy or ipython terminal, import the BeamTrace class by runningimportbeamtracefrombeamtrace.tracerimportBeamTraceor if you have LIGO credentials you can git clone the directory athttps://git.ligo.org/craig-cahillane/beamtraceand runimportsyssys.path.addpath('path/to/this/directory')frombeamtrace.tracerimportBeamTraceDocstringFrom beamtrace/tracer.py, the main class BeamTrace docstring;ClassBeamTraceForverysimplebeamwaistandgouyphasecalculationsinpython.Nofancyoptimizationlikealamode,noniceGUIlikejammt.Justmirrors,lenses,andlengthsaddedinsequence.## Other optionsMATLABalamode:https://github.com/nicolassmith/almJAMMT:http://www.sr.bham.ac.uk/dokuwiki/doku.php?id=geosim:jammtFinesse+pykat:https://git.ligo.org/finesse/pykat## ProcessUseraddsinmirrors,lenses,andspaces*insequentialorder*.UsercomputesthecavityABCDmatrixfromthecomponentsaddedusingcalculate_cavity_ABCD().Ifcavityisstable,findthefundamentaleigenmodeforthebeam(q-parameter)Setthisq-parameterasq_inputbeam.Scanthecavitybeamparmaterusingscan_cavity().## Quick tips1.You*must*haveacomponentbetweenspaces,evenifitisjustaflatlens,flatmirror,orflatrefractionelement.Tryingtoconnecttwospacestogetherdirectlywillresultinanerror.2.Refractioncomponentsonlyhaveaneffectonthebeamifthereisaradiusofcurvaturetothedielectricsurface.Tomodelabeamthroughflatdielectric,youmustincludeaflatlensorflatrefractionatthefrontandbacksurfacesofthedielectric.Seeexamples/flat_dielectric_beam_scan.pyorexamples/curved_dielectric_beam_scan.pyinthebeamtracegitrepository.## Examples### Simple resonatorimportnumpyasnpmy_cav=BeamTrace()# initializes ABCD classmy_cav.add_mirror(1.0)# adds mirror with 1.0 meter radius of curvature at z=0.0 metersmy_cav.add_space(0.5)# adds 0.5 meters of space to cavitymy_cav.add_mirror(1.0)# adds mirror with 1.0 meter radius of curvature at z=0.5 metersmy_cav.calculate_cavity_ABCD()# Finds the cavity round-trip ABCD matrix, tells you if it's stable.  If it is stable, populates the my_cav.q_input parameterzz,ww,gouy,qq=my_cav.scan_cavity(round_trip=True)# Returns propagation distance, beam radius, accumulated gouy phase, and beam q-parameter for the entire cavity, plus the round-tripimportmatplotlib.pyplotaspltfig=my_cav.plot_cavity_scan(round_trip=True,label='Simple Cavity')plt.show()# LIGO arm cavityR1=1934.# mR2=2245.# mL=3994.469# marm_cav=BeamTrace()arm_cav.add_mirror(R1,name='ITMY')arm_cav.add_space(L)arm_cav.add_mirror(R2,name='ETMY')fig=arm_cav.plot_cavity_scan(round_trip=True)plt.show()Simple ABCD matrix calculationsSpace matrix, $L$ is the length of the space and $n$ is the index of refraction$S(L,n) = \begin{bmatrix} 1 & \frac{L}{n} \\ 0 & 1 \end{bmatrix}$Lens, $f$ is the focal length$L(f) = \begin{bmatrix} 1 & 0 \\ -\frac{1}{f} & 1 \end{bmatrix}$Mirror, $R$ is the radius of curvature with index of refraction $n$, same as lens with $f = RoC/2$$M(R) = \begin{bmatrix} 1 & 0 \\ -\frac{2 n}{R} & 1 \end{bmatrix}$Refraction through a surface with radius of curvature $R$, initial index of refraction $n1$, and final index of refraction $n2$:$F(R, n1, n2) = \begin{bmatrix} 1 & 0 \\ \frac{n2 - n1}{n2 R} & \frac{n1}{n2} \end{bmatrix}$Refraction does not need to be considered for flat interfaces if you include the index of refraction in the space matrix $S(L,n)$ above:$S(L,n2) = F(inf, n2, 1.0) S(L, 1.0) F(inf, 1, n2)$Other Options:Finesse + pykatMATLAB alamodeJAMMTReferences:Kogelnik and LiKoji Arai on beam propWikipedia with ABCD matricesStefan SRC gouy phase measSimple ABCD matrix derivations