Changeset 3206

Show
Ignore:
Timestamp:
11/17/11 10:05:42 (6 months ago)
Author:
farhi
Message:

nlib/optics: set R=1 when reflectivity is >1 in monochromators and Guide_anyshape.
Fix minor stuff in mcplot.py and typos.

Location:
trunk
Files:
6 modified

Legend:

Unmodified
Added
Removed
  • trunk/nlib/contrib/Monochromator_2foc.comp

    r3177 r3206  
    133133  if (reflect != NULL) 
    134134  { 
    135     if (verbose) fprintf(stdout, "Monochromator_2foc : %s : Reflectivity data (k, R)\n", NAME_CURRENT_COMP); 
     135    if (verbose) fprintf(stdout, "Monochromator_2foc: %s : Reflectivity data (k, R)\n", NAME_CURRENT_COMP); 
    136136    Table_Read(&rTable, reflect, 1); /* read 1st block data from file into rTable */ 
    137137    Table_Rebin(&rTable);         /* rebin as evenly, increasing array */ 
     
    214214        if (my_r0 >= 1) 
    215215        { 
    216           if (verbose) fprintf(stdout, "Warning: Monochromator_2foc : lowered reflectivity from %f to 0.99 (k=%f)\n", my_r0, k); 
     216          if (verbose) fprintf(stdout, "Warning: Monochromator_2foc: %s: lowered reflectivity from %f to 0.99 (k=%f)\n",  
     217            NAME_CURRENT_COMP, my_r0, k); 
    217218          my_r0=0.99; 
    218219        } 
    219220        if (my_r0 < 0) 
    220221        { 
    221           if (verbose) fprintf(stdout, "Warning: Monochromator_2foc : raised reflectivity from %f to 0 (k=%f)\n", my_r0, k); 
     222          if (verbose) fprintf(stdout, "Warning: Monochromator_2foc: %s: raised reflectivity from %f to 0 (k=%f)\n",  
     223          NAME_CURRENT_COMP, my_r0, k); 
    222224          my_r0=0; 
    223225        } 
     
    226228        z = z1; 
    227229        t = t1; 
    228  
    229         p *= fabs(my_r0)*exp(-tmp3*tmp3*4*log(2)); /* Use mosaics */ 
     230         
     231        /* reflectivity */ 
     232        t1 = fabs(my_r0)*exp(-tmp3*tmp3*4*log(2)); 
     233        if (t1 <= 0) ABSORB; 
     234        if (t1 > 1)  t1 = 1; 
     235        p *= t1; /* Use mosaics */ 
     236         
    230237        tmp1 = 2*theta; 
    231238        cs = cos(tmp1); 
  • trunk/nlib/optics/Guide_anyshape.comp

    r3177 r3206  
    150150 
    151151    if (R <= 0) ABSORB; 
     152    if (R > 1) { 
     153      fprintf(stderr,"Guide_anyshape: %s: Warning: Reflectivity R=%g > 1 lowered to R=1.\n", NAME_CURRENT_COMP, R); 
     154      R=1; 
     155    } 
    152156 
    153157    /* now handle either probability when transmit or reflect */ 
  • trunk/nlib/optics/Monochromator_curved.comp

    r3198 r3206  
    182182  if (reflect != NULL && r0 && strlen(reflect) && strcmp(reflect,"NULL") && strcmp(reflect,"0")) 
    183183  { 
    184     if (verbose) fprintf(stdout, "Monochromator_curved : %s : Reflectivity data (k, R) from %s\n", NAME_CURRENT_COMP, reflect); 
     184    if (verbose) fprintf(stdout, "Monochromator_curved: %s: Reflectivity data (k, R) from %s\n", NAME_CURRENT_COMP, reflect); 
    185185    Table_Read(&rTable, reflect, 1); /* read 1st block data from file into rTable */ 
    186186    Table_Rebin(&rTable);         /* rebin as evenly, increasing array */ 
     
    191191  if (transmit != NULL && strlen(transmit) && strcmp(transmit,"NULL") && strcmp(transmit,"0")) 
    192192  { 
    193     if (verbose) fprintf(stdout, "Monochromator_curved : %s : Transmission data (k, T) from %s\n", NAME_CURRENT_COMP, transmit); 
     193    if (verbose) fprintf(stdout, "Monochromator_curved: %s: Transmission data (k, T) from %s\n", NAME_CURRENT_COMP, transmit); 
    194194    Table_Read(&tTable, transmit, 1); /* read 1st block data from file into rTable */ 
    195195    Table_Rebin(&tTable);         /* rebin as evenly, increasing array */ 
     
    384384            vy = K2V*(kiy+q_y); 
    385385            vz = K2V*(kiz+q_z); 
    386             p *= p_reflect/(total*GAUSS(phi,0,mos_sample)); 
     386            p_reflect /= total*GAUSS(phi,0,mos_sample); 
     387            if (p_reflect <= 0) ABSORB; 
     388            if (p_reflect > 1)  p_reflect = 1; 
     389            p *= p_reflect; 
    387390 
    388391            SCATTER; 
  • trunk/nlib/optics/Monochromator_flat.comp

    r3177 r3206  
    243243          vy = K2V*(kiy+q_y); 
    244244          vz = K2V*(kiz+q_z); 
    245           p *= p_reflect/(total*GAUSS(phi,0,mos_sample)); 
     245          p_reflect /= total*GAUSS(phi,0,mos_sample); 
     246          if (p_reflect <= 0) ABSORB; 
     247          if (p_reflect > 1)  p_reflect = 1; 
     248          p *= p_reflect; 
    246249          SCATTER; 
    247250        } /* End MC choice to reflect or transmit neutron */ 
  • trunk/nlib/optics/Monochromator_pol.comp

    r3177 r3206  
    156156    // calculate deltalambda squared and sigmaLambda squared 
    157157    dlambda2 = (lambda-lambdaBragg)*(lambda-lambdaBragg); 
    158     // The sigmaLambda is propagated by differentiating thge bragg  
     158    // The sigmaLambda is propagated by differentiating the Bragg  
    159159    // condition: lambda = 2*d*sinTheta 
    160160    sigmaLambda2 = 2.0*2.0 * sinTheta*sinTheta * d_rms*d_rms+ 
  • trunk/src/mcplot.py

    r2916 r3206  
    412412        # No filename given, assume mcstas.sim in current dir 
    413413        this_File = "mcstas.sim" 
     414 
     415    # FIX: make the path to this_File absolute to always get a non-empty dirname. 
     416    this_File = os.path.abspath(this_File) 
    414417     
    415418    if os.path.isdir(this_File)==1: 
    416419        # dirname given, assume mcstas.sim in that dir. 
    417420        this_File = os.path.join(this_File,'mcstas.sim') 
    418   
     421 
    419422    if os.path.dirname(this_File) != '': 
    420423        pwd = os.getcwd()