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

core_shell_microgelscostrafo411magnetic_modelrelease_v0.94release_v0.95ticket-1257-vesicle-productticket_1156ticket_1265_superballticket_822_more_unit_tests
Last change on this file since e481a39 was aa2edb2, checked in by gonzalezm, 8 years ago

Removing hardcoded figures to be replaced by autogenerated ones

  • Property mode set to 100644
File size: 3.1 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} + B
11
12The first term describes Porod scattering from clusters (exponent = n) and the
13second term is a Lorentzian function describing scattering from polymer chains
14(exponent = m). This second term characterizes the polymer/solvent interactions
15and therefore the thermodynamics. The two multiplicative factors A and C, the
16incoherent background B and the two exponents n and m are used as fitting
17parameters. The final parameter ξ is a correlation length for the polymer
18chains. Note that when m=2 this functional form becomes the familiar Lorentzian
19function.
20
21For 2D data: The 2D scattering intensity is calculated in the same way as 1D,
22where the q vector is defined as
23
24.. math::
25    q = \sqrt{q_x^2 + q_y^2}
26
27References
28----------
29
30B Hammouda, D L Ho and S R Kline, Insight into Clustering in
31Poly(ethylene oxide) Solutions, Macromolecules, 37 (2004) 6932-6937
32"""
33
34from numpy import inf, sqrt
35
36name = "correlation_length"
37title = """Calculates an empirical functional form for SAS data characterized
38by a low-Q signal and a high-Q signal."""
39description = """
40"""
41category = "shape-independent"
42# pylint: disable=bad-continuation, line-too-long
43#             ["name", "units", default, [lower, upper], "type","description"],
44parameters = [
45              ["lorentz_scale", "", 10.0, [0, inf], "", "Lorentzian Scaling Factor"],
46              ["porod_scale", "", 1e-06, [0, inf], "", "Porod Scaling Factor"],
47              ["cor_length", "Ang", 50.0, [0, inf], "", "Correlation length"],
48              ["exponent_p", "", 3.0, [0, inf], "", "Porod Exponent"],
49              ["exponent_l", "1/Ang^2", 2.0, [0, inf], "", "Lorentzian Exponent"],
50             ]
51# pylint: enable=bad-continuation, line-too-long
52
53def Iq(q, lorentz_scale, porod_scale, cor_length, exponent_p, exponent_l):
54    """
55    1D calculation of the Correlation length model
56    """
57    porod = porod_scale / pow(q, exponent_p)
58    lorentz = lorentz_scale / (1.0 + pow(q * cor_length, exponent_l))
59    inten = porod + lorentz
60    return inten
61
62def Iqxy(qx, qy, lorentz_scale, porod_scale, cor_length, exponent_p, exponent_l):
63    """
64    2D calculation of the Correlation length model
65    There is no orientation contribution.
66    """
67    q = sqrt(qx ** 2 + qy ** 2)
68    return Iq(q, lorentz_scale, porod_scale, cor_length, exponent_p, exponent_l)
69
70# parameters for demo
71demo = dict(lorentz_scale=10.0, porod_scale=1.0e-06, cor_length=50.0,
72            exponent_p=3.0, exponent_l=2.0, background=0.1,
73           )
74
75# For testing against the old sasview models, include the converted parameter
76# names and the target sasview model name.
77oldname = 'CorrLengthModel'
78
79oldpars = dict(lorentz_scale='scale_l', porod_scale='scale_p',
80               cor_length='length_l', exponent_p='exponent_p',
81               exponent_l='exponent_l')
82
83tests = [[{}, 0.001, 1009.98],
84         [{}, 0.150141, 0.175645],
85         [{}, 0.442528, 0.0213957]]
Note: See TracBrowser for help on using the repository browser.