source: sasmodels/sasmodels/models/flexible_cylinder.py @ 31df0c9

core_shell_microgelscostrafo411magnetic_modelticket-1257-vesicle-productticket_1156ticket_1265_superballticket_822_more_unit_tests
Last change on this file since 31df0c9 was 31df0c9, checked in by Paul Kienzle <pkienzle@…>, 7 years ago

tuned random model generation for more models

  • Property mode set to 100644
File size: 4.4 KB
RevLine 
[f94d8a2]1r"""
[168052c]2This model provides the form factor, $P(q)$, for a flexible cylinder
3where 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]10where the averaging $\left<\ldots\right>$ is applied only for the 1D
11calculation
[f94d8a2]12
[168052c]13The 2D scattering intensity is the same as 1D, regardless of the orientation of
14the q vector which is defined as
[f94d8a2]15
16.. math::
17
18    q = \sqrt{q_x^2 + q_y^2}
19
20Definitions
21-----------
22
23.. figure:: img/flexible_cylinder_geometry.jpg
24
25
[168052c]26The chain of contour length, $L$, (the total length) can be described as a
27chain of some number of locally stiff segments of length $l_p$, the persistence
28length (the length along the cylinder over which the flexible cylinder can be
29considered a rigid rod).
[f94d8a2]30The Kuhn length $(b = 2*l_p)$ is also used to describe the stiffness of a chain.
31
[e65a3e7]32The returned value is in units of $cm^{-1}$, on absolute scale.
[f94d8a2]33
[ce8bed9]34In the parameters, the sld and sld\_solvent represent the SLD of the cylinder
[168052c]35and solvent respectively.
[f94d8a2]36
[168052c]37Our model uses the form factor calculations implemented in a c-library provided
38by the NIST Center for Neutron Research (Kline, 2006).
[f94d8a2]39
40
41From the reference:
42
43    'Method 3 With Excluded Volume' is used.
44    The model is a parametrization of simulations of a discrete representation
[168052c]45    of the worm-like chain model of Kratky and Porod applied in the
46    pseudocontinuous limit.
[f94d8a2]47    See equations (13,26-27) in the original reference for the details.
48
49References
50----------
51
[168052c]52J S Pedersen and P Schurtenberger. *Scattering functions of semiflexible
53polymers with and without excluded volume effects.* Macromolecules,
5429 (1996) 7602-7612
[f94d8a2]55
56Correction of the formula can be found in
57
[168052c]58W R Chen, P D Butler and L J Magid, *Incorporating Intermicellar Interactions
59in the Fitting of SANS Data from Cationic Wormlike Micelles.* Langmuir,
6022(15) 2006 6539-6548
[f94d8a2]61"""
62from numpy import inf
63
64name = "flexible_cylinder"
[168052c]65title = "Flexible cylinder where the form factor is normalized by the volume" \
66        "of the cylinder."
[e65a3e7]67description = """Note : scale and contrast = (sld - sld_solvent) are both
[168052c]68                multiplicative factors in the model and are perfectly
69                correlated. One or both of these parameters must be held fixed
[f94d8a2]70                during model fitting.
71              """
72
73category = "shape:cylinder"
[e65a3e7]74single = False  # double precision only!
[f94d8a2]75
[168052c]76# pylint: disable=bad-whitespace, line-too-long
[f94d8a2]77#             ["name", "units", default, [lower, upper], "type", "description"],
78parameters = [
[168052c]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"],
[42356c8]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"],
[168052c]84    ]
85# pylint: enable=bad-whitespace, line-too-long
[26141cb]86source = ["lib/polevl.c", "lib/sas_J1.c", "lib/wrc_cyl.c", "flexible_cylinder.c"]
[f94d8a2]87
[31df0c9]88def 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.7)*length  # at least 10 segments
93    pars = dict(
94        length=length,
95        radius=radius,
96        kuhn_length=kuhn_length,
97    )
98    return pars
[f94d8a2]99
100tests = [
[168052c]101    # Accuracy tests based on content in test/utest_other_models.py
102    # Currently fails in OCL
103    # [{'length':     1000.0,
104    #  'kuhn_length': 100.0,
105    #  'radius':       20.0,
106    #  'sld':           1.0,
[e65a3e7]107    #  'sld_solvent':   6.3,
[168052c]108    #  'background':    0.0001,
109    #  }, 0.001, 3509.2187],
110
111    # Additional tests with larger range of parameters
112    [{'length':    1000.0,
113      'kuhn_length': 100.0,
114      'radius':       20.0,
115      'sld':           1.0,
[e65a3e7]116      'sld_solvent':   6.3,
[168052c]117      'background':    0.0001,
118     }, 1.0, 0.000595345],
119    [{'length':        10.0,
120      'kuhn_length': 800.0,
121      'radius':        2.0,
122      'sld':           6.0,
[e65a3e7]123      'sld_solvent':  12.3,
[168052c]124      'background':    0.001,
125     }, 0.1, 1.55228],
126    [{'length':        100.0,
127      'kuhn_length': 800.0,
128      'radius':       50.0,
129      'sld':           0.1,
[e65a3e7]130      'sld_solvent':   5.1,
[168052c]131      'background':    0.0,
132     }, 1.0, 0.000938456]
133    ]
[f94d8a2]134
Note: See TracBrowser for help on using the repository browser.