diff options
author | Eugeniy Mikhailov <evgmik@gmail.com> | 2011-04-13 18:22:48 -0400 |
---|---|---|
committer | Eugeniy Mikhailov <evgmik@gmail.com> | 2011-04-13 18:22:48 -0400 |
commit | a70fb91882267fc65ca8ab2de019a45a02f5883b (patch) | |
tree | f1056b17e67847107be4a5d82e24afe32dc0f792 | |
parent | d633bca9a5fe49e2f425e22f0c226eb4d32db5c7 (diff) | |
download | mode_match-a70fb91882267fc65ca8ab2de019a45a02f5883b.tar.gz mode_match-a70fb91882267fc65ca8ab2de019a45a02f5883b.zip |
added test cases and special case of starting point coinsiding with optics element
Ignore-this: ad4d37134d562280bf9293a14935c585
darcs-hash:20110413222248-067c0-90b83cde89a90fc65c0f6b129d637838734f0195
-rw-r--r-- | gbeam_propagation.m | 32 | ||||
-rw-r--r-- | gbeam_propagation_froward_only.m | 24 |
2 files changed, 56 insertions, 0 deletions
diff --git a/gbeam_propagation.m b/gbeam_propagation.m index 524d4ae..cd7c47c 100644 --- a/gbeam_propagation.m +++ b/gbeam_propagation.m @@ -26,8 +26,16 @@ function q = gbeam_propagation(x_pos, q_in, x_in, optics_elements) % we need to flip all optics elements around x_in as well for i=1:length(optics_elements_backw) optics_elements_backw{i}.x=x_in-optics_elements_backw{i}.x; + % there is a tricky case: if position of any optics element coincides + % with x_in i.e it is 0 in backwards x coordinates (or at index 1) then + % we need to apply abcd matrix of that element in advance. + if ( optics_elements_backw{i}.x == 0) + q_in_backw(1) = q_afteer_element( q_in_backw(1), optics_elements_backw{i}.abcd); + end + end + q_backw = gbeam_propagation_froward_only(x_backw, q_in_backw, 0, optics_elements_backw); % now we need to flip the radius of curvature again q_backw = -real(q_backw) + 1i*imag(q_backw); @@ -39,3 +47,27 @@ function q = gbeam_propagation(x_pos, q_in, x_in, optics_elements) endfunction +%!test +%! lambda= 1.064E-6 ; +%! f1=0.1526; +%! lns1.abcd=abcd_lens( f1) ; +%! lns1.x= 0.2; +%! f2=0.019; +%! lns2.abcd=abcd_lens( f2) ; +%! lns2.x= lns1.x+ f1 + f2; +%! lns3.abcd=abcd_lens( 0.0629) ; +%! lns3.x= 0.500; +%! q0=-1.5260e-01 + 1.7310e-04i; +%! x0=0.2; +%! optics={lns1,lns2,lns3}; +%! x=[0, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7]; +%! q0=1.8098e-96 + 1.3453e+02i; +%! x0=0; +%! q_test = gbeam_propagation(x,q0,x0,optics); +%! +%! % test beam is the same but starting point is taken midway +%! % and coincides with optics element{1}.x since (x(3) = 0.2) +%! q=gbeam_propagation(x,q_test(3),x(3),optics); +%! assert(q,q_test, -1e-6) + + diff --git a/gbeam_propagation_froward_only.m b/gbeam_propagation_froward_only.m index ba8c1cf..612d30f 100644 --- a/gbeam_propagation_froward_only.m +++ b/gbeam_propagation_froward_only.m @@ -2,6 +2,9 @@ function q = gbeam_propagation_froward_only(x_pos, q_in, x_in, optics_elements) % calculate the 'q' parameter of the Gaussian beam propagating through optical % 'optics_elements' only in the positive direction along 'x' axis at points 'x_pos' % takes the gaussian beam with initial q_in parameter at x_in +% Note!: if optics element position coinside with a x_pos at some place +% the reported value will be the one calculated after the element +% so the resulting value will coinside with submitted q_in % % all x_pos must be to the right of x_in % x_pos must be monotonic! @@ -38,3 +41,24 @@ function q = gbeam_propagation_froward_only(x_pos, q_in, x_in, optics_elements) q(i)=q_last_calc; endfor end + +%!test +%! lambda= 1.064E-6 ; +%! f1=0.1526; +%! lns1.abcd=abcd_lens( f1) ; +%! lns1.x= 0.2; +%! f2=0.019; +%! lns2.abcd=abcd_lens( f2) ; +%! lns2.x= lns1.x+ f1 + f2; +%! lns3.abcd=abcd_lens( 0.0629) ; +%! lns3.x= 0.500; +%! q0=1.8098e-96 + 1.3453e+02i; +%! x0=0; +%! optics={lns1,lns2,lns3}; +%! x=[0, 0.1, 0.2, 0.3, 0,4, 0.5, 0.6, 0.7]; +%! q_test = [1.8098e-96 + 1.3453e+02i, 1.0000e-01 + 1.3453e+02i, -1.5260e-01 + 1.7310e-04i, -5.2600e-02 + 1.7310e-04i, -5.2600e-02 + 1.7310e-04i, 3.4371e+00 + 1.8961e-03i, 3.4371e+00 + 1.8961e-03i, 3.4371e+00 + 1.8961e-03i, 3.4371e+00 + 1.8961e-03i]; +%! +%! q=gbeam_propagation(x,q0,x0,optics); +%! assert(q,q_test, -1e-4) + + |