Skip to content
  • Danny Hindson's avatar
    Add ability to load measured attenuation profile for material · 74316a4b
    Danny Hindson authored
    Add feature where an externally generated attenuation profile can be loaded into
    the material definition from a .DAT text file. This will override the normal
    exp(-alpha*thickness) calculation of the attenuation. The new feature was requested
    as part of the absorption calculation for the Pearl instrument where some parts
    of the environment are crystalline
    
    Found the lookup\interpolation on the loaded profile was slowing down the absorption
    Monte Carlo calculation.
    So improved performance of Kernel::Interpolation. Changed it to use vector of pairs
    instead of two separate vectors to reduce amount of navigation around vectors
    
    Considered adding feature into AttenuationProfile where I add any interpolated points
    into the override attenuation profile to prevent interpolation next iteration of
    Monte Carlo simulation. However wasn't convinced this was going to be thread-safe
    during the parallel part of the absorption calculation - may revisit this. While doing
    this investigation I fixed the following issues with the function Interpolation::AddPoint:
    
    a) it doesn't add the same point twice
    b) it reuses the lower_bound function rather than stepping through the vector sequentially
    
    I removed the exception from findIndexOfNextLargerValue because the end()
    iterator is a valid result if the x value supplied equals the last x value
    already in the vector. Could have left check in for begin() but didn't seem
    much point
    
    Finally - the interpolation outside the range is not v good. The data at the extremes
    is noisy so we end up extrapolating based on random gradient in extreme 2 points. Need
    to either fit or use more points to determine gradient
    74316a4b