1 | r""" |
---|
2 | This model provides the form factor, $P(q)$, for a flexible cylinder |
---|
3 | where the form factor is normalized by the volume of the cylinder. |
---|
4 | **Inter-cylinder interactions are NOT provided for.** |
---|
5 | |
---|
6 | .. math:: |
---|
7 | |
---|
8 | P(q) = \text{scale} \left<F^2\right>/V + \text{background} |
---|
9 | |
---|
10 | where the averaging $\left<\ldots\right>$ is applied only for the 1D |
---|
11 | calculation |
---|
12 | |
---|
13 | The 2D scattering intensity is the same as 1D, regardless of the orientation of |
---|
14 | the q vector which is defined as |
---|
15 | |
---|
16 | .. math:: |
---|
17 | |
---|
18 | q = \sqrt{q_x^2 + q_y^2} |
---|
19 | |
---|
20 | Definitions |
---|
21 | ----------- |
---|
22 | |
---|
23 | .. figure:: img/flexible_cylinder_geometry.jpg |
---|
24 | |
---|
25 | |
---|
26 | The chain of contour length, $L$, (the total length) can be described as a |
---|
27 | chain of some number of locally stiff segments of length $l_p$, the persistence |
---|
28 | length (the length along the cylinder over which the flexible cylinder can be |
---|
29 | considered a rigid rod). |
---|
30 | The Kuhn length $(b = 2*l_p)$ is also used to describe the stiffness of a chain. |
---|
31 | |
---|
32 | The returned value is in units of $cm^{-1}$, on absolute scale. |
---|
33 | |
---|
34 | In the parameters, the sld and sld\_solvent represent the SLD of the cylinder |
---|
35 | and solvent respectively. |
---|
36 | |
---|
37 | Our model uses the form factor calculations implemented in a c-library provided |
---|
38 | by the NIST Center for Neutron Research (Kline, 2006). |
---|
39 | |
---|
40 | |
---|
41 | From the reference: |
---|
42 | |
---|
43 | 'Method 3 With Excluded Volume' is used. |
---|
44 | The model is a parametrization of simulations of a discrete representation |
---|
45 | of the worm-like chain model of Kratky and Porod applied in the |
---|
46 | pseudocontinuous limit. |
---|
47 | See equations (13,26-27) in the original reference for the details. |
---|
48 | |
---|
49 | References |
---|
50 | ---------- |
---|
51 | |
---|
52 | J S Pedersen and P Schurtenberger. *Scattering functions of semiflexible |
---|
53 | polymers with and without excluded volume effects.* Macromolecules, |
---|
54 | 29 (1996) 7602-7612 |
---|
55 | |
---|
56 | Correction of the formula can be found in |
---|
57 | |
---|
58 | W R Chen, P D Butler and L J Magid, *Incorporating Intermicellar Interactions |
---|
59 | in the Fitting of SANS Data from Cationic Wormlike Micelles.* Langmuir, |
---|
60 | 22(15) 2006 6539-6548 |
---|
61 | """ |
---|
62 | from numpy import inf |
---|
63 | |
---|
64 | name = "flexible_cylinder" |
---|
65 | title = "Flexible cylinder where the form factor is normalized by the volume" \ |
---|
66 | "of the cylinder." |
---|
67 | description = """Note : scale and contrast = (sld - sld_solvent) are both |
---|
68 | multiplicative factors in the model and are perfectly |
---|
69 | correlated. One or both of these parameters must be held fixed |
---|
70 | during model fitting. |
---|
71 | """ |
---|
72 | |
---|
73 | category = "shape:cylinder" |
---|
74 | single = False # double precision only! |
---|
75 | |
---|
76 | # pylint: disable=bad-whitespace, line-too-long |
---|
77 | # ["name", "units", default, [lower, upper], "type", "description"], |
---|
78 | parameters = [ |
---|
79 | ["length", "Ang", 1000.0, [0, inf], "volume", "Length of the flexible cylinder"], |
---|
80 | ["kuhn_length", "Ang", 100.0, [0, inf], "volume", "Kuhn length of the flexible cylinder"], |
---|
81 | ["radius", "Ang", 20.0, [0, inf], "volume", "Radius of the flexible cylinder"], |
---|
82 | ["sld", "1e-6/Ang^2", 1.0, [-inf, inf], "sld", "Cylinder scattering length density"], |
---|
83 | ["sld_solvent", "1e-6/Ang^2", 6.3, [-inf, inf], "sld", "Solvent scattering length density"], |
---|
84 | ] |
---|
85 | # pylint: enable=bad-whitespace, line-too-long |
---|
86 | source = ["lib/polevl.c", "lib/sas_J1.c", "lib/wrc_cyl.c", "flexible_cylinder.c"] |
---|
87 | |
---|
88 | def random(): |
---|
89 | import numpy as np |
---|
90 | length = 10**np.random.uniform(2, 6) |
---|
91 | radius = 10**np.random.uniform(1, 3) |
---|
92 | kuhn_length = 10**np.random.uniform(-2, 0)*length |
---|
93 | pars = dict( |
---|
94 | length=length, |
---|
95 | radius=radius, |
---|
96 | kuhn_length=kuhn_length, |
---|
97 | ) |
---|
98 | return pars |
---|
99 | |
---|
100 | tests = [ |
---|
101 | # Accuracy tests based on content in test/utest_other_models.py |
---|
102 | [{'length': 1000.0, # test T1 |
---|
103 | 'kuhn_length': 100.0, |
---|
104 | 'radius': 20.0, |
---|
105 | 'sld': 1.0, |
---|
106 | 'sld_solvent': 6.3, |
---|
107 | 'background': 0.0001, |
---|
108 | }, 0.001, 3509.2187], |
---|
109 | |
---|
110 | # Additional tests with larger range of parameters |
---|
111 | [{'length': 1000.0, # test T2 |
---|
112 | 'kuhn_length': 100.0, |
---|
113 | 'radius': 20.0, |
---|
114 | 'sld': 1.0, |
---|
115 | 'sld_solvent': 6.3, |
---|
116 | 'background': 0.0001, |
---|
117 | }, 1.0, 0.000595345], |
---|
118 | [{'length': 10.0, # test T3 |
---|
119 | 'kuhn_length': 800.0, |
---|
120 | 'radius': 2.0, |
---|
121 | 'sld': 6.0, |
---|
122 | 'sld_solvent': 12.3, |
---|
123 | 'background': 0.001, |
---|
124 | }, 0.1, 1.55228], |
---|
125 | [{'length': 100.0, # test T4 |
---|
126 | 'kuhn_length': 800.0, |
---|
127 | 'radius': 50.0, |
---|
128 | 'sld': 0.1, |
---|
129 | 'sld_solvent': 5.1, |
---|
130 | 'background': 0.0, |
---|
131 | }, 1.0, 0.000938456] |
---|
132 | ] |
---|
133 | |
---|
134 | # There are a few branches in the code that ought to have test values: |
---|
135 | # |
---|
136 | # For length > 4 * kuhn_length |
---|
137 | # if length > 10 * kuhn_length then C is scaled by 3.06 (L/b)^(-0.44) |
---|
138 | # q*kuhn_length <= 3.1 => Sexv_new |
---|
139 | # dS/dQ < 0 has different behaviour from dS/dQ >= 0 |
---|
140 | # T2 q*kuhn_length > 3.1 => a_long |
---|
141 | # |
---|
142 | # For length <= 4 * kuhn_length |
---|
143 | # q*kuhn_length <= max(1.9/Rg_short, 3.0) => Sdebye((q*Rg)^2) |
---|
144 | # q*Rg < 0.5 uses Pade approx, q*Rg > 1.0 uses math lib |
---|
145 | # T3,T4 q*kuhn_length > max(1.9/Rg_short, 3.0) => a_short |
---|
146 | # |
---|
147 | # Note that the transitions between branches may be abrupt. You can see a |
---|
148 | # several percent change around length=10*kuhn_length and length=4*kuhn_length |
---|
149 | # using the following: |
---|
150 | # |
---|
151 | # sascomp flexible_cylinder -calc=double -sets=10 length=10*kuhn_length,10.000001*kuhn_length |
---|
152 | # sascomp flexible_cylinder -calc=double -sets=10 length=4*kuhn_length,4.000001*kuhn_length |
---|
153 | # |
---|
154 | # The transition between low q and high q around q*kuhn_length = 3 seems |
---|
155 | # to be good to 4 digits or better. This was tested by computing the value |
---|
156 | # on each branches near the transition point and reporting the relative error |
---|
157 | # for kuhn lengths of 10, 100 and 1000 and a variety of length:kuhn_length |
---|
158 | # ratios. |
---|