# source:sasmodels/sasmodels/models/vesicle.py@6e7d7b6

core_shell_microgelsmagnetic_modelticket-1257-vesicle-productticket_1156ticket_1265_superballticket_822_more_unit_tests
Last change on this file since 6e7d7b6 was 6e7d7b6, checked in by butler, 10 months ago

Fix Vesicle and Hollow Rectangular Prism Thin Walls

fix errors and document normalizatin for the two aforementioned models

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