source: sasmodels/sasmodels/models/porod.py @ c1e44e5

Last change on this file since c1e44e5 was c1e44e5, checked in by Paul Kienzle <pkienzle@…>, 5 years ago

Add local link to source files. Refs #1263.

  • Property mode set to 100644
File size: 1.6 KB
Line 
1r"""
2This model fits the Porod function
3
4.. math:: I(q) = C/q^4
5
6to the data directly without any need for linearisation (cf. Log I(q) vs Log q).
7
8Here $C = 2\pi (\Delta\rho)^2 S_v$ is the scale factor where $S_v$ is
9the specific surface area (ie, surface area / volume) of the sample, and
10$\Delta\rho$ is the contrast factor.
11
12For 2D data: The 2D scattering intensity is calculated in the same way as 1D,
13where the q vector is defined as
14
15.. math:: q = \sqrt{q_x^2+q_y^2}
16
17References
18----------
19
20.. [#] G Porod. *Kolloid Zeit*. 124 (1951) 83
21.. [#] L A Feigin, D I Svergun, G W Taylor. *Structure Analysis by Small-Angle X-ray and Neutron Scattering*. Springer. (1987)
22
23Authorship and Verification
24----------------------------
25
26* **Author:**
27* **Last Modified by:**
28* **Last Reviewed by:**
29"""
30
31import numpy as np
32from numpy import inf, errstate
33
34name = "porod"
35title = "Porod function"
36description = """\
37          I(q) = scale/q^4 + background
38"""
39
40category = "shape-independent"
41
42parameters = []
43
44def Iq(q):
45    """
46    @param q: Input q-value
47    """
48    with errstate(divide='ignore'):
49        return q**-4
50
51Iq.vectorized = True  # Iq accepts an array of q values
52
53def random():
54    """Return a random parameter set for the model."""
55    sld, solvent = np.random.uniform(-0.5, 12, size=2)
56    radius = 10**np.random.uniform(1, 4.7)
57    Vf = 10**np.random.uniform(-3, -1)
58    scale = 1e-4 * Vf * 2*np.pi*(sld-solvent)**2/(3*radius)
59    pars = dict(
60        scale=scale,
61    )
62    return pars
63
64demo = dict(scale=1.5, background=0.5)
65
66tests = [
67    [{'scale': 0.00001, 'background':0.01}, 0.04, 3.916250],
68    [{}, 0.0, inf],
69]
Note: See TracBrowser for help on using the repository browser.