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

core_shell_microgelsmagnetic_modelticket-1257-vesicle-productticket_1156ticket_1265_superballticket_822_more_unit_tests
Last change on this file since a839b22 was 48462b0, checked in by Paul Kienzle <pkienzle@…>, 7 years ago

tuned random model generation for even more models

  • Property mode set to 100644
File size: 2.4 KB
Line 
1r"""
2Definition
3----------
4
5This model calculates the SAS signal of a phase separating solution under spinodal decomposition.
6The scattering intensity $I(q)$ is calculated as
7
8.. math::
9    I(q) = I_{max}\frac{(1+\gamma/2)x^2}{\gamma/2+x^{2+\gamma}}+B
10
11where $x=q/q_0$ and $B$ is a flat background. The characteristic structure length
12scales with the correlation peak at $q_0$. The exponent $\gamma$ is equal to
13$d+1$ with d the dimensionality of the off-critical concentration mixtures.
14A transition to $\gamma=2d$ is seen near the percolation threshold into the
15critical concentration regime.
16
17References
18----------
19
20H. Furukawa. Dynamics-scaling theory for phase-separating unmixing mixtures:
21Growth rates of droplets and scaling properties of autocorrelation functions. Physica A 123,497 (1984).
22
23Authorship and Verification
24----------------------------
25
26* **Author:** Dirk Honecker **Date:** Oct 7, 2016
27* **Last Modified by:**
28* **Last Reviewed by:**
29"""
30
31from numpy import inf, errstate
32
33name = "spinodal"
34title = "Spinodal decomposition model"
35description = """\
36      I(q) = scale ((1+gamma/2)x^2)/(gamma/2+x^(2+gamma))+background
37
38      List of default parameters:
39      scale = scaling
40      gamma = exponent
41      x = q/q_0
42      q_0 = correlation peak position [1/A]
43      background = Incoherent background"""
44category = "shape-independent"
45
46# pylint: disable=bad-whitespace, line-too-long
47#             ["name", "units", default, [lower, upper], "type", "description"],
48parameters = [["gamma",      "",    3.0, [-inf, inf], "", "Exponent"],
49              ["q_0",  "1/Ang",     0.1, [-inf, inf], "", "Correlation peak position"]
50             ]
51# pylint: enable=bad-whitespace, line-too-long
52
53def Iq(q,
54       gamma=3.0,
55       q_0=0.1):
56    """
57    :param q:              Input q-value
58    :param gamma:          Exponent
59    :param q_0:            Correlation peak position
60    :return:               Calculated intensity
61    """
62
63    with errstate(divide='ignore'):
64        x = q/q_0
65        inten = ((1 + gamma / 2) * x ** 2) / (gamma / 2 + x ** (2 + gamma))
66    return inten
67Iq.vectorized = True  # Iq accepts an array of q values
68
69def random():
70    import numpy as np
71    pars = dict(
72        scale=10**np.random.uniform(1, 3),
73        gamma=np.random.uniform(0, 6),
74        q_0=10**np.random.uniform(-3, -1),
75    )
76    return pars
77
78demo = dict(scale=1, background=0,
79            gamma=1, q_0=0.1)
Note: See TracBrowser for help on using the repository browser.