# source:sasmodels/sasmodels/models/vesicle.py@ef07e95

core_shell_microgelsmagnetic_modelticket-1257-vesicle-productticket_1156ticket_1265_superballticket_822_more_unit_tests
Last change on this file since ef07e95 was ef07e95, checked in by Paul Kienzle <pkienzle@…>, 5 years ago

use consistent formatting for 'Last Reviewed'

• Property mode set to 100644
File size: 5.3 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{\phi}{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 $\phi$ is the volume fraction of shell material, $V_{shell}$ is the volume
18of the shell, $V_{\text{cor}}$ is the volume of the core, $V_{\text{tot}}$ is
19the total volume, $R_{\text{core}}$ is the radius of the core, $R_{\text{tot}}$
20is the outer radius of the shell, $\rho_{\text{solvent}}$ is the scattering
21length density of the solvent (which is the same as for the core in this case),
22$\rho_{\text{scale}}$ is the scattering length density of the shell, background
23is a flat background level (due for example to incoherent scattering in the
24case of neutrons), and $j_1$ is the spherical bessel function
25$j_1 = (\sin(x) - x \cos(x))/ x^2$.
26
27The functional form is identical to a "typical" core-shell structure, except
28that the scattering is normalized by the volume that is contributing to the
29scattering, namely the volume of the shell alone, the scattering length density
30of the core is fixed the same as that of the solvent, the scale factor when the
31data are on an absolute scale is equivalent to the volume fraction of material
32in the shell rather than the entire core+shell sphere, and the parameterization
33is done in terms of the core radius = $R_{\text{core}}$ and the shell
34thickness = $R_{\text{tot}} - R_{\text{core}}$.
35
36.. figure:: img/vesicle_geometry.jpg
37
38    Vesicle geometry.
39
40The 2D scattering intensity is the same as *P(q)* above, regardless of the
41orientation of the *q* vector which is defined as
42
43.. math::
44
45    q = \sqrt{q_x^2 + q_y^2}
46
47
48NB: The outer most radius (= *radius* + *thickness*) is used as the effective
49radius for *S(Q)* when *P(Q)* \* *S(Q)* is applied.
50
51
52References
53----------
54
55A Guinier and G. Fournet, *Small-Angle Scattering of X-Rays*, John Wiley and
56Sons, New York, (1955)
57
58* **Author:** NIST IGOR/DANSE **Date:** pre 2010
60* **Last Reviewed by:** Paul Butler **Date:** March 20, 2016
61"""
62
63import numpy as np
64from numpy import pi, inf
65
66name = "vesicle"
67title = "This model provides the form factor, *P(q)*, for an unilamellar \
68    vesicle. This is model is effectively identical to the hollow sphere \
69    reparameterized to be more intuitive for a vesicle and normalizing the \
70    form factor by the volume of the shell."
71description = """
72    Model parameters:
74        thickness: the shell thickness
75        sld: the shell SLD
76        sld_solvent: the solvent (and core) SLD
77        background: incoherent background
78        volfraction: shell volume fraction
79        scale : scale factor = 1 if on absolute scale"""
80category = "shape:sphere"
81
82#             [ "name", "units", default, [lower, upper], "type", "description"],
83parameters = [["sld", "1e-6/Ang^2", 0.5, [-inf, inf], "sld",
84               "vesicle shell scattering length density"],
85              ["sld_solvent", "1e-6/Ang^2", 6.36, [-inf, inf], "sld",
86               "solvent scattering length density"],
87              ["volfraction", "", 0.05, [0, 1.0], "",
88               "volume fraction of shell"],
89              ["radius", "Ang", 100, [0, inf], "volume",
91              ["thickness", "Ang", 30, [0, inf], "volume",
92               "vesicle shell thickness"],
93             ]
94
95source = ["lib/sas_3j1x_x.c", "vesicle.c"]
96
98    '''
99    returns the effective radius used in the S*P calculation
100
102    :param thickness: shell thickness
103    '''
105
107    '''
108    returns the volumes of the shell and of the whole sphere including the
109    core plus shell - is used to normalize when including polydispersity.
110
112    :param thickness: shell thickness
113    :return whole: volume of core and shell
114    :return whole-core: volume of the shell
115    '''
116
117    whole = 4./3. * pi * (radius + thickness)**3
118    core = 4./3. * pi * radius**3
119    return whole, whole - core
120
121def random():
125    volfraction = 10**np.random.uniform(-3, -1)
126    pars = dict(
127        #background=0,
128        scale=1,  # volfraction is part of the model, so scale=1
130        thickness=thickness,
131        volfraction=volfraction,
132    )
133    return pars
134
135# parameters for demo
136demo = dict(sld=0.5, sld_solvent=6.36,
137            volfraction=0.05,