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

core_shell_microgelsmagnetic_modelticket-1257-vesicle-productticket_1156ticket_1265_superballticket_822_more_unit_tests
Last change on this file since b6422c7 was b297ba9, checked in by Paul Kienzle <pkienzle@…>, 5 years ago

lint

  • Property mode set to 100644
File size: 3.7 KB
RevLine 
[da84551]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::
[30b60d2]11    :nowrap:
[da84551]12
[30b60d2]13    \begin{align*}
[b716cc6]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} \\
[30b60d2]19    \text{scale} &= \text{scale factor}\, N V^1(\rho_\text{particle} - \rho_\text{solvent})^2 \\
[b716cc6]20    V &= \frac{4}{3}\pi R^3
[30b60d2]21    \end{align*}
[da84551]22
[513efc5]23where $R$ is the radius of the building block, $D_S$ is the **surface** fractal
[b716cc6]24dimension, $\xi$ is the cut-off length, $\rho_\text{solvent}$ is the scattering
[5c94f41]25length density of the solvent and $\rho_\text{particle}$ is the scattering
26length density of particles.
[da84551]27
28.. note::
[b716cc6]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.
[da84551]33
34
[95441ff]35References
36----------
[da84551]37
38D Mildner and P Hall, *J. Phys. D: Appl. Phys.*, 19 (1986) 1535-1545
39"""
40
[2d81cfe]41import numpy as np
[da84551]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
[a807206]56        fractal_dim_surf  =  Surface fractal dimension (Ds)
[da84551]57        co_length    =  Cut-off length
58        background   =  background
59
60        Ref.   :Mildner, Hall,J Phys D Appl Phys(1986), 19, 1535-1545
[a807206]61        Note I : This model is valid for 1<fractal_dim_surf<3 with limited q range.
[da84551]62        Note II: This model is not in absolute scale.
63"""
64category = "shape-independent"
65
[168052c]66# pylint: disable=bad-whitespace, line-too-long
[da84551]67#             ["name", "units", default, [lower, upper], "type","description"],
[513efc5]68parameters = [["radius",        "Ang", 10.0, [0, inf],   "",
69               "Particle radius"],
[a807206]70              ["fractal_dim_surf",   "",    2.0,  [1, 3],   "",
[513efc5]71               "Surface fractal dimension"],
72              ["cutoff_length", "Ang", 500., [0.0, inf], "",
73               "Cut-off Length"],
[168052c]74             ]
75# pylint: enable=bad-whitespace, line-too-long
[da84551]76
[925ad6e]77source = ["lib/sas_3j1x_x.c", "lib/sas_gamma.c", "surface_fractal.c"]
[da84551]78
[48462b0]79def random():
[b297ba9]80    """Return a random parameter set for the model."""
[48462b0]81    radius = 10**np.random.uniform(1, 4)
82    fractal_dim_surf = np.random.uniform(1, 3-1e-6)
83    cutoff_length = 1e6  # Sets the low q limit; keep it big for sim
84    pars = dict(
85        #background=0,
86        scale=1,
87        radius=radius,
88        fractal_dim_surf=fractal_dim_surf,
89        cutoff_length=cutoff_length,
90    )
91    return pars
[da84551]92
[07a6700]93tests = [
[168052c]94    # Accuracy tests based on content in test/utest_other_models.py
95    [{'radius': 10.0,
[a807206]96      'fractal_dim_surf': 2.0,
[168052c]97      'cutoff_length': 500.0,
[6dd90c1]98     }, 0.05, 301428.66016],
[168052c]99
100    # Additional tests with larger range of parameters
101    [{'radius': 1.0,
[a807206]102      'fractal_dim_surf': 1.0,
[168052c]103      'cutoff_length': 10.0,
[6dd90c1]104     }, 0.332070182643, 1125.00421004],
[168052c]105
106    [{'radius': 3.5,
[a807206]107      'fractal_dim_surf': 0.1,
[168052c]108      'cutoff_length': 30.0,
109      'background': 0.01,
110     }, 5.0, 0.00999998891322],
111
112    [{'radius': 3.0,
[a807206]113      'fractal_dim_surf': 1.0,
[168052c]114      'cutoff_length': 33.0,
115      'scale': 0.1,
[6dd90c1]116     }, 0.51, 2.50120147004],
[168052c]117    ]
Note: See TracBrowser for help on using the repository browser.