blob: 0e38d07aa97c6c4ac31d3a91d9a36e0980a22b73 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
|
function answ=q_diff_after_cavity(q_initial)
# A B C D should be defined as global variables outside as well
# they represent elements of cavity ABCD matrix
global A B C D ;
q_diff=(A*(q_initial(1)+q_initial(2)*1i)+B)/(C*(q_initial(1)+q_initial(2)*1i) +D)-(q_initial(1)+q_initial(2)*1i) ;
answ=[real(q_diff), imag(q_diff)];
endfunction
## looks like it always return some result even if cavity is unstable ##
function answ=find_q_at_the_mirror(q_initial_guess)
[q_array,info]=fsolve("q_diff_after_cavity", [real(q_initial_guess),imag(q_initial_guess)]);
if ( info == 1 )
answ=q_array(1)+q_array(2)*1i ;
else
error("unable to find waste at mirror of the cavity, may be cavity is unstable")
quit()
endif
endfunction
|