source: sasmodels/sasmodels/models/correlation_length.py @ 5054e80

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

Converted the correlation length model

  • Property mode set to 100644
File size: 3.3 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
27.. figure:: img/correlation_length_1d.jpg
28
29    1D plot using the default values (w/500 data points).
30
31REFERENCE
32B Hammouda, D L Ho and S R Kline, Insight into Clustering in
33Poly(ethylene oxide) Solutions, Macromolecules, 37 (2004) 6932-6937
34"""
35
36from numpy import inf, sqrt
37
38name = "correlation_length"
39title = """Calculates an empirical functional form for SAS data characterized
40by a low-Q signal and a high-Q signal."""
41description = """
42"""
43category = "shape-independent"
44# pylint: disable=bad-continuation, line-too-long
45#             ["name", "units", default, [lower, upper], "type","description"],
46parameters = [
47              ["lorentz_scale", "", 10.0, [0, inf], "", "Lorentzian Scaling Factor"],
48              ["porod_scale", "", 1e-06, [0, inf], "", "Porod Scaling Factor"],
49              ["cor_length", "Ang", 50.0, [0, inf], "", "Correlation length"],
50              ["exponent_p", "", 3.0, [0, inf], "", "Porod Exponent"],
51              ["exponent_l", "1/Ang^2", 2.0, [0, inf], "", "Lorentzian Exponent"],
52             ]
53# pylint: enable=bad-continuation, line-too-long
54
55def Iq(q, lorentz_scale, porod_scale, cor_length, exponent_p, exponent_l):
56    """
57    1D calculation of the Correlation length model
58    """
59    porod = porod_scale / pow(q, exponent_p)
60    lorentz = lorentz_scale / (1.0 + pow(q * cor_length, exponent_l))
61    inten = porod + lorentz
62    return inten
63
64def Iqxy(qx, qy, lorentz_scale, porod_scale, cor_length, exponent_p, exponent_l):
65    """
66    2D calculation of the Correlation length model
67    There is no orientation contribution.
68    """
69    q = sqrt(qx ** 2 + qy ** 2)
70    return Iq(q, lorentz_scale, porod_scale, cor_length, exponent_p, exponent_l)
71
72# parameters for demo
73demo = dict(lorentz_scale=10.0, porod_scale=1.0e-06, cor_length=50.0,
74            exponent_p=3.0, exponent_l=2.0, background=0.1,
75           )
76
77# For testing against the old sasview models, include the converted parameter
78# names and the target sasview model name.
79oldname = 'CorrLengthModel'
80# pylint: disable=bad-continuation
81oldpars = dict(
82               lorentz_scale='scale_l', porod_scale='scale_p',
83               cor_length='length_l', exponent_p='exponent_p',
84               exponent_l='exponent_l'
85               )
86
87tests = [
88         [{}, 0.001, 1009.98],
89         [{}, 0.150141, 0.174645],
90         [{}, 0.442528, 0.0203957]
91         ]
92# pylint: enable=bad-continuation
Note: See TracBrowser for help on using the repository browser.