From b168bb08f7cebf5eb6d58fb6662e94f57aa1cc84 Mon Sep 17 00:00:00 2001 From: Eugeniy Mikhailov Date: Fri, 27 Sep 2013 10:50:11 -0400 Subject: bug fixes and improvements in cavity design handling --- cavity_design_demo.m | 60 +++++++++++++++++++++++++++++----------------------- 1 file changed, 33 insertions(+), 27 deletions(-) (limited to 'cavity_design_demo.m') diff --git a/cavity_design_demo.m b/cavity_design_demo.m index 7bddf35..1108f11 100644 --- a/cavity_design_demo.m +++ b/cavity_design_demo.m @@ -15,8 +15,8 @@ % let's set some parameters R1=0.8; -R2=1; -d1=3; +R2=Inf; +d1=0.2; d2=1; Ltot = d1+d2; % total resonator length @@ -29,13 +29,6 @@ lambda = 795e-9; abcd_cavity = abcd_mirror(R2)*abcd_free_space(d2)*abcd_mirror(R1)* abcd_free_space(d1); -% spelling out abcd coefficients -A = abcd_cavity(1,1); -B = abcd_cavity(1,2); -C = abcd_cavity(2,1); -D = abcd_cavity(2,2); - - if ~isCavityStable(abcd_cavity) display('Cavity is unstable !'); display('We should stop now. There is no stable mode in this cavity'); @@ -44,23 +37,23 @@ end display('Cavity is stable'); -% stability parameter see eq.4 -u = (A+D+2)/4; +zstart = 0; +qstart = abcd2self_repeating_q( abcd_cavity ); -% resonator waist eq.10 -w0 = sqrt ( 2*lambda/(pi*abs(C))*sqrt(u*(1-u)) ); +zfinal = Ltot; +qfinal = q_after_abcd( qstart, abcd_cavity ); -% resonator waist location along 1st arm eq.11 -z0 = (A-D)/(2*C); -% Everything is periodic with respect to cavity length -% so by taking modulus with respect to its length -% we get rid of nasty virtual waist condition -z0 = mod(z0,Ltot); +eps = 1e-8; % typical round of error +if ( abs( q2wr(qstart, lambda ) - q2wr(qfinal, lambda) ) > eps ) + % We should never be here if above functions do their job correctly + display(qstart); + display(qfinal); + error('The calculation is incorrect: resonator mode sizes do not match at the beginning and the end. Go fix the code.'); +end -% naturally the Gaussian beam curvature radius is huge i.e. wavefront is flat -q0=wr2q(w0, inf, lambda); %Calculate initial q +%% Preparing for the graphical mode output % time to build the optics set mirror1.abcd = abcd_mirror( R1 ) ; mirror1.x = d1; @@ -75,11 +68,24 @@ show_lens_position = 1; %Set to 1 to enable display of position of center of len display_prop = [show_lens_width, show_lens_position]; -zstart = 0; -qstart = gbeam_propagation(zstart, q0, z0, optics); -zfinal = Ltot; -qfinal = gbeam_propagation(zfinal, q0, z0, optics); - % show beam in the resonator -[waste_at_the_end, radius_at_the_end, waist_at_mirrors] = solution_visualization(qstart,zstart, qfinal, zfinal, optics, lambda, lens_width, display_prop) +[waste_at_the_end, radius_at_the_end, waist_at_mirrors] = solution_visualization(qstart,zstart, qfinal, zfinal, optics, lambda, lens_width, display_prop); + +waist_at_mirrors + +display('Presumed size and location of the cavity waist'); +[w0, z0] = cavity_abcd2its_waist_and_position( abcd_cavity, lambda, Ltot ) + +q0_via_propagation = gbeam_propagation ( z0, qstart, zstart, optics ); +[w0prop, R0prop] = q2wr(q0_via_propagation, lambda); + +% we expect R0prop to be infinite since it is focused point +% w0prop should match w0 + +if ( abs( w0 - w0prop ) > eps ) + % We should never be here if above functions do their job correctly + display(w0prop); + error('Different methods to calculate focused point parameters do not match'); +end + -- cgit v1.2.3