Changeset 3224
- Timestamp:
- 12/14/11 15:24:08 (5 months ago)
- Files:
-
- 1 modified
Legend:
- Unmodified
- Added
- Removed
-
branches/mcxtrace-1.0/xlib/samples/Perfect_crystal.comp
r3223 r3224 61 61 %{ 62 62 %include "read_table-lib" 63 63 #include <complex.h> 64 64 /* something that would be relevant for ALL crystals */ 65 65 void DarwinReflectivity(double *R, double *Thetah, double *Theta0, double *DeltaTheta0, … … 103 103 104 104 /* STRUCTURE FACTOR CALCULATION: */ 105 /* NOTE: these structurefactors are valid for single atom structures like Si or Ge only: */ 105 /* NOTE: these structurefactors are valid for single atom diamond lattice structures like Si or Ge only: */ 106 107 108 106 109 F0r = 8*(f00 + fp); /* Q=0, real part of structure factor for forward scattering */ 107 110 F0i = 8*(fpp); /* Q=0, imag part of structure factor for forward scattering */ … … 111 114 Fhi = sqrt(17)*(fpp); /* |(4-i)| = sqrt(17) */ 112 115 } 113 if (h==2 && k==2 && l==0){ /* (220) reflection */116 else if (h==2 && k==2 && l==0){ /* (220) reflection */ 114 117 Fhr = 8*(f0h + fp); 115 118 Fhi = 8*(fpp); 116 119 } 117 if (h==4 && k==0 && l==0){ /* (400) reflection */120 else if (h==4 && k==0 && l==0){ /* (400) reflection */ 118 121 Fhr = 8*(f0h + fp); 119 122 Fhi = 8*(fpp); 120 123 } 124 else { 125 complex double f_hkl=(1+cexp(I*M_PI*(h+k))+cexp(I*M_PI*(k+l)) + cexp(I*M_PI*(h+l)))*(1+cexp(I*M_PI*(h/4.0 + k/4.0 + l/4.0))); 126 Fhr = cabs(f_hkl)*(f0h + fp); 127 Fhi = cabs(f_hkl)*(fpp); 128 F0r = cabs(f_hkl)*(f00 + fp); /* Q=0, real part of structure factor for forward scattering */ 129 F0i = cabs(f_hkl)*(fpp); /* Q=0, imag part of structure factor for forward scattering */ 130 } 121 131 122 132 psi0r = fabs(F0r*exp(-M)*r0*lambda*lambda/(PI*V)); … … 233 243 if (fabs(x_int)<=width/2 && fabs(z_int)<=length/2){ 234 244 dist=sqrt(SQR(x-x_int)+SQR(y-y_int)+SQR(z-z_int)); 235 PROP_DL(dist); /* now the photon is on the mirrorsurface, ready to be reflected... */245 PROP_DL(dist); /* now the photon is on the crystal surface, ready to be reflected... */ 236 246 SCATTER; 237 247 /*Check which quadrant the k vector is in to determine sense of alpha. This to allow for hitting the crystal from behind.*/ … … 253 263 }else if(ky>0 && kz>0){ 254 264 /*1st quadrant - forward hit from below. Sense of alpha is reversed.*/ 255 DarwinReflectivity(&R, &Thetah, &Theta0, &DeltaTheta0, f00, f0h, fp, fpp, V, alpha, h, k, l, M, E, Thetain,pol);265 DarwinReflectivity(&R, &Thetah, &Theta0, &DeltaTheta0, f00, f0h, fp, fpp, V, -alpha, h, k, l, M, E, Thetain,pol); 256 266 }else if(ky>0 && kz<0){ 257 267 /*2nd quadrant - backward hit from below. No change.*/ 258 DarwinReflectivity(&R, &Thetah, &Theta0, &DeltaTheta0, f00, f0h, fp, fpp, V, -alpha, h, k, l, M, E, Thetain,pol);268 DarwinReflectivity(&R, &Thetah, &Theta0, &DeltaTheta0, f00, f0h, fp, fpp, V, alpha, h, k, l, M, E, Thetain,pol); 259 269 } 260 270 Thetaout = Thetah - alpha; /* (rad) the angle between the crystal surface and the reflected ray */
