source: sasmodels/sasmodels/models/mass_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, 5 years ago

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

  • Property mode set to 100644
File size: 4.2 KB
RevLine 
[5c1d341]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
[232bb12]30    scale = scale\_factor \times NV^2(\rho_\text{particle} - \rho_\text{solvent})^2
[5c1d341]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
[232bb12]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.
[5c1d341]40
41.. note::
42
43    The mass fractal dimension ( $D_m$ ) is only
[232bb12]44    valid if $1 < mass\_dim < 6$. It is also only valid over a limited
[5c1d341]45    $q$ range (see the reference for details).
46
47
[95441ff]48References
49----------
[5c1d341]50
[0507e09]51.. [#] D Mildner and P Hall, *J. Phys. D: Appl. Phys.*, 19 (1986) 1535-1545 Equation(9)
52
53Source
54------
55
56`mass_fractal.py <https://github.com/SasView/sasmodels/blob/master/sasmodels/models/mass_fractal.py>`_
57
58`mass_fractal.c <https://github.com/SasView/sasmodels/blob/master/sasmodels/models/mass_fractal.c>`_
59
60Authorship and Verification
61----------------------------
62
63* **Author:**
64* **Last Modified by:**
65* **Last Reviewed by:**
66* **Source added by :** Steve King **Date:** March 25, 2019"""
[5c1d341]67
[2d81cfe]68import numpy as np
[5c1d341]69from numpy import inf
70
71name = "mass_fractal"
72title = "Mass Fractal model"
73description = """
74        The scattering intensity  I(x) = scale*P(x)*S(x) + background, where
75        scale = scale_factor  * V * delta^(2)
76        p(x)=  F(x*radius)^(2)
77        F(x) = 3*[sin(x)-x cos(x)]/x**3
78        S(x) = [(gamma(Dm-1)*colength^(Dm-1)*[1+(x^2*colength^2)]^((1-Dm)/2)
79        * sin[(Dm-1)*arctan(x*colength)])/x]
80        where delta = sldParticle -sldSolv.
81        radius       =  Particle radius
[a807206]82        fractal_dim_mass  =  Mass fractal dimension
[5c1d341]83        cutoff_length  =  Cut-off length
84        background   =  background
85        Ref.:Mildner, Hall,J Phys D Appl Phys(1986), 9, 1535-1545
[a807206]86        Note I: This model is valid for 1<fractal_dim_mass<6.
[5c1d341]87        Note II: This model is not in absolute scale.
88        """
89category = "shape-independent"
90
[168052c]91# pylint: disable=bad-whitespace, line-too-long
[6d96b66]92#   ["name", "units", default, [lower, upper], "type","description"],
93parameters = [
94    ["radius",           "Ang",  10.0, [0.0, inf], "", "Particle radius"],
95    ["fractal_dim_mass", "",      1.9, [1.0, 6.0], "", "Mass fractal dimension"],
96    ["cutoff_length",    "Ang", 100.0, [0.0, inf], "", "Cut-off length"],
97]
[168052c]98# pylint: enable=bad-whitespace, line-too-long
[5c1d341]99
[925ad6e]100source = ["lib/sas_3j1x_x.c", "lib/sas_gamma.c", "mass_fractal.c"]
[5c1d341]101
[404ebbd]102def random():
[b297ba9]103    """Return a random parameter set for the model."""
[404ebbd]104    radius = 10**np.random.uniform(0.7, 4)
105    cutoff_length = 10**np.random.uniform(0.7, 2)*radius
[4553dae]106    # TODO: fractal dimension should range from 1 to 6
[404ebbd]107    fractal_dim_mass = 2*np.random.beta(3, 4) + 1
[2d81cfe]108    #volfrac = 10**np.random.uniform(-4, -1)
[404ebbd]109    pars = dict(
110        #background=0,
[2d81cfe]111        scale=1, #1e5*volfrac/radius**(fractal_dim_mass),
[404ebbd]112        radius=radius,
113        cutoff_length=cutoff_length,
114        fractal_dim_mass=fractal_dim_mass,
115    )
116    return pars
117
[5c1d341]118demo = dict(scale=1, background=0,
119            radius=10.0,
[a807206]120            fractal_dim_mass=1.9,
[87edabf]121            cutoff_length=100.0)
[5c1d341]122
[07a6700]123tests = [
[168052c]124
125    # Accuracy tests based on content in test/utest_other_models.py
126    [{'radius':         10.0,
[a807206]127      'fractal_dim_mass':        1.9,
[168052c]128      'cutoff_length': 100.0,
[6dd90c1]129     }, 0.05, 279.59422],
[168052c]130
131    # Additional tests with larger range of parameters
132    [{'radius':        2.0,
[a807206]133      'fractal_dim_mass':      3.3,
[168052c]134      'cutoff_length': 1.0,
[6dd90c1]135     }, 0.5, 1.29116774904],
[168052c]136
137    [{'radius':        1.0,
[a807206]138      'fractal_dim_mass':      1.3,
[168052c]139      'cutoff_length': 1.0,
140      'background':    0.8,
141     }, 0.001, 1.69747015932],
142
143    [{'radius':        1.0,
[a807206]144      'fractal_dim_mass':      2.3,
[168052c]145      'cutoff_length': 1.0,
146      'scale':        10.0,
[6dd90c1]147     }, 0.051, 11.6237966145],
[168052c]148    ]
Note: See TracBrowser for help on using the repository browser.