Changes in / [e526a9d:032646d] in sasmodels


Ignore:
Files:
2 deleted
2 edited

Legend:

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

    r92d330fd reda8b30  
    4242calculations are generally more robust with more data points or more angles. 
    4343 
    44 The following distribution functions are provided: 
     44The following five distribution functions are provided: 
    4545 
    4646*  *Rectangular Distribution* 
    47 *  *Uniform Distribution* 
    4847*  *Gaussian Distribution* 
    4948*  *Lognormal Distribution* 
    5049*  *Schulz Distribution* 
    5150*  *Array Distribution* 
    52 *  *Boltzmann Distribution* 
    5351 
    5452These are all implemented as *number-average* distributions. 
     
    8785    Rectangular distribution. 
    8886 
    89  
    90  
    91 Uniform Distribution 
    92 ^^^^^^^^^^^^^^^^^^^^^^^^ 
    93  
    94 The Uniform Distribution is defined as 
    95  
    96     .. math:: 
    97  
    98         f(x) = \frac{1}{\text{Norm}} 
    99         \begin{cases} 
    100           1 & \text{for } |x - \bar x| \leq \sigma \\ 
    101           0 & \text{for } |x - \bar x| > \sigma 
    102         \end{cases} 
    103  
    104     where $\bar x$ is the mean of the distribution, $\sigma$ is the half-width, and 
    105     *Norm* is a normalization factor which is determined during the numerical 
    106     calculation. 
    107  
    108     Note that the polydispersity is given by 
    109  
    110     .. math:: \text{PD} = \sigma / \bar x 
    111  
    112     .. figure:: pd_uniform.jpg 
    113  
    114         Uniform distribution. 
    115  
    116 The value $N_\sigma$ is ignored for this distribution. 
    117  
    11887.. ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ 
    11988 
     
    214183^^^^^^^^^^^^^^^^^^ 
    215184 
    216 This user-definable distribution should be given as a simple ASCII text 
     185This user-definable distribution should be given as as a simple ASCII text 
    217186file where the array is defined by two columns of numbers: $x$ and $f(x)$. 
    218187The $f(x)$ will be normalized to 1 during the computation. 
     
    233202given for the model will have no affect, and will be ignored when computing 
    234203the average.  This means that any parameter with an array distribution will 
    235 not be fitable. 
    236  
    237 .. ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ 
    238  
    239 Boltzmann Distribution 
    240 ^^^^^^^^^^^^^^^^^^^^^^ 
    241  
    242 The Boltzmann Distribution is defined as 
    243  
    244 .. math:: 
    245  
    246     f(x) = \frac{1}{\text{Norm}} 
    247            \exp\left(-\frac{ | x - \bar x | }{\sigma}\right) 
    248  
    249 where $\bar x$ is the mean of the distribution and *Norm* is a normalization 
    250 factor which is determined during the numerical calculation. 
    251 The width is defined as 
    252  
    253 .. math:: \sigma=\frac{k T}{E} 
    254  
    255 which is the inverse Boltzmann factor, 
    256 where $k$ is the Boltzmann constant, $T$ the temperature in Kelvin and $E$ a 
    257 characteristic energy per particle. 
    258  
    259 .. figure:: pd_boltzmann.jpg 
    260  
    261     Boltzmann distribution. 
     204not be fittable. 
    262205 
    263206.. ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ 
  • sasmodels/weights.py

    r3d58247 r2d81cfe  
    9797        return x, px 
    9898 
    99 class UniformDispersion(Dispersion): 
    100     r""" 
    101     Uniform dispersion, with width $\sigma$. 
     99 
     100class RectangleDispersion(Dispersion): 
     101    r""" 
     102    Uniform dispersion, with width $\sqrt{3}\sigma$. 
    102103 
    103104    .. math:: 
     
    105106        w = 1 
    106107    """ 
    107     type = "uniform" 
    108     default = dict(npts=35, width=0, nsigmas=None) 
    109     def _weights(self, center, sigma, lb, ub): 
    110         x = np.linspace(center-sigma, center+sigma, self.npts) 
    111         x = x[(x >= lb) & (x <= ub)] 
     108    type = "rectangle" 
     109    default = dict(npts=35, width=0, nsigmas=1.70325) 
     110    def _weights(self, center, sigma, lb, ub): 
     111        x = self._linspace(center, sigma, lb, ub) 
     112        x = x[np.fabs(x-center) <= np.fabs(sigma)*sqrt(3.0)] 
    112113        return x, np.ones_like(x) 
    113114 
    114 class RectangleDispersion(Dispersion): 
    115     r""" 
    116     Uniform dispersion, with width $\sqrt{3}\sigma$. 
    117  
    118     .. math:: 
    119  
    120         w = 1 
    121     """ 
    122     type = "rectangle" 
    123     default = dict(npts=35, width=0, nsigmas=1.73205) 
    124     def _weights(self, center, sigma, lb, ub): 
    125          x = self._linspace(center, sigma, lb, ub) 
    126          x = x[np.fabs(x-center) <= np.fabs(sigma)*sqrt(3.0)] 
    127          return x, np.ones_like(x) 
    128115 
    129116class LogNormalDispersion(Dispersion): 
     
    203190        return x, px 
    204191 
    205 class BoltzmannDispersion(Dispersion): 
    206     r""" 
    207     Boltzmann dispersion, with $\sigma=k T/E$. 
    208  
    209     .. math:: 
    210  
    211         w = \exp\left( -|x - c|/\sigma\right) 
    212     """ 
    213     type = "boltzmann" 
    214     default = dict(npts=35, width=0, nsigmas=3) 
    215     def _weights(self, center, sigma, lb, ub): 
    216         x = self._linspace(center, sigma, lb, ub) 
    217         px = np.exp(-np.abs(x-center) / np.abs(sigma)) 
    218         return x, px 
    219192 
    220193# dispersion name -> disperser lookup table. 
     
    223196MODELS = OrderedDict((d.type, d) for d in ( 
    224197    RectangleDispersion, 
    225     UniformDispersion, 
    226198    ArrayDispersion, 
    227199    LogNormalDispersion, 
    228200    GaussianDispersion, 
    229201    SchulzDispersion, 
    230     BoltzmannDispersion 
    231202)) 
    232203 
Note: See TracChangeset for help on using the changeset viewer.