;$Id: rayleighII.pro,v 1.1 2016/09/28 17:24:26 brandenb Exp $ common cdat,x,y,z,nx,ny,nz,nw,ntmax,date0,time0 ; ; This is a sample routine for computing eigenvalues and eigenvectors ; for the Rayleigh inflection point instability problem. ; Run this directly on the command line with ".r rayleighII.pro". ; The eigenfunctions are plotted afterwards using ".r pevec.pro" ; Report problems to Axel Brandenburg ; if !d.name eq 'PS' then begin device,xsize=18,ysize=5,yoffset=3 !p.charthick=3 & !p.thick=3 & !x.thick=3 & !y.thick=3 end ; ; mv idl.ps ~/tex/teach/ASTR_5410/8_Inflection_Pt_Inst_II/fig/rayleighII.ps ; !p.charsize=1.0 !x.margin=[7.8,.5] !y.margin=[3.2,.5] ; n=61 ;(number of mesh points) n=121 ;(number of mesh points) length=10. ;(size of the domain) length=40. ;(size of the domain) ; dk=.02 ;(interval between k values) kmax=1.1 ;(maximum wavenumber) ; dx=length/(n+1) x=dx*(findgen(n)+1.)-length/2. dx2=1./dx^2 ii=complex(0.,1.) nk=1+fix(kmax/dk) k=dk*findgen(nk) ; ; profiles ; ;U=(x)*1. U=tanh(x) ;U=x<1.>(-1.) ;U=x>(-1.)<1. U1=deriv(x,U) U2=deriv(x,U1) ; evalk=complexarr(n,nk) eveck=complexarr(n,nk) ; ; set matrix points ; D2=fltarr(n,n) for i=0,n-1 do D2(i,i)=-2.*dx2 for i=0,n-2 do D2(i,i+1)=dx2 for i=1,n-1 do D2(i,i-1)=dx2 ; UU=fltarr(n,n) & for i=0,n-1 do UU[i,*]=U[i] UU2=fltarr(n,n) & for i=0,n-1 do UU2[i,i]=U2[i] ; for ik=0,nk-1 do begin k2=k(ik)^2 S=D2-k2*identity(n) M=UU*S-UU2 eval=LA_EIGENPROBLEM(M,S,eigenvectors=evec) ; ; sort ; good=sort(imaginary(eval)) evalk[*,ik]=eval(good) eveck[*,ik]=evec[*,good[n-1]] ;if ik eq 20 then stop endfor ; !p.multi=[0,2,1] !x.title='!8k!6' !y.title='!6Re !8c!6' plot,k,float(evalk[n-1,*]),yr=[-1,1]*1.05e0,/nodata for i=0,n-1 do oplot,k,float(evalk[i,*]),ps=3 i=0 & oplot,k,abs(float(evalk[i,*])),ps=1,col=122 i=n-1 & oplot,k,abs(float(evalk[i,*])),ps=1,col=55 ; !y.title='!6Im !8c!6' plot,k,imaginary(evalk[n-1,*]),yr=[-1,1]*max(imaginary(evalk))*1.2,/nodata for i=0,n-1 do oplot,k,imaginary(evalk[i,*]),ps=3 i=0 & oplot,k,imaginary(evalk[i,*]),ps=1,col=122 i=n-1 & oplot,k,imaginary(evalk[i,*]),ps=1,col=55 ; !p.multi=0 print,minmax(imaginary(evalk)) !x.title='!6' !y.title='!6' end