Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ; set parameters for calculations here
- slitValues = []; um
- mirrorValues = []; deg wrt. normal
- alphaValues = []; deg wrt. normal
- betaValues = []; deg wrt. normal
- energyValues = []; eV
- divergenceValues = []; mrad
- resolvingPower = ;
- lineDensity = ; l/mm
- cff = ;
- ; ----------------------------------------------------------
- ; open output file
- fname='output.txt';
- openw,lun,fname,/get_lun;
- window,/free;
- FOR j=0,N_Elements(energyValues)-1 DO BEGIN
- energy=energyValues[j];
- divergence=divergenceValues[j];
- alpha=alphaValues[j];
- beta=betaValues[j];
- mirrorAngle=mirrorValues[j];
- ; calculate energy width
- energyHalfWidth=(energy/resolvingPower)*(10.0/2.0);
- eMin=energy-energyHalfWidth;
- eMax=energy+energyHalfWidth;
- ; print source parameters
- printf,lun,'energy='+string(energy);
- printf,lun,'eMin='+string(eMin);
- printf,lun,'eMax='+string(eMax);
- printf,lun,'divergence='+string(divergence);
- ; set source energy width and divergence
- source=read_gfile('start.00');
- source.PH1=eMin;
- source.PH2=eMax;
- source.VDIV1=divergence/(1000.0*2.0);
- source.VDIV2=divergence/(1000.0*2.0);
- write_gfile,source,'start.00';
- ; run source calculation
- xsh_run,'gen_source start.00';
- ; set plane mirror angles
- planeMirror=read_gfile('start.02');
- planeMirror.T_INCIDENCE=mirrorAngle
- planeMirror.T_REFLECTION=mirrorAngle
- write_gfile,planeMirror,'start.02';
- ; set grating parameters
- pgm=read_gfile('start.03');
- pgm.PHOT_CENT=energy;
- pgm.T_INCIDENCE=alpha;
- pgm.T_REFLECTION=beta;
- pgm.RULING=lineDensity*10.0;
- write_gfile,pgm,'start.03';
- ; print angle parameters
- printf,lun,'alpha='+string(alpha);
- printf,lun,'beta='+string(beta);
- printf,lun,'mirrorAngle='+string(mirrorAngle);
- printf,lun,'lineDensity='+string(lineDensity);
- printf,lun,'cff='+string(cff);
- printf,lun,'';
- ; print headings for results
- printf,lun,'slit_gap good_rays energy_res hor_size vert_size pgm_foot vfm_foot';
- ; run trace for all slit width values
- FOR i=0,N_Elements(slitValues)-1 DO BEGIN
- slit=slitValues[i];
- ; set slit gap
- cylindricalMirror=read_gfile('start.04');
- cylindricalMirror.RX_SLIT(0)=slit/10000.0;
- write_gfile,cylindricalMirror,'start.04';
- ; run ray trace
- xsh_run,'echo 0 | trace -m menu';
- ; find beam size and intensity
- plotxy,'star.06',3,1,nolost=1,cart=1,calfwhm=1,gaussfit=2,mulfac=10000,fwhm_fit=size,extract=points;
- horSize=size[0];
- vertSize=size[1];
- goodRays=n_elements(points[0,*]);
- ; find energy resolution
- histo1,'star.06',11,gaussfit=2,nolost=1,calfwhm=1,fwhm_fit=energyRes;
- ; find pgm footprint
- plotxy,'mirr.03',2,1,nolost=1,cart=1,calfwhm=1,gaussfit=2,mulfac=10,fwhm_val=pgmFootVal;
- ; find vfm footprint
- plotxy,'mirr.05',2,1,nolost=1,cart=1,calfwhm=1,gaussfit=2,mulfac=10,fwhm_val=vfmFootVal;
- pgmFoot=pgmFootVal[0];
- vfmFoot=vfmFootVal[0];
- ; print results line
- printf,lun,string(slit)+' '+string(goodRays)+' '+string(energyRes)+' '+string(horSize)+' '+string(vertSize)+' '+string(pgmFoot)+' '+string(vfmFoot);
- ENDFOR
- printf,lun,'';
- ENDFOR
- ; close output file
- close,lun;
- free_lun,lun;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement