Changes in / [791281c:4c08e69] in sasmodels


Ignore:
Files:
2 added
2 edited

Legend:

Unmodified
Added
Removed
  • doc/guide/pd/polydispersity.rst

    reda8b30 r22279a4  
    4242calculations are generally more robust with more data points or more angles. 
    4343 
    44 The following five distribution functions are provided: 
     44The following distribution functions are provided: 
    4545 
    4646*  *Rectangular Distribution* 
     47*  *Uniform Distribution* 
    4748*  *Gaussian Distribution* 
    4849*  *Lognormal Distribution* 
    4950*  *Schulz Distribution* 
    5051*  *Array Distribution* 
     52*  *Boltzmann Distribution* 
    5153 
    5254These are all implemented as *number-average* distributions. 
     
    8587    Rectangular distribution. 
    8688 
     89Uniform Distribution 
     90^^^^^^^^^^^^^^^^^^^^^^^^ 
     91 
     92The Uniform Distribution is defined as 
     93 
     94    .. math:: 
     95 
     96        f(x) = \frac{1}{\text{Norm}} 
     97        \begin{cases} 
     98          1 & \text{for } |x - \bar x| \leq \sigma \\ 
     99          0 & \text{for } |x - \bar x| > \sigma 
     100        \end{cases} 
     101 
     102    where $\bar x$ is the mean of the distribution, $\sigma$ is the half-width, and 
     103    *Norm* is a normalization factor which is determined during the numerical 
     104    calculation. 
     105 
     106    Note that the polydispersity is given by 
     107 
     108    .. math:: \text{PD} = \sigma / \bar x 
     109 
     110    .. figure:: pd_uniform.jpg 
     111 
     112        Uniform distribution. 
     113 
    87114.. ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ 
    88115 
     
    183210^^^^^^^^^^^^^^^^^^ 
    184211 
    185 This user-definable distribution should be given as as a simple ASCII text 
     212This user-definable distribution should be given as a simple ASCII text 
    186213file where the array is defined by two columns of numbers: $x$ and $f(x)$. 
    187214The $f(x)$ will be normalized to 1 during the computation. 
     
    202229given for the model will have no affect, and will be ignored when computing 
    203230the average.  This means that any parameter with an array distribution will 
    204 not be fittable. 
     231not be fitable. 
     232 
     233.. ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ 
     234 
     235Boltzmann Distribution 
     236^^^^^^^^^^^^^^^^^^^^^^ 
     237 
     238The Boltzmann Distribution is defined as 
     239 
     240.. math:: 
     241 
     242    f(x) = \frac{1}{\text{Norm}} 
     243           \exp\left(-\frac{ | x - \bar x | }{\sigma}\right) 
     244 
     245where $\bar x$ is the mean of the distribution and *Norm* is a normalization 
     246factor which is determined during the numerical calculation. 
     247The width is defined as 
     248 
     249.. math:: \sigma=\frac{k T}{E} 
     250 
     251which is the inverse Boltzmann factor, 
     252where $k$ is the Boltzmann constant, $T$ the temperature in Kelvin and $E$ a 
     253characteristic energy per particle. 
     254 
     255.. figure:: pd_boltzmann.jpg 
     256 
     257    Boltzmann distribution. 
    205258 
    206259.. ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ 
  • sasmodels/weights.py

    r2d81cfe r34bbb9c  
    9797        return x, px 
    9898 
     99class UniformDispersion(Dispersion): 
     100    r""" 
     101    Uniform dispersion, with width $\sigma$. 
     102 
     103    .. math:: 
     104 
     105        w = 1 
     106    """ 
     107    type = "uniform" 
     108    default = dict(npts=35, width=0, nsigmas=1) 
     109    def _weights(self, center, sigma, lb, ub): 
     110        x = self._linspace(center, sigma, lb, ub) 
     111        x = x[np.fabs(x-center) <= np.fabs(sigma)] 
     112        return x, np.ones_like(x) 
    99113 
    100114class RectangleDispersion(Dispersion): 
     
    190204        return x, px 
    191205 
     206class BoltzmannDispersion(Dispersion): 
     207    r""" 
     208    Boltzmann dispersion, with $\sigma=k T/E$. 
     209 
     210    .. math:: 
     211 
     212        w = \exp\left( -|x - c|/\sigma\right) 
     213    """ 
     214    type = "boltzmann" 
     215    default = dict(npts=35, width=0, nsigmas=3) 
     216    def _weights(self, center, sigma, lb, ub): 
     217        x = self._linspace(center, sigma, lb, ub) 
     218        px = np.exp(-np.abs(x-center) / np.abs(sigma)) 
     219        return x, px 
    192220 
    193221# dispersion name -> disperser lookup table. 
     
    196224MODELS = OrderedDict((d.type, d) for d in ( 
    197225    RectangleDispersion, 
     226    UniformDispersion, 
    198227    ArrayDispersion, 
    199228    LogNormalDispersion, 
    200229    GaussianDispersion, 
    201230    SchulzDispersion, 
     231    BoltzmannDispersion 
    202232)) 
    203233 
Note: See TracChangeset for help on using the changeset viewer.