source: sasmodels/sasmodels/models/lamellar.py @ 304c775

core_shell_microgelsmagnetic_modelticket-1257-vesicle-productticket_1156ticket_1265_superballticket_822_more_unit_tests
Last change on this file since 304c775 was 304c775, checked in by Paul Kienzle <pkienzle@…>, 5 years ago

provide method for testing Fq results. Refs #1202.

  • Property mode set to 100644
File size: 3.4 KB
Line 
1r"""
2Polydispersity in the bilayer thickness can be applied from the GUI.
3
4Definition
5----------
6
7The scattering intensity $I(q)$ for dilute, randomly oriented,
8"infinitely large" sheets or lamellae is
9
10.. math::
11
12    I(q) = \text{scale}\frac{2\pi P(q)}{q^2\delta} + \text{background}
13
14
15The form factor is
16
17.. math::
18
19   P(q) = \frac{2\Delta\rho^2}{q^2}(1-\cos(q\delta))
20        = \frac{4\Delta\rho^2}{q^2}\sin^2\left(\frac{q\delta}{2}\right)
21
22where $\delta$ is the total layer thickness and $\Delta\rho$ is the
23scattering length density difference.
24
25This is the limiting form for a spherical shell of infinitely large radius.
26Note that the division by $\delta$ means that $scale$ in sasview is the
27volume fraction of sheet, $\phi = S\delta$ where $S$ is the area of sheet
28per unit volume. $S$ is half the Porod surface area per unit volume of a
29thicker layer (as that would include both faces of the sheet).
30
31The 2D scattering intensity is calculated in the same way as 1D, where
32the $q$ vector is defined as
33
34.. math::
35
36    q = \sqrt{q_x^2 + q_y^2}
37
38
39References
40----------
41
42F Nallet, R Laversanne, and D Roux, J. Phys. II France, 3, (1993) 487-502
43
44also in J. Phys. Chem. B, 105, (2001) 11081-11088
45"""
46
47import numpy as np
48from numpy import inf
49
50name = "lamellar"
51title = "Lyotropic lamellar phase with uniform SLD and random distribution"
52description = """\
53    [Dilute Lamellar Form Factor](from a lyotropic lamellar phase)
54        I(q)= 2*pi*P(q)/(delta *q^(2)), where
55        P(q)=2*(contrast/q)^(2)*(1-cos(q*delta))^(2))
56        thickness = layer thickness
57        sld = layer scattering length density
58        sld_solvent = solvent scattering length density
59        background = incoherent background
60        scale = scale factor
61"""
62category = "shape:lamellae"
63
64# pylint: disable=bad-whitespace, line-too-long
65#   ["name", "units", default, [lower, upper], "type","description"],
66parameters = [
67    ["thickness",          "Ang", 50, [0, inf],    "volume", "total layer thickness" ],
68    ["sld",         "1e-6/Ang^2",  1, [-inf, inf], "sld",    "Layer scattering length density" ],
69    ["sld_solvent", "1e-6/Ang^2",  6, [-inf, inf], "sld",    "Solvent scattering length density" ],
70    ]
71# pylint: enable=bad-whitespace, line-too-long
72
73# No volume normalization despite having a volume parameter
74# This should perhaps be volume normalized? - it is!
75form_volume = """
76    return 1.0;
77    """
78
79Iq = """
80    const double sub = sld - sld_solvent;
81    const double qsq = q*q;
82    // Original expression
83    //return 4.0e-4*M_PI*sub*sub/qsq * (1.0-cos(q*thickness)) / (thickness*qsq);
84    // const double alpha = fmod(q*thickness+0.1, 2.0*M_PI)-0.1;
85    // Use small angle fix 1-cos(theta) = 2 sin^2(theta/2)
86    const double sinq2 = sin(0.5*q*thickness);
87    return 4.0e-4*M_PI*sub*sub/qsq * 2.0*sinq2*sinq2 / (thickness*qsq);
88    """
89
90def random():
91    thickness = 10**np.random.uniform(1, 4)
92    pars = dict(
93        thickness=thickness,
94    )
95    return pars
96
97demo = dict(scale=1, background=0,
98            sld=6, sld_solvent=1,
99            thickness=40,
100            thickness_pd=0.2, thickness_pd_n=40)
101#  [(qx1, qy1), (qx2, qy2), ...], [I(qx1,qy1), I(qx2,qy2), ...]],
102tests = [
103    [{'scale': 1.0, 'background': 0.0, 'thickness': 50.0,
104      'sld': 1.0, 'sld_solvent': 6.3, 'thickness_pd': 0.0},
105     [0.001], [882289.54309]]
106]
107# ADDED by: converted by PAK? (or RKH?)
108# ON: 16Mar2016 - RKH adding unit tests from sasview to early 2015 conversion
Note: See TracBrowser for help on using the repository browser.