source: sasmodels/sasmodels/models/flexible_cylinder_elliptical.py @ 0507e09

core_shell_microgelsmagnetic_modelticket-1257-vesicle-productticket_1156ticket_1265_superballticket_822_more_unit_tests
Last change on this file since 0507e09 was 0507e09, checked in by smk78, 6 months ago

Added link to source code to each model. Closes #883

  • Property mode set to 100644
File size: 6.6 KB
Line 
1r"""
2This model calculates the form factor for a flexible cylinder with an
3elliptical cross section and a uniform scattering length density.
4The non-negligible diameter of the cylinder is included by accounting
5for excluded volume interactions within the walk of a single cylinder.
6The form factor is normalized by the particle volume such that
7
8.. math::
9
10    P(q) = \text{scale} \left<F^2\right>/V + \text{background}
11
12where the averaging $\left<\ldots\right>$ is over all possible orientations
13of the flexible cylinder.
14
15The 2D scattering intensity is the same as 1D, regardless of the orientation
16of the q vector which is defined as
17
18.. math::
19
20    q = \sqrt{q_x^2 + q_y^2}
21
22
23Definitions
24-----------
25
26The function calculated in a similar way to that for the flexible_cylinder model
27from the reference given below using the author's "Method 3 With Excluded Volume".
28The model is a parameterization of simulations of a discrete representation of
29the worm-like chain model of Kratky and Porod applied in the pseudo-continuous
30limit. See equations (13, 26-27) in the original reference for the details.
31
32.. note::
33
34    There are several typos in the original reference that have been corrected
35    by WRC. Details of the corrections are in the reference below. Most notably
36
37    - Equation (13): the term $(1 - w(QR))$ should swap position with $w(QR)$
38
39    - Equations (23) and (24) are incorrect; WRC has entered these into
40      Mathematica and solved analytically. The results were then converted to
41      code.
42
43    - Equation (27) should be $q0 = max(a3/sqrt(RgSquare),3)$ instead of
44      $max(a3*b/sqrt(RgSquare),3)$
45
46    - The scattering function is negative for a range of parameter values and
47      q-values that are experimentally accessible. A correction function has been
48      added to give the proper behavior.
49
50.. figure:: img/flexible_cylinder_ex_geometry.jpg
51
52
53The chain of contour length, $L$, (the total length) can be described as a chain
54of some number of locally stiff segments of length $l_p$, the persistence length
55(the length along the cylinder over which the flexible cylinder can be considered
56a rigid rod).
57The Kuhn length $(b = 2*l_p)$ is also used to describe the stiffness of a chain.
58
59The cross section of the cylinder is elliptical, with minor radius $a$ .
60The major radius is larger, so of course, **the axis ratio (parameter 5) must be
61greater than one.** Simple constraints should be applied during curve fitting to
62maintain this inequality.
63
64The returned value is in units of $cm^{-1}$, on absolute scale.
65
66In the parameters, the $sld$ and $sld\_solvent$ represent the SLD of the
67chain/cylinder and solvent respectively. The *scale*, and the contrast are both
68multiplicative factors in the model and are perfectly correlated. One or both of
69these parameters must be held fixed during model fitting.
70
71**No inter-cylinder interference effects are included in this calculation.**
72
73References
74----------
75
76.. [#] J S Pedersen and P Schurtenberger. *Scattering functions of semiflexible polymers with and without excluded volume effects.* Macromolecules, 29 (1996) 7602-7612
77
78Correction of the formula can be found in
79
80.. [#] W R Chen, P D Butler and L J Magid, *Incorporating Intermicellar Interactions in the Fitting of SANS Data from Cationic Wormlike Micelles.* Langmuir, 22(15) 2006 6539-6548
81
82Source
83------
84
85`flexible_cylinder_elliptical.py <https://github.com/SasView/sasmodels/blob/master/sasmodels/models/flexible_cylinder_elliptical.py>`_
86
87`flexible_cylinder_elliptical.c <https://github.com/SasView/sasmodels/blob/master/sasmodels/models/flexible_cylinder_elliptical.c>`_
88
89Authorship and Verification
90----------------------------
91
92* **Author:**
93* **Last Modified by:**
94* **Last Reviewed by:**
95* **Source added by :** Steve King **Date:** March 25, 2019
96"""
97
98import numpy as np
99from numpy import inf
100
101name = "flexible_cylinder_elliptical"
102title = "Flexible cylinder wth an elliptical cross section and a uniform " \
103        "scattering length density."
104description = """Note : scale and contrast=sldCyl-sldSolv are both multiplicative
105        factors in the
106        model and are perfectly correlated. One or
107        both of these parameters must be held fixed
108        during model fitting.
109        """
110single = False
111
112category = "shape:cylinder"
113# pylint: disable=bad-whitespace, line-too-long
114#             ["name", "units", default, [lower, upper], "type", "description"],
115parameters = [
116    ["length",      "Ang",       1000.0, [0, inf],    "volume", "Length of the flexible cylinder"],
117    ["kuhn_length", "Ang",        100.0, [0, inf],    "volume", "Kuhn length of the flexible cylinder"],
118    ["radius",      "Ang",         20.0, [1, inf],    "volume", "Radius of the flexible cylinder"],
119    ["axis_ratio",  "",             1.5, [0, inf],    "",       "Axis_ratio (major_radius/minor_radius"],
120    ["sld",         "1e-6/Ang^2",   1.0, [-inf, inf], "sld",    "Cylinder scattering length density"],
121    ["sld_solvent", "1e-6/Ang^2",   6.3, [-inf, inf], "sld",    "Solvent scattering length density"],
122    ]
123# pylint: enable=bad-whitespace, line-too-long
124
125source = ["lib/polevl.c", "lib/sas_J1.c", "lib/gauss76.c", "lib/wrc_cyl.c",
126          "flexible_cylinder_elliptical.c"]
127
128def random():
129    """Return a random parameter set for the model."""
130    length = 10**np.random.uniform(2, 6)
131    radius = 10**np.random.uniform(1, 3)
132    axis_ratio = 10**np.random.uniform(-1, 1)
133    kuhn_length = 10**np.random.uniform(-2, -0.7)*length  # at least 10 segments
134    pars = dict(
135        length=length,
136        radius=radius,
137        axis_ratio=axis_ratio,
138        kuhn_length=kuhn_length,
139    )
140    return pars
141
142tests = [
143    # Accuracy tests based on content in test/utest_other_models.py
144    # Currently fails in OCL
145    # [{'length':     1000.0,
146    #  'kuhn_length': 100.0,
147    #  'radius':       20.0,
148    #  'axis_ratio':    1.5,
149    #  'sld':           1.0,
150    #  'sld_solvent':   6.3,
151    #  'background':    0.0001,
152    # }, 0.001, 3509.2187],
153
154    # Additional tests with larger range of parameters
155    [{'length':     1000.0,
156      'kuhn_length': 100.0,
157      'radius':       20.0,
158      'axis_ratio':    1.5,
159      'sld':           1.0,
160      'sld_solvent':   6.3,
161      'background':    0.0001,
162     }, 1.0, 0.00223819],
163    [{'length':        10.0,
164      'kuhn_length': 800.0,
165      'radius':        2.0,
166      'axis_ratio':    0.5,
167      'sld':           6.0,
168      'sld_solvent':  12.3,
169      'background':    0.001,
170     }, 0.1, 0.390281],
171    [{'length':        100.0,
172      'kuhn_length': 800.0,
173      'radius':       50.0,
174      'axis_ratio':    4.5,
175      'sld':           0.1,
176      'sld_solvent':   5.1,
177      'background':    0.0,
178     }, 1.0, 0.0016338264790]
179    ]
Note: See TracBrowser for help on using the repository browser.