source: sasmodels/sasmodels/models/surface_fractal.py @ ef07e95

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

lint

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