diff options
-rw-r--r-- | cavity_optics2its_waist_and_position.m | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/cavity_optics2its_waist_and_position.m b/cavity_optics2its_waist_and_position.m new file mode 100644 index 0000000..360f8c1 --- /dev/null +++ b/cavity_optics2its_waist_and_position.m @@ -0,0 +1,41 @@ +function [w0, z0] = cavity_optics2its_waist_and_position( cavity_optics, lambda ) + +abcd_cavity = optics2abcd( cavity_optics ); +cavity_length = cavity_optics{end}.x; +N=length(cavity_optics); + +if ~isCavityStable(abcd_cavity) + display('Cavity is unstable !'); + display('We should stop now. There is no stable mode in this cavity'); + error('Not possible to calculate a cavity mode in the unstable cavity'); +end + +zstart = 0; +qstart = abcd2self_repeating_q( abcd_cavity ); + +% waist location of this particular Gaussian beam +% which disregards other optical elements +z0 = - real (qstart); + +i = 1; +if ( (z0 > cavity_optics{1}.x) || (z0 < 0) ) + % waist is to the left of the cavity or beyond first reflective/refractive element + % we need to swap cavity elements by one + % in attempt to find waist in between optics elements + x1 = cavity_optics{i}.x; + for i=2:N + cavity_optics_transpose{i-1} = cavity_optics{ i }; + cavity_optics_transpose{i-1}.x = cavity_optics{ i }.x - x1; + end + cavity_optics_transpose{N} = cavity_optics{1}; + cavity_optics_transpose{N}.x = cavity_length; + [w0, z0] = cavity_optics2its_waist_and_position( cavity_optics_transpose, lambda ); + z0 = cavity_optics{1}.x + z0; +else + q0 = gbeam_propagation ( z0, qstart, zstart, cavity_optics ); + [w0, r0 ] = q2wr( q0, lambda ); +end + + +end + |