source: sasmodels/sasmodels/models/vesicle.py @ d507c3a

core_shell_microgelscostrafo411magnetic_modelrelease_v0.94release_v0.95ticket-1257-vesicle-productticket_1156ticket_1265_superballticket_822_more_unit_tests
Last change on this file since d507c3a was 216fa6d, checked in by butler, 8 years ago

update title string for converted vesicle model

  • Property mode set to 100644
File size: 4.9 KB
Line 
1r"""
2Definition
3----------
4
5The 1D scattering intensity is calculated in the following way (Guinier, 1955)
6
7.. math::
8
9    P(q) = \frac{\text{scale}}{V_\text{shell}} \left[
10           \frac{3V_{\text{core}}({\rho_{\text{solvent}}
11           - \rho_{\text{shell}})j_1(qR_{\text{core}})}}{qR_{\text{core}}}
12           + \frac{3V_{\text{tot}}(\rho_{\text{shell}}
13           - \rho_{\text{solvent}}) j_1(qR_{\text{tot}})}{qR_{\text{tot}}}
14           \right]^2 + \text{background}
15
16
17where scale is a scale factor equivalent to the volume fraction of shell
18material if the data is on an absolute scale, $V_{shell}$ is the volume of the
19shell, $V_{\text{cor}}$ is the volume of the core, $V_{\text{tot}}$ is the
20total volume, $R_{\text{core}}$ is the radius of the core, $R_{\text{tot}}$ is
21the outer radius of the shell, $\rho_{\text{solvent}}$ is the scattering length
22density of the solvent (which is the same as for the core in this case),
23$\rho_{\text{scale}}$ is the scattering length density of the shell, background
24is a flat background level (due for example to incoherent scattering in the
25case of neutrons), and $j_1$ is the spherical bessel function
26$j_1 = (sin(x) - x cos(x))/ x^2$.
27
28The functional form is identical to a "typical" core-shell structure, except
29that the scattering is normalized by the volume that is contributing to the
30scattering, namely the volume of the shell alone, the scattering length density
31of the core is fixed the same as that of the solvent, the scale factor when the
32data are on an absolute scale is equivalent to the volume fraction of material
33in the shell rather than the entire core+shell sphere, and the parameterization
34is done in terms of the core radius = $R_{\text{core}}$ and the shell
35thickness = $R_{\text{tot}} - R_{\text{core}}$.
36
37.. figure: img/vesicle_geometry.jpg
38
39The 2D scattering intensity is the same as *P(q)* above, regardless of the
40orientation of the *q* vector which is defined as
41
42.. math::
43
44    q = \sqrt{q_x^2 + q_y^2}
45
46
47NB: The outer most radius (= *radius* + *thickness*) is used as the effective
48radius for *S(Q)* when *P(Q)* \* *S(Q)* is applied.
49
50.. image:: img/vesicle_1d.jpg
51
52*Figure. 1D plot using the default values given in the table
53(w/200 data point). Polydispersity and instrumental resolution normally
54will smear out most of the rapidly oscillating features.*
55
56REFERENCE
57
58A Guinier and G. Fournet, *Small-Angle Scattering of X-Rays*, John Wiley and
59Sons, New York, (1955)
60"""
61
62import numpy as np
63from numpy import pi, inf
64
65name = "vesicle"
66title = "This model provides the form factor, *P(q)*, for an unilamellar \
67    vesicle. This is model is effectively identical to the hollow sphere \
68    reparameterized to be more intuitive for a vesicle and normalizing the \
69    form factor by the volume of the shell."
70description = """
71    Model parameters:
72        radius : the core radius of the vesicle
73        thickness: the shell thickness
74        sld: the shell SLD
75        solvent_sld: the solvent (and core) SLD
76        background: incoherent background
77        scale : scale factor = shell volume fraction if on absolute scale"""
78category = "shape:sphere"
79
80#             [ "name", "units", default, [lower, upper], "type", "description"],
81parameters = [["sld", "1e-6/Ang^2", 0.5, [-inf, inf], "",
82               "vesicle shell scattering length density"],
83              ["solvent_sld", "1e-6/Ang^2", 6.36, [-inf, inf], "",
84               "solvent scattering length density"],
85              ["radius", "Ang", 100, [0, inf], "volume",
86               "vesicle core radius"],
87              ["thickness", "Ang", 30, [0, inf], "volume",
88               "vesicle shell thickness"],
89             ]
90
91source = ["lib/sph_j1c.c", "vesicle.c"]
92
93def ER(radius, thickness):
94    '''
95    returns the effective radius used in the S*P calculation
96
97    :param radius: core radius
98    :param thickness: shell thickness
99    '''
100    return radius + thickness
101
102def VR(radius, thickness):
103    '''
104    returns the volumes of the shell and of the whole sphere including the
105    core plus shell - is used to normalize when including polydispersity.
106
107    :param radius: core radius
108    :param thickness: shell thickness
109    :return whole: volume of core and shell
110    :return whole-core: volume of the shell
111    '''
112
113    whole = 4. * pi * (radius + thickness) ** 3. / 3.
114    core = 4. * pi * radius ** 3. / 3.
115    return whole, whole - core
116
117
118# parameters for demo
119demo = dict(scale=1, background=0,
120            sld=0.5, solvent_sld=6.36,
121            radius=100, thickness=30,
122            radius_pd=.2, radius_pd_n=10,
123            thickness_pd=.2, thickness_pd_n=10)
124
125# For testing against the old sasview models, include the converted parameter
126# names and the target sasview model name.
127oldname = 'VesicleModel'
128oldpars = dict(sld='shell_sld', solvent_sld='solv_sld')
129
130
131# NOTE: test results taken from values returned by SasView 3.1.2
132tests = [[{}, 0.0010005303255, 17139.8268799],
133         [{}, 0.200027832249, 0.130387268704 ],
134         [{}, 'ER', 130.],
135         [{}, 'VR', 0.54483386436],
136        ]
Note: See TracBrowser for help on using the repository browser.