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

core_shell_microgelscostrafo411magnetic_modelrelease_v0.94release_v0.95ticket-1257-vesicle-productticket_1156ticket_1265_superballticket_822_more_unit_tests
Last change on this file since e481a39 was aa2edb2, checked in by gonzalezm, 8 years ago

Removing hardcoded figures to be replaced by autogenerated ones

  • Property mode set to 100644
File size: 4.8 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
39    Vesicle geometry.
40
41The 2D scattering intensity is the same as *P(q)* above, regardless of the
42orientation of the *q* vector which is defined as
43
44.. math::
45
46    q = \sqrt{q_x^2 + q_y^2}
47
48
49NB: The outer most radius (= *radius* + *thickness*) is used as the effective
50radius for *S(Q)* when *P(Q)* \* *S(Q)* is applied.
51
52
53References
54----------
55
56A Guinier and G. Fournet, *Small-Angle Scattering of X-Rays*, John Wiley and
57Sons, New York, (1955)
58"""
59
60from numpy import pi, inf
61
62name = "vesicle"
63title = "This model provides the form factor, *P(q)*, for an unilamellar \
64    vesicle. This is model is effectively identical to the hollow sphere \
65    reparameterized to be more intuitive for a vesicle and normalizing the \
66    form factor by the volume of the shell."
67description = """
68    Model parameters:
69        radius : the core radius of the vesicle
70        thickness: the shell thickness
71        sld: the shell SLD
72        solvent_sld: the solvent (and core) SLD
73        background: incoherent background
74        scale : scale factor = shell volume fraction if on absolute scale"""
75category = "shape:sphere"
76
77#             [ "name", "units", default, [lower, upper], "type", "description"],
78parameters = [["sld", "1e-6/Ang^2", 0.5, [-inf, inf], "",
79               "vesicle shell scattering length density"],
80              ["solvent_sld", "1e-6/Ang^2", 6.36, [-inf, inf], "",
81               "solvent scattering length density"],
82              ["radius", "Ang", 100, [0, inf], "volume",
83               "vesicle core radius"],
84              ["thickness", "Ang", 30, [0, inf], "volume",
85               "vesicle shell thickness"],
86             ]
87
88source = ["lib/sph_j1c.c", "vesicle.c"]
89
90def ER(radius, thickness):
91    '''
92    returns the effective radius used in the S*P calculation
93
94    :param radius: core radius
95    :param thickness: shell thickness
96    '''
97    return radius + thickness
98
99def VR(radius, thickness):
100    '''
101    returns the volumes of the shell and of the whole sphere including the
102    core plus shell - is used to normalize when including polydispersity.
103
104    :param radius: core radius
105    :param thickness: shell thickness
106    :return whole: volume of core and shell
107    :return whole-core: volume of the shell
108    '''
109
110    whole = 4. * pi * (radius + thickness) ** 3. / 3.
111    core = 4. * pi * radius ** 3. / 3.
112    return whole, whole - core
113
114
115# parameters for demo
116demo = dict(scale=1, background=0,
117            sld=0.5, solvent_sld=6.36,
118            radius=100, thickness=30,
119            radius_pd=.2, radius_pd_n=10,
120            thickness_pd=.2, thickness_pd_n=10)
121
122# For testing against the old sasview models, include the converted parameter
123# names and the target sasview model name.
124oldname = 'VesicleModel'
125oldpars = dict(sld='shell_sld', solvent_sld='solv_sld')
126
127
128# NOTE: test results taken from values returned by SasView 3.1.2, with
129# 0.001 added for a non-zero default background.
130tests = [[{}, 0.0010005303255, 17139.8278799],
131         [{}, 0.200027832249, 0.131387268704],
132         [{}, 'ER', 130.],
133         [{}, 'VR', 0.54483386436],
134        ]
Note: See TracBrowser for help on using the repository browser.