source: sasmodels/sasmodels/models/surface_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.8 KB
Line 
1r"""
2This model calculates the scattering from fractal-like aggregates based
3on the Mildner reference.
4
5Definition
6----------
7
8The scattering intensity $I(q)$ is calculated as
9
10.. math::
11    :nowrap:
12
13    \begin{align*}
14    I(q) &= \text{scale} \times P(q)S(q) + \text{background} \\
15    P(q) &= F(qR)^2 \\
16    F(x) &= \frac{3\left[\sin(x)-x\cos(x)\right]}{x^3} \\
17    S(q) &= \Gamma(5-D_S)\xi^{\,5-D_S}\left[1+(q\xi)^2 \right]^{-(5-D_S)/2}
18            \sin\left[-(5-D_S) \tan^{-1}(q\xi) \right] q^{-1} \\
19    \text{scale} &= \text{scale factor}\, N V^1(\rho_\text{particle} - \rho_\text{solvent})^2 \\
20    V &= \frac{4}{3}\pi R^3
21    \end{align*}
22
23where $R$ is the radius of the building block, $D_S$ is the **surface** fractal
24dimension, $\xi$ is the cut-off length, $\rho_\text{solvent}$ is the scattering
25length density of the solvent and $\rho_\text{particle}$ is the scattering
26length density of particles.
27
28.. note::
29
30    The surface fractal dimension is only valid if $1<D_S<3$. The result is
31    only valid over a limited $q$ range, $\tfrac{5}{3-D_S}\xi^{\,-1} < q < R^{-1}$.
32    See the reference for details.
33
34
35References
36----------
37
38.. [#] D Mildner and P Hall, *J. Phys. D: Appl. Phys.*, 19 (1986) 1535-1545
39
40Authorship and Verification
41----------------------------
42
43* **Author:**
44* **Last Modified by:**
45* **Last Reviewed by:**
46"""
47
48import numpy as np
49from numpy import inf
50
51name = "surface_fractal"
52title = "Fractal-like aggregates based on the Mildner reference"
53description = """\
54    [The scattering intensity  I(x) = scale*P(x)*S(x) + background, where
55        scale = scale_factor  * V * delta^(2)
56        p(x) = F(x*radius)^(2)
57        F(x) = 3*[sin(x)-x cos(x)]/x**3
58        S(x) = [(gamma(5-Ds)*colength^(5-Ds)*[1+(x^2*colength^2)]^((Ds-5)/2)
59             * sin[(Ds-5)*arctan(x*colength)])/x]
60        where
61        delta        =  sldParticle -sldSolv.
62        radius       =  Particle radius
63        fractal_dim_surf  =  Surface fractal dimension (Ds)
64        co_length    =  Cut-off length
65        background   =  background
66
67        Ref.   :Mildner, Hall,J Phys D Appl Phys(1986), 19, 1535-1545
68        Note I : This model is valid for 1<fractal_dim_surf<3 with limited q range.
69        Note II: This model is not in absolute scale.
70"""
71category = "shape-independent"
72
73# pylint: disable=bad-whitespace, line-too-long
74#             ["name", "units", default, [lower, upper], "type","description"],
75parameters = [["radius",        "Ang", 10.0, [0, inf],   "",
76               "Particle radius"],
77              ["fractal_dim_surf",   "",    2.0,  [1, 3],   "",
78               "Surface fractal dimension"],
79              ["cutoff_length", "Ang", 500., [0.0, inf], "",
80               "Cut-off Length"],
81             ]
82# pylint: enable=bad-whitespace, line-too-long
83
84source = ["lib/sas_3j1x_x.c", "lib/sas_gamma.c", "surface_fractal.c"]
85
86def random():
87    """Return a random parameter set for the model."""
88    radius = 10**np.random.uniform(1, 4)
89    fractal_dim_surf = np.random.uniform(1, 3-1e-6)
90    cutoff_length = 1e6  # Sets the low q limit; keep it big for sim
91    pars = dict(
92        #background=0,
93        scale=1,
94        radius=radius,
95        fractal_dim_surf=fractal_dim_surf,
96        cutoff_length=cutoff_length,
97    )
98    return pars
99
100tests = [
101    # Accuracy tests based on content in test/utest_other_models.py
102    [{'radius': 10.0,
103      'fractal_dim_surf': 2.0,
104      'cutoff_length': 500.0,
105     }, 0.05, 301428.66016],
106
107    # Additional tests with larger range of parameters
108    [{'radius': 1.0,
109      'fractal_dim_surf': 1.0,
110      'cutoff_length': 10.0,
111     }, 0.332070182643, 1125.00421004],
112
113    [{'radius': 3.5,
114      'fractal_dim_surf': 0.1,
115      'cutoff_length': 30.0,
116      'background': 0.01,
117     }, 5.0, 0.00999998891322],
118
119    [{'radius': 3.0,
120      'fractal_dim_surf': 1.0,
121      'cutoff_length': 33.0,
122      'scale': 0.1,
123     }, 0.51, 2.50120147004],
124    ]
Note: See TracBrowser for help on using the repository browser.