1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138
|
r"""
Calculates the scattering from fractal-like aggregates based on
the Mildner reference.
Definition
----------
The scattering intensity $I(q)$ is calculated as
.. math::
I(q) = scale \times P(q)S(q) + background
.. math::
P(q) = F(qR)^2
.. math::
F(x) = \frac{3\left[sin(x)-xcos(x)\right]}{x^3}
.. math::
S(q) = \frac{\Gamma(D_m-1)\zeta^{D_m-1}}{\left[1+(q\zeta)^2
\right]^{(D_m-1)/2}}
\frac{sin\left[(D_m - 1) tan^{-1}(q\zeta) \right]}{q}
.. math::
scale = scale\_factor \times NV^2(\rho_\text{particle} - \rho_\text{solvent})^2
.. math::
V = \frac{4}{3}\pi R^3
where $R$ is the radius of the building block, $D_m$ is the **mass** fractal
dimension, $\zeta$ is the cut-off length, $\rho_\text{solvent}$ is the
scattering length density of the solvent, and $\rho_\text{particle}$ is the
scattering length density of particles.
.. note::
The mass fractal dimension ( $D_m$ ) is only
valid if $1 < mass\_dim < 6$. It is also only valid over a limited
$q$ range (see the reference for details).
References
----------
#. D Mildner and P Hall,
*J. Phys. D: Appl. Phys.*, 19 (1986) 1535-1545 Equation(9)
Authorship and Verification
----------------------------
* **Author:**
* **Last Modified by:**
* **Last Reviewed by:**
"""
import numpy as np
from numpy import inf
name = "mass_fractal"
title = "Mass Fractal model"
description = """
The scattering intensity I(x) = scale*P(x)*S(x) + background, where
scale = scale_factor * V * delta^(2)
p(x)= F(x*radius)^(2)
F(x) = 3*[sin(x)-x cos(x)]/x**3
S(x) = [(gamma(Dm-1)*colength^(Dm-1)*[1+(x^2*colength^2)]^((1-Dm)/2)
* sin[(Dm-1)*arctan(x*colength)])/x]
where delta = sldParticle -sldSolv.
radius = Particle radius
fractal_dim_mass = Mass fractal dimension
cutoff_length = Cut-off length
background = background
Ref.:Mildner, Hall,J Phys D Appl Phys(1986), 9, 1535-1545
Note I: This model is valid for 1<fractal_dim_mass<6.
Note II: This model is not in absolute scale.
"""
category = "shape-independent"
# pylint: disable=bad-whitespace, line-too-long
# ["name", "units", default, [lower, upper], "type","description"],
parameters = [
["radius", "Ang", 10.0, [0.0, inf], "", "Particle radius"],
["fractal_dim_mass", "", 1.9, [1.0, 6.0], "", "Mass fractal dimension"],
["cutoff_length", "Ang", 100.0, [0.0, inf], "", "Cut-off length"],
]
# pylint: enable=bad-whitespace, line-too-long
source = ["lib/sas_3j1x_x.c", "lib/sas_gamma.c", "mass_fractal.c"]
valid = "fractal_dim_mass >= 1.0"
def random():
"""Return a random parameter set for the model."""
radius = 10**np.random.uniform(0.7, 4)
cutoff_length = 10**np.random.uniform(0.7, 2)*radius
# TODO: fractal dimension should range from 1 to 6
fractal_dim_mass = 2*np.random.beta(3, 4) + 1
#volfrac = 10**np.random.uniform(-4, -1)
pars = dict(
#background=0,
scale=1, #1e5*volfrac/radius**(fractal_dim_mass),
radius=radius,
cutoff_length=cutoff_length,
fractal_dim_mass=fractal_dim_mass,
)
return pars
tests = [
# Accuracy tests based on content in test/utest_other_models.py
[{'radius': 10.0,
'fractal_dim_mass': 1.9,
'cutoff_length': 100.0,
}, 0.05, 279.59422],
# Additional tests with larger range of parameters
[{'radius': 2.0,
'fractal_dim_mass': 3.3,
'cutoff_length': 1.0,
}, 0.5, 1.29116774904],
[{'radius': 1.0,
'fractal_dim_mass': 1.3,
'cutoff_length': 1.0,
'background': 0.8,
}, 0.001, 1.69747015932],
[{'radius': 1.0,
'fractal_dim_mass': 2.3,
'cutoff_length': 1.0,
'scale': 10.0,
}, 0.051, 11.6237966145],
]
|