source: sasmodels/sasmodels/models/mass_fractal.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: 3.9 KB
Line 
1r"""
2Calculates the scattering from fractal-like aggregates based on
3the Mildner reference.
4
5Definition
6----------
7
8The scattering intensity $I(q)$ is calculated as
9
10.. math::
11
12    I(q) = scale \times P(q)S(q) + background
13
14.. math::
15
16    P(q) = F(qR)^2
17
18.. math::
19
20    F(x) = \frac{3\left[sin(x)-xcos(x)\right]}{x^3}
21
22.. math::
23
24    S(q) = \frac{\Gamma(D_m-1)\zeta^{D_m-1}}{\left[1+(q\zeta)^2
25    \right]^{(D_m-1)/2}}
26    \frac{sin\left[(D_m - 1) tan^{-1}(q\zeta) \right]}{q}
27
28.. math::
29
30    scale = scale\_factor \times NV^2(\rho_\text{particle} - \rho_\text{solvent})^2
31
32.. math::
33
34    V = \frac{4}{3}\pi R^3
35
36where $R$ is the radius of the building block, $D_m$ is the **mass** fractal
37dimension, $\zeta$  is the cut-off length, $\rho_\text{solvent}$ is the scattering
38length density of the solvent, and $\rho_\text{particle}$ is the scattering
39length density of particles.
40
41.. note::
42
43    The mass fractal dimension ( $D_m$ ) is only
44    valid if $1 < mass\_dim < 6$. It is also only valid over a limited
45    $q$ range (see the reference for details).
46
47
48References
49----------
50
51.. [#] D Mildner and P Hall, *J. Phys. D: Appl. Phys.*, 19 (1986) 1535-1545 Equation(9)
52
53Authorship and Verification
54----------------------------
55
56* **Author:**
57* **Last Modified by:**
58* **Last Reviewed by:**
59"""
60
61import numpy as np
62from numpy import inf
63
64name = "mass_fractal"
65title = "Mass Fractal model"
66description = """
67        The scattering intensity  I(x) = scale*P(x)*S(x) + background, where
68        scale = scale_factor  * V * delta^(2)
69        p(x)=  F(x*radius)^(2)
70        F(x) = 3*[sin(x)-x cos(x)]/x**3
71        S(x) = [(gamma(Dm-1)*colength^(Dm-1)*[1+(x^2*colength^2)]^((1-Dm)/2)
72        * sin[(Dm-1)*arctan(x*colength)])/x]
73        where delta = sldParticle -sldSolv.
74        radius       =  Particle radius
75        fractal_dim_mass  =  Mass fractal dimension
76        cutoff_length  =  Cut-off length
77        background   =  background
78        Ref.:Mildner, Hall,J Phys D Appl Phys(1986), 9, 1535-1545
79        Note I: This model is valid for 1<fractal_dim_mass<6.
80        Note II: This model is not in absolute scale.
81        """
82category = "shape-independent"
83
84# pylint: disable=bad-whitespace, line-too-long
85#   ["name", "units", default, [lower, upper], "type","description"],
86parameters = [
87    ["radius",           "Ang",  10.0, [0.0, inf], "", "Particle radius"],
88    ["fractal_dim_mass", "",      1.9, [1.0, 6.0], "", "Mass fractal dimension"],
89    ["cutoff_length",    "Ang", 100.0, [0.0, inf], "", "Cut-off length"],
90]
91# pylint: enable=bad-whitespace, line-too-long
92
93source = ["lib/sas_3j1x_x.c", "lib/sas_gamma.c", "mass_fractal.c"]
94
95def random():
96    """Return a random parameter set for the model."""
97    radius = 10**np.random.uniform(0.7, 4)
98    cutoff_length = 10**np.random.uniform(0.7, 2)*radius
99    # TODO: fractal dimension should range from 1 to 6
100    fractal_dim_mass = 2*np.random.beta(3, 4) + 1
101    #volfrac = 10**np.random.uniform(-4, -1)
102    pars = dict(
103        #background=0,
104        scale=1, #1e5*volfrac/radius**(fractal_dim_mass),
105        radius=radius,
106        cutoff_length=cutoff_length,
107        fractal_dim_mass=fractal_dim_mass,
108    )
109    return pars
110
111demo = dict(scale=1, background=0,
112            radius=10.0,
113            fractal_dim_mass=1.9,
114            cutoff_length=100.0)
115
116tests = [
117
118    # Accuracy tests based on content in test/utest_other_models.py
119    [{'radius':         10.0,
120      'fractal_dim_mass':        1.9,
121      'cutoff_length': 100.0,
122     }, 0.05, 279.59422],
123
124    # Additional tests with larger range of parameters
125    [{'radius':        2.0,
126      'fractal_dim_mass':      3.3,
127      'cutoff_length': 1.0,
128     }, 0.5, 1.29116774904],
129
130    [{'radius':        1.0,
131      'fractal_dim_mass':      1.3,
132      'cutoff_length': 1.0,
133      'background':    0.8,
134     }, 0.001, 1.69747015932],
135
136    [{'radius':        1.0,
137      'fractal_dim_mass':      2.3,
138      'cutoff_length': 1.0,
139      'scale':        10.0,
140     }, 0.051, 11.6237966145],
141    ]
Note: See TracBrowser for help on using the repository browser.