Changeset 3232 for trunk

Show
Ignore:
Timestamp:
12/15/11 17:03:38 (5 months ago)
Author:
erkn
Message:

Perfect crystal now works for any hkl

added support for arbitrary hkls. Still only single material diamond
structures, though.
Can now handle hits from below and backwards.
Fix to detector out data print routine to allow values closely spaced.
There was an implicit hard limit at 4 digits precision.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/xlib/samples/Perfect_crystal.comp

    r3231 r3232  
    3838* width [m]                     width of the crystal (along x-axis) 
    3939* Material                      Si, Ge (maybe also GaAs?)        
    40 <<<<<<< HEAD 
    41 * V [à
    42 ^3]                     unit cell volume 
    43 * h,k,l                         indices of reflection (111)(220)(400) 
    44 ======= 
    4540* V [à
    4641^3]                     unit cell volume160.1826 
     
    4843* k []                          Miller index of reflection 
    4944* l []                          Miller index of reflection 
    50 >>>>>>> Perfect crystal now works for any hkl 
    5145* alpha [rad]                   asymmetry angle (alpha=0 for symmetric reflection, ie the Bragg planes are parallel to the crystal surface) 
    5246* R0 []                         Reflectivity. Overrides the computed Darwin reflectivity. Probably only useful for debugging.  
     
    8680    theta = asin(lambda/(2*d));                 /* kinematical bragg angle (rad) */ 
    8781    b = sin(theta - alpha)/sin(theta + alpha);  /* asymmetry factor */ 
    88      
    89 <<<<<<< HEAD 
    90     *Theta0 = Thetain + alpha;                  /* (rad) angle between Bragg planes and incident ray */  
    91     *Thetah = b*(*Theta0 - theta) + theta;      /* (rad) Angle betweeb Bragg planes and reflected ray */ 
    92 ======= 
    93     b = sin(theta + alpha)/sin(theta - alpha);  /* asymmetry factor */ 
    9482 
    9583    *Theta0 = Thetain - alpha;                  /* (rad) angle between Bragg planes and incident ray */  
     
    10088      *DeltaTheta0 = -1; /*to mark it irrelevant*/ 
    10189    } 
    102 >>>>>>> Perfect crystal now works for any hkl 
    10390     
    10491    /* Define polarization factor: */ 
     
    248235        PROP_DL(dist);                  /* now the photon is on the mirror surface, ready to be reflected... */  
    249236        SCATTER; 
    250 <<<<<<< HEAD 
    251  
    252         Thetain = atan(kyu/kzu);        /* (rad )The angle of incidence*/ 
    253          
    254 ======= 
    255237        /*Check which quadrant the k vector is in to determine sense of alpha. This to allow for hitting the crystal from behind.*/ 
    256238        int quadrant; 
    257239        Thetain=fabs(atan(ky/kz)); 
    258 >>>>>>> Perfect crystal now works for any hkl 
    259240        /* for a start, just define the value of atomic form factors for Si(111) at E = 8.04778keV */ 
    260241        double d=cbrt(V)/(sqrt(h*h+k*k+l*l));/*this is valid only for cubic structures*/ 
     
    264245        fpp = Table_Value(prms.m_t,E,2); 
    265246//        printf("%g %g %g %g\n",f00,f0h,fp,fpp);     
    266 <<<<<<< HEAD 
    267 /*      printf("Thetain for this ray is: %g: \n",Thetain);*/ 
    268         DarwinReflectivity(&R, &Thetah, &Theta0, &DeltaTheta0, f00, f0h, fp, fpp, V, alpha, h, k, l, M, E, Thetain,pol); 
    269         Thetaout = Thetah + alpha;      /* (rad) the angle between the crystal surface and the reflected ray */ 
    270 /*      printf("Thetaout for this ray is: %g: \n", Thetaout);*/ 
    271  
    272 ======= 
    273247        //printf("Thetain for this ray is: %g: \n",Thetain); 
    274248        if (ky<0 && kz>0){ 
     
    301275          kz=kz-2*vnz; 
    302276        }while(0); 
    303 >>>>>>> Perfect crystal now works for any hkl 
    304277        /* The direction of the reflected ray: */ 
    305278       // printf("kout: %g %g %g\n",kx,ky,kz); 
    306279 
    307 <<<<<<< HEAD 
    308         NORM(kxout,kyout,kzout);  
    309         kx=K*kxout; 
    310         ky=K*kyout; 
    311         kz=K*kzout; 
    312                    
    313         /* apply reflectivity */ 
    314         p*=R;  
    315  
    316 ======= 
    317280        /* apply Darwin reflectivity if not is supplied from outside*/ 
    318281        if (!R0){ 
     
    323286        /*catch dead rays*/ 
    324287        if (p==0) ABSORB; 
    325 >>>>>>> Perfect crystal now works for any hkl 
    326         } else { 
    327           RESTORE_XRAY(INDEX_CURRENT_COMP, x, y, z, kx, ky, kz, phi, t, Ex, Ey, Ez, p); 
    328         }  
     288    } else { 
     289      RESTORE_XRAY(INDEX_CURRENT_COMP, x, y, z, kx, ky, kz, phi, t, Ex, Ey, Ez, p); 
     290    }  
    329291  } 
    330292