source: sasmodels/sasmodels/models/correlation_length.py @ c1e44e5

Last change on this file since c1e44e5 was c1e44e5, checked in by Paul Kienzle <pkienzle@…>, 5 years ago

Add local link to source files. Refs #1263.

  • Property mode set to 100644
File size: 2.9 KB
Line 
1#correlation length model
2# Note: model title and parameter table are inserted automatically
3r"""
4Definition
5----------
6
7The scattering intensity I(q) is calculated as
8
9.. math::
10    I(Q) = \frac{A}{Q^n} + \frac{C}{1 + (Q\xi)^m} + \text{background}
11
12The first term describes Porod scattering from clusters (exponent = $n$) and
13the second term is a Lorentzian function describing scattering from
14polymer chains (exponent = $m$). This second term characterizes the
15polymer/solvent interactions and therefore the thermodynamics. The two
16multiplicative factors $A$ and $C$, and the two exponents $n$ and $m$ are
17used as fitting parameters. (Respectively *porod_scale*, *lorentz_scale*,
18*porod_exp* and *lorentz_exp* in the parameter list.) The remaining
19parameter $\xi$ (*cor_length* in the parameter list) is a correlation
20length for the polymer chains. Note that when $m=2$ this functional form
21becomes the familiar Lorentzian function. Some interpretation of the
22values of $A$ and $C$ may be possible depending on the values of $m$ and $n$.
23
24For 2D data: The 2D scattering intensity is calculated in the same way as 1D,
25where the q vector is defined as
26
27.. math::  q = \sqrt{q_x^2 + q_y^2}
28
29References
30----------
31
32.. [#] B Hammouda, D L Ho and S R Kline, Insight into Clustering in Poly(ethylene oxide) Solutions, Macromolecules, 37 (2004) 6932-6937
33
34Authorship and Verification
35----------------------------
36
37* **Author:**
38* **Last Modified by:**
39* **Last Reviewed by:**
40"""
41
42from numpy import inf, errstate
43
44name = "correlation_length"
45title = """Calculates an empirical functional form for SAS data characterized
46by a low-Q signal and a high-Q signal."""
47description = """
48"""
49category = "shape-independent"
50# pylint: disable=bad-continuation, line-too-long
51#             ["name", "units", default, [lower, upper], "type","description"],
52parameters = [
53              ["lorentz_scale", "", 10.0, [0, inf], "", "Lorentzian Scaling Factor"],
54              ["porod_scale", "", 1e-06, [0, inf], "", "Porod Scaling Factor"],
55              ["cor_length", "Ang", 50.0, [0, inf], "", "Correlation length, xi, in Lorentzian"],
56              ["porod_exp", "", 3.0, [0, inf], "", "Porod Exponent, n, in q^-n"],
57              ["lorentz_exp", "1/Ang^2", 2.0, [0, inf], "", "Lorentzian Exponent, m, in 1/( 1 + (q.xi)^m)"],
58             ]
59# pylint: enable=bad-continuation, line-too-long
60
61def Iq(q, lorentz_scale, porod_scale, cor_length, porod_exp, lorentz_exp):
62    """
63    1D calculation of the Correlation length model
64    """
65    with errstate(divide='ignore'):
66        porod = porod_scale / q**porod_exp
67        lorentz = lorentz_scale / (1.0 + (q * cor_length)**lorentz_exp)
68    inten = porod + lorentz
69    return inten
70Iq.vectorized = True
71
72# parameters for demo
73demo = dict(lorentz_scale=10.0, porod_scale=1.0e-06, cor_length=50.0,
74            porod_exp=3.0, lorentz_exp=2.0, background=0.1,
75           )
76
77tests = [[{}, 0.001, 1009.98],
78         [{}, 0.150141, 0.175645],
79         [{}, 0.442528, 0.0213957]]
Note: See TracBrowser for help on using the repository browser.