# source:sasmodels/sasmodels/models/surface_fractal.py@0507e09

core_shell_microgelsmagnetic_modelticket-1257-vesicle-productticket_1156ticket_1265_superballticket_822_more_unit_tests
Last change on this file since 0507e09 was 0507e09, checked in by smk78, 6 months ago

Added link to source code to each model. Closes #883

• Property mode set to 100644
File size: 4.1 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
40Source
41------
42
43surface_fractal.py <https://github.com/SasView/sasmodels/blob/master/sasmodels/models/surface_fractal.py>_
44
45surface_fractal.c <https://github.com/SasView/sasmodels/blob/master/sasmodels/models/surface_fractal.c>_
46
47Authorship and Verification
48----------------------------
49
50* **Author:**
51* **Last Modified by:**
52* **Last Reviewed by:**
53* **Source added by :** Steve King **Date:** March 25, 2019
54"""
55
56import numpy as np
57from numpy import inf
58
59name = "surface_fractal"
60title = "Fractal-like aggregates based on the Mildner reference"
61description = """\
62    [The scattering intensity  I(x) = scale*P(x)*S(x) + background, where
63        scale = scale_factor  * V * delta^(2)
64        p(x) = F(x*radius)^(2)
65        F(x) = 3*[sin(x)-x cos(x)]/x**3
66        S(x) = [(gamma(5-Ds)*colength^(5-Ds)*[1+(x^2*colength^2)]^((Ds-5)/2)
67             * sin[(Ds-5)*arctan(x*colength)])/x]
68        where
69        delta        =  sldParticle -sldSolv.
70        radius       =  Particle radius
71        fractal_dim_surf  =  Surface fractal dimension (Ds)
72        co_length    =  Cut-off length
73        background   =  background
74
75        Ref.   :Mildner, Hall,J Phys D Appl Phys(1986), 19, 1535-1545
76        Note I : This model is valid for 1<fractal_dim_surf<3 with limited q range.
77        Note II: This model is not in absolute scale.
78"""
79category = "shape-independent"
80
81# pylint: disable=bad-whitespace, line-too-long
82#             ["name", "units", default, [lower, upper], "type","description"],
83parameters = [["radius",        "Ang", 10.0, [0, inf],   "",
84               "Particle radius"],
85              ["fractal_dim_surf",   "",    2.0,  [1, 3],   "",
86               "Surface fractal dimension"],
87              ["cutoff_length", "Ang", 500., [0.0, inf], "",
88               "Cut-off Length"],
89             ]
90# pylint: enable=bad-whitespace, line-too-long
91
92source = ["lib/sas_3j1x_x.c", "lib/sas_gamma.c", "surface_fractal.c"]
93
94def random():
95    """Return a random parameter set for the model."""
96    radius = 10**np.random.uniform(1, 4)
97    fractal_dim_surf = np.random.uniform(1, 3-1e-6)
98    cutoff_length = 1e6  # Sets the low q limit; keep it big for sim
99    pars = dict(
100        #background=0,
101        scale=1,
102        radius=radius,
103        fractal_dim_surf=fractal_dim_surf,
104        cutoff_length=cutoff_length,
105    )
106    return pars
107
108tests = [
109    # Accuracy tests based on content in test/utest_other_models.py
110    [{'radius': 10.0,
111      'fractal_dim_surf': 2.0,
112      'cutoff_length': 500.0,
113     }, 0.05, 301428.66016],
114
115    # Additional tests with larger range of parameters
116    [{'radius': 1.0,
117      'fractal_dim_surf': 1.0,
118      'cutoff_length': 10.0,
119     }, 0.332070182643, 1125.00421004],
120
121    [{'radius': 3.5,
122      'fractal_dim_surf': 0.1,
123      'cutoff_length': 30.0,
124      'background': 0.01,
125     }, 5.0, 0.00999998891322],
126
127    [{'radius': 3.0,
128      'fractal_dim_surf': 1.0,
129      'cutoff_length': 33.0,
130      'scale': 0.1,
131     }, 0.51, 2.50120147004],
132    ]
Note: See TracBrowser for help on using the repository browser.