source: sasmodels/sasmodels/models/spinodal.py @ c88f983

core_shell_microgelsmagnetic_modelticket-1257-vesicle-productticket_1156ticket_1265_superballticket_822_more_unit_tests
Last change on this file since c88f983 was c88f983, checked in by Torin Cooper-Bennun <torin.cooper-bennun@…>, 6 years ago

Merge branch 'master' into beta_approx

  • Property mode set to 100644
File size: 2.8 KB
Line 
1r"""
2Definition
3----------
4
5This model calculates the SAS signal of a phase separating system
6undergoing spinodal decomposition. The scattering intensity $I(q)$ is calculated
7as
8
9.. math::
10    I(q) = I_{max}\frac{(1+\gamma/2)x^2}{\gamma/2+x^{2+\gamma}}+B
11
12where $x=q/q_0$, $q_0$ is the peak position, $I_{max}$ is the intensity
13at $q_0$ (parameterised as the $scale$ parameter), and $B$ is a flat
14background. The spinodal wavelength is given by $2\pi/q_0$.
15
16The exponent $\gamma$ is equal to $d+1$ for off-critical concentration
17mixtures (smooth interfaces) and $2d$ for critical concentration mixtures
18(entangled interfaces), where $d$ is the dimensionality (ie, 1, 2, 3) of the
19system. Thus 2 <= $\gamma$ <= 6. A transition from $\gamma=d+1$ to $\gamma=2d$
20is expected near the percolation threshold.
21
22As this function tends to zero as $q$ tends to zero, in practice it may be
23necessary to combine it with another function describing the low-angle
24scattering, or to simply omit the low-angle scattering from the fit.
25
26References
27----------
28
29H. Furukawa. Dynamics-scaling theory for phase-separating unmixing mixtures:
30Growth rates of droplets and scaling properties of autocorrelation functions.
31Physica A 123,497 (1984).
32
33Revision History
34----------------
35
36* **Author:**  Dirk Honecker **Date:** Oct 7, 2016
37* **Revised:** Steve King    **Date:** Sep 7, 2018
38"""
39
40import numpy as np
41from numpy import inf, errstate
42
43name = "spinodal"
44title = "Spinodal decomposition model"
45description = """\
46      I(q) = Imax ((1+gamma/2)x^2)/(gamma/2+x^(2+gamma)) + background
47
48      List of default parameters:
49     
50      Imax = correlation peak intensity at q_0
51      background = incoherent background
52      gamma = exponent (see model documentation)
53      q_0 = correlation peak position [1/A]
54      x = q/q_0"""
55     
56category = "shape-independent"
57
58# pylint: disable=bad-whitespace, line-too-long
59#             ["name", "units", default, [lower, upper], "type", "description"],
60parameters = [["gamma",      "",    3.0, [-inf, inf], "", "Exponent"],
61              ["q_0",  "1/Ang",     0.1, [-inf, inf], "", "Correlation peak position"]
62             ]
63# pylint: enable=bad-whitespace, line-too-long
64
65def Iq(q,
66       gamma=3.0,
67       q_0=0.1):
68    """
69    :param q:              Input q-value
70    :param gamma:          Exponent
71    :param q_0:            Correlation peak position
72    :return:               Calculated intensity
73    """
74    with errstate(divide='ignore'):
75        x = q/q_0
76        inten = ((1 + gamma / 2) * x ** 2) / (gamma / 2 + x ** (2 + gamma))
77    return inten
78Iq.vectorized = True  # Iq accepts an array of q values
79
80def random():
81    pars = dict(
82        scale=10**np.random.uniform(1, 3),
83        gamma=np.random.uniform(0, 6),
84        q_0=10**np.random.uniform(-3, -1),
85    )
86    return pars
87
88demo = dict(scale=1, background=0,
89            gamma=1, q_0=0.1)
Note: See TracBrowser for help on using the repository browser.