[f94d8a2] | 1 | r""" |
---|
[168052c] | 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. |
---|
[f94d8a2] | 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 | |
---|
[168052c] | 10 | where the averaging $\left<\ldots\right>$ is applied only for the 1D |
---|
| 11 | calculation |
---|
[f94d8a2] | 12 | |
---|
[168052c] | 13 | The 2D scattering intensity is the same as 1D, regardless of the orientation of |
---|
| 14 | the q vector which is defined as |
---|
[f94d8a2] | 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 | |
---|
[168052c] | 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). |
---|
[f94d8a2] | 30 | The Kuhn length $(b = 2*l_p)$ is also used to describe the stiffness of a chain. |
---|
| 31 | |
---|
[ce8bed9] | 32 | In the parameters, the sld and sld\_solvent represent the SLD of the cylinder |
---|
[168052c] | 33 | and solvent respectively. |
---|
[f94d8a2] | 34 | |
---|
[db1d9d5] | 35 | Our model uses the form factor calculations in reference [1] as implemented in a |
---|
| 36 | c-library provided by the NIST Center for Neutron Research (Kline, 2006). This states: |
---|
[f94d8a2] | 37 | |
---|
| 38 | 'Method 3 With Excluded Volume' is used. |
---|
| 39 | The model is a parametrization of simulations of a discrete representation |
---|
[168052c] | 40 | of the worm-like chain model of Kratky and Porod applied in the |
---|
| 41 | pseudocontinuous limit. |
---|
[f94d8a2] | 42 | See equations (13,26-27) in the original reference for the details. |
---|
| 43 | |
---|
[db1d9d5] | 44 | .. note:: |
---|
| 45 | |
---|
| 46 | There are several typos in the original reference that have been corrected |
---|
| 47 | by WRC [2]. Details of the corrections are in the reference below. Most notably |
---|
| 48 | |
---|
| 49 | - Equation (13): the term $(1 - w(QR))$ should swap position with $w(QR)$ |
---|
| 50 | |
---|
| 51 | - Equations (23) and (24) are incorrect; WRC has entered these into |
---|
| 52 | Mathematica and solved analytically. The results were then converted to |
---|
| 53 | code. |
---|
| 54 | |
---|
| 55 | - Equation (27) should be $q0 = max(a3/(Rg^2)^{1/2},3)$ instead of |
---|
| 56 | $max(a3*b(Rg^2)^{1/2},3)$ |
---|
| 57 | |
---|
| 58 | - The scattering function is negative for a range of parameter values and |
---|
[830cf6b] | 59 | q-values that are experimentally accessible. A correction function has been |
---|
| 60 | added to give the proper behavior. |
---|
| 61 | |
---|
| 62 | |
---|
| 63 | **This is a model with complex behaviour depending on the ratio of** $L/b$ **and the |
---|
| 64 | reader is strongly encouraged to read reference [1] before use.** |
---|
| 65 | |
---|
[40c9825] | 66 | .. note:: |
---|
| 67 | |
---|
| 68 | There are several typos in the original reference that have been corrected |
---|
| 69 | by WRC [2]. Details of the corrections are in the reference below. Most notably |
---|
| 70 | |
---|
| 71 | - Equation (13): the term $(1 - w(QR))$ should swap position with $w(QR)$ |
---|
| 72 | |
---|
| 73 | - Equations (23) and (24) are incorrect; WRC has entered these into |
---|
| 74 | Mathematica and solved analytically. The results were then converted to |
---|
| 75 | code. |
---|
| 76 | |
---|
| 77 | - Equation (27) should be $q0 = max(a3/(Rg^2)^{1/2},3)$ instead of |
---|
| 78 | $max(a3*b(Rg^2)^{1/2},3)$ |
---|
| 79 | |
---|
| 80 | - The scattering function is negative for a range of parameter values and |
---|
[db1d9d5] | 81 | q-values that are experimentally accessible. A correction function has been |
---|
| 82 | added to give the proper behavior. |
---|
| 83 | |
---|
| 84 | |
---|
| 85 | **This is a model with complex behaviour depending on the ratio of** $L/b$ **and the |
---|
| 86 | reader is strongly encouraged to read reference [1] before use.** |
---|
| 87 | |
---|
[f94d8a2] | 88 | References |
---|
| 89 | ---------- |
---|
| 90 | |
---|
[0507e09] | 91 | .. [#] J S Pedersen and P Schurtenberger. *Scattering functions of semiflexible polymers with and without excluded volume effects.* Macromolecules, 29 (1996) 7602-7612 |
---|
[f94d8a2] | 92 | |
---|
| 93 | Correction of the formula can be found in |
---|
| 94 | |
---|
[0507e09] | 95 | .. [#] 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 |
---|
| 96 | |
---|
| 97 | Source |
---|
| 98 | ------ |
---|
| 99 | |
---|
| 100 | `flexible_cylinder.py <https://github.com/SasView/sasmodels/blob/master/sasmodels/models/flexible_cylinder.py>`_ |
---|
| 101 | |
---|
| 102 | `flexible_cylinder.c <https://github.com/SasView/sasmodels/blob/master/sasmodels/models/flexible_cylinder.c>`_ |
---|
| 103 | |
---|
[db1d9d5] | 104 | `wrc_cyl.c <https://github.com/SasView/sasmodels/blob/master/sasmodels/models/lib/wrc_cyl.c>`_ |
---|
| 105 | |
---|
[0507e09] | 106 | Authorship and Verification |
---|
| 107 | ---------------------------- |
---|
| 108 | |
---|
[db1d9d5] | 109 | * **Author:** |
---|
| 110 | * **Last Modified by:** |
---|
| 111 | * **Last Reviewed by:** Steve King **Date:** March 26, 2019 |
---|
[0507e09] | 112 | * **Source added by :** Steve King **Date:** March 25, 2019 |
---|
[f94d8a2] | 113 | """ |
---|
[2d81cfe] | 114 | |
---|
| 115 | import numpy as np |
---|
[f94d8a2] | 116 | from numpy import inf |
---|
| 117 | |
---|
| 118 | name = "flexible_cylinder" |
---|
[db1d9d5] | 119 | title = "Flexible cylinder where the form factor is normalized by the volume " \ |
---|
[168052c] | 120 | "of the cylinder." |
---|
[e65a3e7] | 121 | description = """Note : scale and contrast = (sld - sld_solvent) are both |
---|
[168052c] | 122 | multiplicative factors in the model and are perfectly |
---|
| 123 | correlated. One or both of these parameters must be held fixed |
---|
[f94d8a2] | 124 | during model fitting. |
---|
| 125 | """ |
---|
| 126 | |
---|
| 127 | category = "shape:cylinder" |
---|
[e65a3e7] | 128 | single = False # double precision only! |
---|
[f94d8a2] | 129 | |
---|
[168052c] | 130 | # pylint: disable=bad-whitespace, line-too-long |
---|
[f94d8a2] | 131 | # ["name", "units", default, [lower, upper], "type", "description"], |
---|
| 132 | parameters = [ |
---|
[168052c] | 133 | ["length", "Ang", 1000.0, [0, inf], "volume", "Length of the flexible cylinder"], |
---|
| 134 | ["kuhn_length", "Ang", 100.0, [0, inf], "volume", "Kuhn length of the flexible cylinder"], |
---|
| 135 | ["radius", "Ang", 20.0, [0, inf], "volume", "Radius of the flexible cylinder"], |
---|
[42356c8] | 136 | ["sld", "1e-6/Ang^2", 1.0, [-inf, inf], "sld", "Cylinder scattering length density"], |
---|
| 137 | ["sld_solvent", "1e-6/Ang^2", 6.3, [-inf, inf], "sld", "Solvent scattering length density"], |
---|
[168052c] | 138 | ] |
---|
| 139 | # pylint: enable=bad-whitespace, line-too-long |
---|
[26141cb] | 140 | source = ["lib/polevl.c", "lib/sas_J1.c", "lib/wrc_cyl.c", "flexible_cylinder.c"] |
---|
[f94d8a2] | 141 | |
---|
[31df0c9] | 142 | def random(): |
---|
[b297ba9] | 143 | """Return a random parameter set for the model.""" |
---|
[31df0c9] | 144 | length = 10**np.random.uniform(2, 6) |
---|
| 145 | radius = 10**np.random.uniform(1, 3) |
---|
[a8631ca] | 146 | kuhn_length = 10**np.random.uniform(-2, 0)*length |
---|
[31df0c9] | 147 | pars = dict( |
---|
| 148 | length=length, |
---|
| 149 | radius=radius, |
---|
| 150 | kuhn_length=kuhn_length, |
---|
| 151 | ) |
---|
| 152 | return pars |
---|
[f94d8a2] | 153 | |
---|
| 154 | tests = [ |
---|
[168052c] | 155 | # Accuracy tests based on content in test/utest_other_models.py |
---|
[2573fa1] | 156 | [{'length': 1000.0, # test T1 |
---|
| 157 | 'kuhn_length': 100.0, |
---|
| 158 | 'radius': 20.0, |
---|
| 159 | 'sld': 1.0, |
---|
| 160 | 'sld_solvent': 6.3, |
---|
| 161 | 'background': 0.0001, |
---|
| 162 | }, 0.001, 3509.2187], |
---|
[168052c] | 163 | |
---|
| 164 | # Additional tests with larger range of parameters |
---|
[18a2bfc] | 165 | [{'length': 1000.0, # test T2 |
---|
[168052c] | 166 | 'kuhn_length': 100.0, |
---|
| 167 | 'radius': 20.0, |
---|
| 168 | 'sld': 1.0, |
---|
[e65a3e7] | 169 | 'sld_solvent': 6.3, |
---|
[168052c] | 170 | 'background': 0.0001, |
---|
| 171 | }, 1.0, 0.000595345], |
---|
[18a2bfc] | 172 | [{'length': 10.0, # test T3 |
---|
[168052c] | 173 | 'kuhn_length': 800.0, |
---|
| 174 | 'radius': 2.0, |
---|
| 175 | 'sld': 6.0, |
---|
[e65a3e7] | 176 | 'sld_solvent': 12.3, |
---|
[168052c] | 177 | 'background': 0.001, |
---|
| 178 | }, 0.1, 1.55228], |
---|
[18a2bfc] | 179 | [{'length': 100.0, # test T4 |
---|
[168052c] | 180 | 'kuhn_length': 800.0, |
---|
| 181 | 'radius': 50.0, |
---|
| 182 | 'sld': 0.1, |
---|
[e65a3e7] | 183 | 'sld_solvent': 5.1, |
---|
[168052c] | 184 | 'background': 0.0, |
---|
| 185 | }, 1.0, 0.000938456] |
---|
| 186 | ] |
---|
[18a2bfc] | 187 | |
---|
| 188 | # There are a few branches in the code that ought to have test values: |
---|
| 189 | # |
---|
| 190 | # For length > 4 * kuhn_length |
---|
| 191 | # if length > 10 * kuhn_length then C is scaled by 3.06 (L/b)^(-0.44) |
---|
| 192 | # q*kuhn_length <= 3.1 => Sexv_new |
---|
| 193 | # dS/dQ < 0 has different behaviour from dS/dQ >= 0 |
---|
| 194 | # T2 q*kuhn_length > 3.1 => a_long |
---|
| 195 | # |
---|
| 196 | # For length <= 4 * kuhn_length |
---|
| 197 | # q*kuhn_length <= max(1.9/Rg_short, 3.0) => Sdebye((q*Rg)^2) |
---|
| 198 | # q*Rg < 0.5 uses Pade approx, q*Rg > 1.0 uses math lib |
---|
| 199 | # T3,T4 q*kuhn_length > max(1.9/Rg_short, 3.0) => a_short |
---|
| 200 | # |
---|
| 201 | # Note that the transitions between branches may be abrupt. You can see a |
---|
| 202 | # several percent change around length=10*kuhn_length and length=4*kuhn_length |
---|
| 203 | # using the following: |
---|
| 204 | # |
---|
| 205 | # sascomp flexible_cylinder -calc=double -sets=10 length=10*kuhn_length,10.000001*kuhn_length |
---|
| 206 | # sascomp flexible_cylinder -calc=double -sets=10 length=4*kuhn_length,4.000001*kuhn_length |
---|
| 207 | # |
---|
| 208 | # The transition between low q and high q around q*kuhn_length = 3 seems |
---|
| 209 | # to be good to 4 digits or better. This was tested by computing the value |
---|
| 210 | # on each branches near the transition point and reporting the relative error |
---|
| 211 | # for kuhn lengths of 10, 100 and 1000 and a variety of length:kuhn_length |
---|
| 212 | # ratios. |
---|