source: sasmodels/sasmodels/models/porod.py @ 71b751d

core_shell_microgelsmagnetic_modelticket-1257-vesicle-productticket_1156ticket_1265_superballticket_822_more_unit_tests
Last change on this file since 71b751d was 2d81cfe, checked in by Paul Kienzle <pkienzle@…>, 6 years ago

lint

  • Property mode set to 100644
File size: 1.4 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
20G Porod. *Kolloid Zeit*. 124 (1951) 83.
21
22L A Feigin, D I Svergun, G W Taylor. *Structure Analysis by Small-Angle
23X-ray and Neutron Scattering*. Springer. (1987)
24"""
25
26import numpy as np
27from numpy import inf, errstate
28
29name = "porod"
30title = "Porod function"
31description = """\
32          I(q) = scale/q^4 + background
33"""
34
35category = "shape-independent"
36
37parameters = []
38
39def Iq(q):
40    """
41    @param q: Input q-value
42    """
43    with errstate(divide='ignore'):
44        return q**-4
45
46Iq.vectorized = True  # Iq accepts an array of q values
47
48def random():
49    sld, solvent = np.random.uniform(-0.5, 12, size=2)
50    radius = 10**np.random.uniform(1, 4.7)
51    Vf = 10**np.random.uniform(-3, -1)
52    scale = 1e-4 * Vf * 2*np.pi*(sld-solvent)**2/(3*radius)
53    pars = dict(
54        scale=scale,
55    )
56    return pars
57
58demo = dict(scale=1.5, background=0.5)
59
60tests = [
61    [{'scale': 0.00001, 'background':0.01}, 0.04, 3.916250],
62    [{}, 0.0, inf],
63]
Note: See TracBrowser for help on using the repository browser.