pro ltx_los_sim,rt=rt,out=out ;program to simulate the l.o.s. observed distribution function for a given tangency radius ; and a given set of profiles xplot39 tek_color ;generate LTX ri=5.468 ;inboard major radius ro=25.938 ;outboard major radius rmx=15.748 ;magnetic axis major radius a=(ro-ri)/2. np=1000 x_ltx_ob=(2.*findgen(np)/(np-1.)-1.)*ro y_ltx_ob=sqrt(ro^2-x_ltx_ob^2) x_ltx_ib=(2.*findgen(np)/(np-1.)-1.)*ri y_ltx_ib=sqrt(ri^2-x_ltx_ib^2) x_ltx_mx=(2.*findgen(np)/(np-1.)-1.)*rmx y_ltx_mx=sqrt(rmx^2-x_ltx_mx^2) window,0,title="LTX toroidal cut" !p.multi=0 plot,x_ltx_ob,y_ltx_ob,/xst,/yst,/iso oplot,x_ltx_ib,y_ltx_ib oplot,x_ltx_mx,y_ltx_mx,linestyle=2 ;generate line-o-sight if n_elements(rt) eq 0 then rt=rmx theta=asin(rt/ro) ;angle of los in radians m=-1.*tan(theta) b=ro*tan(theta) ;solve x2+y2=ro2 and y=mx+b x1=(-2.*m*b+sqrt((2.*m*b)^2-4.*(1.+m^2)*(b^2-ro^2)))/(2.*(1+m^2)) x2=(-2.*m*b-sqrt((2.*m*b)^2-4.*(1.+m^2)*(b^2-ro^2)))/(2.*(1+m^2)) x_los=(findgen(np)/(np-1.)*(x2-x1)+x1) y_los=m*x_los+b oplot,x_los,y_los,color=2 r_los=sqrt(x_los^2+y_los^2) s_los=sqrt((x_los-x_los[0])^2+(y_los-y_los[0])^2) temp=s_los/r_los*sin(theta) w=where(temp gt 1.) if w[0] ne -1 then temp[w]=temp[w]*0.+1. beta=asin(temp) ;asin(s_los/r_los*sin(theta)) w=where(x_los lt 0) if w[0] ne -1 then beta[w]=!pi-beta[w] ;need to fix the sign of arcsin crossing the y-axis phi=!pi-theta-beta kt=near(r_los,rt) oplot,[0,x_los[kt]],[0,y_los[kt]],color=3 window,1 !p.multi=[0,1,2] plot,s_los,r_los,/ynoz,xtitle='s_los (inches)',ytitle='r_los (inches)' oplot,[-1,1]*1000.,[1.,1.]*rt,color=3 plot,r_los,phi*180./!pi-90.,xtitle='r_los (inches)',ytitle='angle wrt B (degrees)' oplot,[1,1]*rt,[-1,1]*180.,color=3 out={rt:rt,x_los:x_los,y_los:y_los,r_los:r_los,s_los:s_los,phi:phi} ;v_los=v_t/cos(phi-!pi/2.) ;stop end