Changeset 2924
- Timestamp:
- 09/02/10 14:46:49 (17 months ago)
- Files:
-
- 1 modified
-
trunk/nlib/optics/Monochromator_curved.comp (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/nlib/optics/Monochromator_curved.comp
r2639 r2924 82 82 * transmit:transmission file name of text file as 2 columns [k, T] [str] 83 83 * t0: transmission efficiency [1] 84 * order: specify the diffraction order, 1 is usually prefered. Use 0 for all [1] 84 85 * 85 86 * OUTPUT PARAMETERS: … … 99 100 DEFINE COMPONENT Monochromator_curved 100 101 DEFINITION 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) 102 SETTING 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) 102 105 OUTPUT PARAMETERS (mos_rms_y, mos_rms_z, mos_rms_max, mono_Q,SlabWidth,SlabHeight,rTable, tTable, row, col) 103 106 STATE PARAMETERS (x,y,z,vx,vy,vz,t,sx,sy,sz,p) … … 155 158 if (mono_Q <= 0) { fprintf(stderr,"Monochromator_curved: %s: Error scattering vector Q = 0\n", NAME_CURRENT_COMP); exit(-1); } 156 159 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. I ngnoring component.\n", NAME_CURRENT_COMP); }160 if (r0 == 0) { fprintf(stderr,"Monochromator_curved: %s: Reflectivity r0 is null. Ignoring component.\n", NAME_CURRENT_COMP); } 158 161 if (NH*NV == 0) { fprintf(stderr,"Monochromator_curved: %s: no slabs ??? (NH or NV=0)\n", NAME_CURRENT_COMP); exit(-1); } 159 162 … … 222 225 if (z>zmin && z<zmax && y>ymin && y<ymax) { /* Intersect the crystal? */ 223 226 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; 225 228 double kix,kiy,kiz; 226 229 int do_transmit = 0; … … 261 264 scattering vector is considered */ 262 265 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; 265 268 /* Order will be negative when the neutron enters from the back, in 266 269 which case the direction of Q0 is flipped. */ 267 if( order < 0) order = -order;270 if(Q_order < 0) Q_order = -Q_order; 268 271 /* Make sure the order is small enough to allow Bragg scattering at the 269 272 given neutron wavelength */ … … 272 275 kuy = kiy/k; 273 276 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? */ 276 279 double q0, q0x, theta, delta, p_reflect, my_r0; 277 280 278 q0 = order*mono_Q;281 q0 = Q_order*mono_Q; 279 282 q0x = ratio < 0 ? -q0 : q0; 280 283 theta = asin(q0/(2*k)); /* Actual bragg angle */
