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