Changes in / [b669b49:a66b004] in sasmodels
- Files:
-
- 2 added
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
doc/guide/pd/polydispersity.rst
reda8b30 r75e4319 42 42 calculations are generally more robust with more data points or more angles. 43 43 44 The following fivedistribution functions are provided:44 The following six distribution functions are provided: 45 45 46 46 * *Rectangular Distribution* 47 * *Uniform Distribution* 47 48 * *Gaussian Distribution* 48 49 * *Lognormal Distribution* 49 50 * *Schulz Distribution* 50 51 * *Array Distribution* 52 * *Boltzmann Distribution* 51 53 52 54 These are all implemented as *number-average* distributions. … … 85 87 Rectangular distribution. 86 88 89 Uniform Distribution 90 ^^^^^^^^^^^^^^^^^^^^^^^^ 91 92 The 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 87 114 .. ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ 88 115 … … 183 210 ^^^^^^^^^^^^^^^^^^ 184 211 185 This user-definable distribution should be given as a s asimple ASCII text212 This user-definable distribution should be given as a simple ASCII text 186 213 file where the array is defined by two columns of numbers: $x$ and $f(x)$. 187 214 The $f(x)$ will be normalized to 1 during the computation. … … 202 229 given for the model will have no affect, and will be ignored when computing 203 230 the average. This means that any parameter with an array distribution will 204 not be fittable. 231 not be fitable. 232 233 .. ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ 234 235 Boltzmann Distribution 236 ^^^^^^^^^^^^^^^^^^^^^^ 237 238 The 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 245 where $\bar x$ is the mean of the distribution and *Norm* is a normalization 246 factor which is determined during the numerical calculation. 247 The width is defined as 248 249 .. math:: \sigma=\frac{k T}{E} 250 251 which is the inverse Boltzmann factor, 252 where $k$ is the Boltzmann constant, $T$ the temperature in Kelvin and $E$ a 253 characteristic energy per particle. 254 255 .. figure:: pd_boltzmann.jpg 256 257 Boltzmann distribution. 205 258 206 259 .. ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ -
sasmodels/weights.py
r2d81cfe r2d81cfe 97 97 return x, px 98 98 99 class 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) 99 113 100 114 class RectangleDispersion(Dispersion): … … 190 204 return x, px 191 205 206 class 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 192 220 193 221 # dispersion name -> disperser lookup table. … … 196 224 MODELS = OrderedDict((d.type, d) for d in ( 197 225 RectangleDispersion, 226 UniformDispersion, 198 227 ArrayDispersion, 199 228 LogNormalDispersion, 200 229 GaussianDispersion, 201 230 SchulzDispersion, 231 BoltzmannDispersion 202 232 )) 203 233 … … 246 276 import pylab 247 277 278 <<<<<<< HEAD 279 if any(len(dispersity)>1 for value, dispersity, weights in mesh): 280 labels = [p.name for p in model_info.parameters.call_parameters] 281 #pylab.interactive(True) 282 pylab.figure() 283 for (v,x,w), s in zip(mesh, labels): 284 ======= 248 285 if any(len(dispersity) > 1 for value, dispersity, weights in mesh): 249 286 labels = [p.name for p in model_info.parameters.call_parameters] … … 251 288 pylab.figure() 252 289 for (v, x, w), s in zip(mesh, labels): 290 >>>>>>> master 253 291 if len(x) > 1: 254 292 pylab.plot(x, w, '-o', label=s)
Note: See TracChangeset
for help on using the changeset viewer.