source: sasmodels/sasmodels/models/mass_surface_fractal.py @ 2ba5ba5

core_shell_microgelscostrafo411magnetic_modelticket-1257-vesicle-productticket_1156ticket_1265_superballticket_822_more_unit_tests
Last change on this file since 2ba5ba5 was 232bb12, checked in by Paul Kienzle <pkienzle@…>, 7 years ago

tuned random model generation for models

  • Property mode set to 100644
File size: 4.8 KB
Line 
1r"""
2
3A number of natural and commercial processes form high-surface area materials
4as a result of the vapour-phase aggregation of primary particles.
5Examples of such materials include soots, aerosols, and fume or pyrogenic
6silicas. These are all characterised by cluster mass distributions (sometimes
7also cluster size distributions) and internal surfaces that are fractal in
8nature. The scattering from such materials displays two distinct breaks in
9log-log representation, corresponding to the radius-of-gyration of the primary
10particles, $rg$, and the radius-of-gyration of the clusters (aggregates),
11$Rg$. Between these boundaries the scattering follows a power law related to
12the mass fractal dimension, $Dm$, whilst above the high-Q boundary the
13scattering follows a power law related to the surface fractal dimension of
14the primary particles, $Ds$.
15
16Definition
17----------
18
19The scattered intensity I(q) is calculated using a modified
20Ornstein-Zernicke equation
21
22.. math::
23
24    I(q) = scale \times P(q) + background
25
26    P(q) = \left\{ \left[ 1+(q^2a)\right]^{D_m/2} \times
27                   \left[ 1+(q^2b)\right]^{(6-D_s-D_m)/2}
28           \right\}^{-1}
29
30    a = R_{g}^2/(3D_m/2)
31
32    b = r_{g}^2/[-3(D_s+D_m-6)/2]
33
34    scale = scale\_factor \times NV^2 (\rho_{particle} - \rho_{solvent})^2
35
36where $R_g$ is the size of the cluster, $r_g$ is the size of the primary
37particle, $D_s$ is the surface fractal dimension, $D_m$ is the mass fractal
38dimension, $\rho_{solvent}$ is the scattering length density of the solvent,
39and $\rho_{particle}$ is the scattering length density of particles.
40
41.. note::
42
43    The surface ( $D_s$ ) and mass ( $D_m$ ) fractal dimensions are only
44    valid if $0 < surface\_dim < 6$ , $0 < mass\_dim < 6$ , and
45    $(surface\_dim + mass\_dim ) < 6$ .
46
47
48References
49----------
50
51P Schmidt, *J Appl. Cryst.*, 24 (1991) 414-435 Equation(19)
52
53A J Hurd, D W Schaefer, J E Martin, *Phys. Rev. A*,
5435 (1987) 2361-2364 Equation(2)
55
56"""
57
58from numpy import inf
59
60name = "mass_surface_fractal"
61title = "Mass Surface Fractal model"
62description = """
63        The scattering intensity  I(x) = scale*P(x)*S(x) + background, where
64        p(x)= {[1+(x^2*a)]^(Dm/2) * [1+(x^2*b)]^(6-Ds-Dm)/2}^(-1)
65        a = Rg^2/(3*Dm/2)
66        b = rg^2/(3*(6-Ds-Dm)/2)
67        scale        =  scale factor * N*Volume^2*contrast^2
68        fractal_dim_mass       =  Dm (mass fractal dimension)
69        fractal_dim_surf  =  Ds
70        rg_cluster  =  Rg
71        rg_primary    =  rg
72        background   =  background
73        Ref: Schmidt, J Appl Cryst, eq(19), (1991), 24, 414-435
74        Hurd, Schaefer, Martin, Phys Rev A, eq(2),(1987),35, 2361-2364
75        Note that 0 < Ds< 6 and 0 < Dm < 6.
76        """
77category = "shape-independent"
78
79# pylint: disable=bad-whitespace, line-too-long
80#   ["name", "units", default, [lower, upper], "type","description"],
81parameters = [
82    ["fractal_dim_mass", "",      1.8, [0.0, 6.0], "", "Mass fractal dimension"],
83    ["fractal_dim_surf", "",      2.3, [0.0, 6.0], "", "Surface fractal dimension"],
84    ["rg_cluster",       "Ang",  86.7, [0.0, inf], "", "Cluster radius of gyration"],
85    ["rg_primary",       "Ang", 4000., [0.0, inf], "", "Primary particle radius of gyration"],
86]
87# pylint: enable=bad-whitespace, line-too-long
88
89source = ["mass_surface_fractal.c"]
90
91def random():
92    import numpy as np
93    fractal_dim = np.random.uniform(0, 6)
94    surface_portion = np.random.uniform(0, 1)
95    fractal_dim_surf = fractal_dim*surface_portion
96    fractal_dim_mass = fractal_dim - fractal_dim_surf
97    rg_cluster = 10**np.random.uniform(1, 5)
98    rg_primary = rg_cluster*10**np.random.uniform(-4, -1)
99    scale = 10**np.random.uniform(2, 5)
100    pars = dict(
101        #background=0,
102        scale=scale,
103        fractal_dim_mass=fractal_dim_mass,
104        fractal_dim_surf=fractal_dim_surf,
105        rg_cluster=rg_cluster,
106        rg_primary=rg_primary,
107    )
108    return pars
109
110
111demo = dict(scale=1, background=0,
112            fractal_dim_mass=1.8,
113            fractal_dim_surf=2.3,
114            rg_cluster=86.7,
115            rg_primary=4000.0)
116
117tests = [
118
119    # Accuracy tests based on content in test/utest_other_models.py
120    [{'fractal_dim_mass':      1.8,
121      'fractal_dim_surf':   2.3,
122      'rg_cluster':   86.7,
123      'rg_primary': 4000.0,
124      'background':    0.0,
125     }, 0.05, 1.77537e-05],
126
127    # Additional tests with larger range of parameters
128    [{'fractal_dim_mass':      3.3,
129      'fractal_dim_surf':   1.0,
130      'rg_cluster':   90.0,
131      'rg_primary': 4000.0,
132     }, 0.001, 0.18562699016],
133
134    [{'fractal_dim_mass':      1.3,
135      'fractal_dim_surf':   1.0,
136      'rg_cluster':   90.0,
137      'rg_primary': 2000.0,
138      'background':    0.8,
139     }, 0.001, 1.16539753641],
140
141    [{'fractal_dim_mass':      2.3,
142      'fractal_dim_surf':   1.0,
143      'rg_cluster':   90.0,
144      'rg_primary': 1000.0,
145      'scale':        10.0,
146      'background':    0.0,
147     }, 0.051, 0.000169548800377],
148    ]
Note: See TracBrowser for help on using the repository browser.