Changeset 2924

Show
Ignore:
Timestamp:
09/02/10 14:46:49 (17 months ago)
Author:
farhi
Message:

optics: Added order parameter to select a prefered diffraction order, or use order=0

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/nlib/optics/Monochromator_curved.comp

    r2639 r2924  
    8282* transmit:transmission file name of text file as 2 columns [k, T] [str] 
    8383* t0:      transmission efficiency [1] 
     84* order:   specify the diffraction order, 1 is usually prefered. Use 0 for all [1] 
    8485* 
    8586* OUTPUT PARAMETERS: 
     
    99100DEFINE COMPONENT Monochromator_curved 
    100101DEFINITION PARAMETERS () 
    101 SETTING PARAMETERS (string reflect=0, string transmit=0, zwidth=0.01, yheight=0.01, gap=0.0005, NH=11, NV=11, mosaich=30.0, mosaicv=30.0, r0=0.7, t0=1.0,Q=1.8734, RV=0, RH=0, DM=0, mosaic=0, width=0, height=0, verbose=0) 
     102SETTING PARAMETERS (string reflect=0, string transmit=0, zwidth=0.01, yheight=0.01,  
     103  gap=0.0005, NH=11, NV=11, mosaich=30.0, mosaicv=30.0, r0=0.7, t0=1.0,Q=1.8734,  
     104  RV=0, RH=0, DM=0, mosaic=0, width=0, height=0, verbose=0, order=0) 
    102105OUTPUT PARAMETERS (mos_rms_y, mos_rms_z, mos_rms_max, mono_Q,SlabWidth,SlabHeight,rTable, tTable, row, col) 
    103106STATE PARAMETERS (x,y,z,vx,vy,vz,t,sx,sy,sz,p) 
     
    155158  if (mono_Q <= 0) { fprintf(stderr,"Monochromator_curved: %s: Error scattering vector Q = 0\n", NAME_CURRENT_COMP); exit(-1); } 
    156159  if (r0 <  0) { fprintf(stderr,"Monochromator_curved: %s: Error reflectivity r0 is negative\n", NAME_CURRENT_COMP); exit(-1); } 
    157   if (r0 == 0) { fprintf(stderr,"Monochromator_curved: %s: Reflectivity r0 is null. Ingnoring component.\n", NAME_CURRENT_COMP); } 
     160  if (r0 == 0) { fprintf(stderr,"Monochromator_curved: %s: Reflectivity r0 is null. Ignoring component.\n", NAME_CURRENT_COMP); } 
    158161  if (NH*NV == 0) { fprintf(stderr,"Monochromator_curved: %s: no slabs ??? (NH or NV=0)\n", NAME_CURRENT_COMP); exit(-1); } 
    159162 
     
    222225    if (z>zmin && z<zmax && y>ymin && y<ymax) { /* Intersect the crystal? */ 
    223226      double tilth,tiltv;         /* used to calculate tilt angle of slab */ 
    224       double ratio, order, k, kux,kuy,kuz; 
     227      double ratio, Q_order, k, kux,kuy,kuz; 
    225228      double kix,kiy,kiz; 
    226229      int    do_transmit = 0; 
     
    261264          scattering vector is considered */ 
    262265        ratio = -2*kix/mono_Q; 
    263         order = floor(ratio + .5); 
    264         if(order == 0.0) order = ratio < 0 ? -1 : 1; 
     266        Q_order = floor(ratio + .5); 
     267        if(Q_order == 0.0) Q_order = ratio < 0 ? -1 : 1; 
    265268        /* Order will be negative when the neutron enters from the back, in 
    266269          which case the direction of Q0 is flipped. */ 
    267         if(order < 0) order = -order; 
     270        if(Q_order < 0) Q_order = -Q_order; 
    268271        /* Make sure the order is small enough to allow Bragg scattering at the 
    269272          given neutron wavelength */ 
     
    272275        kuy = kiy/k; 
    273276        kuz = kiz/k; 
    274         if(order > 2*k/mono_Q) order--; 
    275         if(order > 0) {           /* Bragg scattering possible? */ 
     277        if(Q_order > 2*k/mono_Q) Q_order--; 
     278        if((!order && Q_order > 0) || (Q_order == fabs(order) && order)) {           /* Bragg scattering possible? */ 
    276279          double q0, q0x, theta, delta, p_reflect, my_r0; 
    277280 
    278           q0 = order*mono_Q; 
     281          q0 = Q_order*mono_Q; 
    279282          q0x = ratio < 0 ? -q0 : q0; 
    280283          theta = asin(q0/(2*k)); /* Actual bragg angle */