1 | r""" |
---|
2 | Definition |
---|
3 | ---------- |
---|
4 | This model calculates the scattering from fractal-like aggregates of spherical |
---|
5 | building blocks according the following equation: |
---|
6 | |
---|
7 | .. math:: |
---|
8 | |
---|
9 | I(q) = \phi\ V_\text{block} (\rho_\text{block} |
---|
10 | - \rho_\text{solvent})^2 P(q)S(q) + \text{background} |
---|
11 | |
---|
12 | where $\phi$ is The volume fraction of the spherical "building block" particles |
---|
13 | of radius $R_0$, $V_{block}$ is the volume of a single building block, |
---|
14 | $\rho_{solvent}$ is the scattering length density of the solvent, and |
---|
15 | $\rho_{block}$ is the scattering length density of the building blocks, and |
---|
16 | P(q), S(q) are the scattering from randomly distributed spherical particles |
---|
17 | (the building blocks) and the interference from such building blocks organized |
---|
18 | in a fractal-like clusters. P(q) and S(q) are calculated as: |
---|
19 | |
---|
20 | .. math:: |
---|
21 | |
---|
22 | P(q)&= F(qR_0)^2 \\ |
---|
23 | F(q)&= \frac{3 (\sin x - x \cos x)}{x^3} \\ |
---|
24 | V_\text{particle} &= \frac{4}{3}\ \pi R_0 \\ |
---|
25 | S(q) &= 1 + \frac{D_f\ \Gamma\!(D_f-1)}{[1+1/(q \xi)^2\ ]^{(D_f -1)/2}} |
---|
26 | \frac{\sin[(D_f-1) \tan^{-1}(q \xi) ]}{(q R_0)^{D_f}} |
---|
27 | |
---|
28 | where $\xi$ is the correlation length representing the cluster size and $D_f$ |
---|
29 | is the fractal dimension, representing the self similarity of the structure. |
---|
30 | Note that S(q) here goes negative if $D_f$ is too large, and the Gamma function |
---|
31 | diverges at $D_f=0$ and $D_f=1$. |
---|
32 | |
---|
33 | **Polydispersity on the radius is provided for.** |
---|
34 | |
---|
35 | For 2D data: The 2D scattering intensity is calculated in the same way as |
---|
36 | 1D, where the *q* vector is defined as |
---|
37 | |
---|
38 | .. math:: |
---|
39 | |
---|
40 | q = \sqrt{q_x^2 + q_y^2} |
---|
41 | |
---|
42 | |
---|
43 | References |
---|
44 | ---------- |
---|
45 | |
---|
46 | .. [#] J Teixeira, *J. Appl. Cryst.*, 21 (1988) 781-785 |
---|
47 | |
---|
48 | Source |
---|
49 | ------ |
---|
50 | |
---|
51 | `fractal.py <https://github.com/SasView/sasmodels/blob/master/sasmodels/models/fractal.py>`_ |
---|
52 | |
---|
53 | `fractal.c <https://github.com/SasView/sasmodels/blob/master/sasmodels/models/fractal.c>`_ |
---|
54 | |
---|
55 | Authorship and Verification |
---|
56 | ---------------------------- |
---|
57 | |
---|
58 | * **Author:** NIST IGOR/DANSE **Date:** pre 2010 |
---|
59 | * **Converted to sasmodels by:** Paul Butler **Date:** March 19, 2016 |
---|
60 | * **Last Modified by:** Paul Butler **Date:** March 12, 2017 |
---|
61 | * **Last Reviewed by:** Paul Butler **Date:** March 12, 2017 |
---|
62 | * **Source added by :** Steve King **Date:** March 25, 2019 |
---|
63 | """ |
---|
64 | from __future__ import division |
---|
65 | |
---|
66 | import numpy as np |
---|
67 | from numpy import inf |
---|
68 | |
---|
69 | name = "fractal" |
---|
70 | title = "Calculates the scattering from fractal-like aggregates of spheres \ |
---|
71 | following theTexiera reference." |
---|
72 | description = """ |
---|
73 | The scattering intensity is given by |
---|
74 | I(q) = scale * V * delta^(2) * P(q) * S(q) + background, where |
---|
75 | p(q)= F(q*radius)^(2) |
---|
76 | F(x) = 3*[sin(x)-x cos(x)]/x**3 |
---|
77 | delta = sld_block -sld_solv |
---|
78 | scale = scale * volfraction |
---|
79 | radius = Block radius |
---|
80 | sld_block = SDL block |
---|
81 | sld_solv = SDL solvent |
---|
82 | background = background |
---|
83 | and S(q) is the interference term between building blocks given |
---|
84 | in the full documentation and depending on the parameters |
---|
85 | fractal_dim = Fractal dimension |
---|
86 | cor_length = Correlation Length """ |
---|
87 | |
---|
88 | category = "shape-independent" |
---|
89 | |
---|
90 | # pylint: disable=bad-whitespace, line-too-long |
---|
91 | # ["name", "units", default, [lower, upper], "type","description"], |
---|
92 | parameters = [["volfraction", "", 0.05, [0.0, 1], "", |
---|
93 | "volume fraction of blocks"], |
---|
94 | ["radius", "Ang", 5.0, [0.0, inf], "volume", |
---|
95 | "radius of particles"], |
---|
96 | ["fractal_dim", "", 2.0, [0.0, 6.0], "", |
---|
97 | "fractal dimension"], |
---|
98 | ["cor_length", "Ang", 100.0, [0.0, inf], "", |
---|
99 | "cluster correlation length"], |
---|
100 | ["sld_block", "1e-6/Ang^2", 2.0, [-inf, inf], "sld", |
---|
101 | "scattering length density of particles"], |
---|
102 | ["sld_solvent", "1e-6/Ang^2", 6.4, [-inf, inf], "sld", |
---|
103 | "scattering length density of solvent"], |
---|
104 | ] |
---|
105 | # pylint: enable=bad-whitespace, line-too-long |
---|
106 | |
---|
107 | source = ["lib/sas_3j1x_x.c", "lib/sas_gamma.c", "lib/fractal_sq.c", "fractal.c"] |
---|
108 | |
---|
109 | def random(): |
---|
110 | """Return a random parameter set for the model.""" |
---|
111 | radius = 10**np.random.uniform(0.7, 4) |
---|
112 | #radius = 5 |
---|
113 | cor_length = 10**np.random.uniform(0.7, 2)*radius |
---|
114 | #cor_length = 20*radius |
---|
115 | volfraction = 10**np.random.uniform(-3, -1) |
---|
116 | #volfraction = 0.05 |
---|
117 | fractal_dim = 2*np.random.beta(3, 4) + 1 |
---|
118 | #fractal_dim = 2 |
---|
119 | pars = dict( |
---|
120 | #background=0, sld_block=1, sld_solvent=0, |
---|
121 | volfraction=volfraction, |
---|
122 | radius=radius, |
---|
123 | cor_length=cor_length, |
---|
124 | fractal_dim=fractal_dim, |
---|
125 | ) |
---|
126 | return pars |
---|
127 | |
---|
128 | demo = dict(volfraction=0.05, |
---|
129 | radius=5.0, |
---|
130 | fractal_dim=2.0, |
---|
131 | cor_length=100.0, |
---|
132 | sld_block=2.0, |
---|
133 | sld_solvent=6.4) |
---|
134 | |
---|
135 | # NOTE: test results taken from values returned by SasView 3.1.2 |
---|
136 | tests = [ |
---|
137 | [{}, 0.0005, 40.4980069872], |
---|
138 | [{}, 0.234734468938, 0.0947143166058], |
---|
139 | [{}, 0.5, 0.0176878183458], |
---|
140 | ] |
---|