source: sasmodels/sasmodels/models/core_shell_sphere.py @ 8c9dbc9

core_shell_microgelscostrafo411magnetic_modelrelease_v0.94release_v0.95ticket-1257-vesicle-productticket_1156ticket_1265_superballticket_822_more_unit_tests
Last change on this file since 8c9dbc9 was 8c9dbc9, checked in by Doucet, Mathieu <doucetm@…>, 8 years ago

fix pylint

  • Property mode set to 100644
File size: 4.0 KB
Line 
1r"""
2This model provides the form factor, $P(q)$, for a spherical particle with a core-shell structure.
3The form factor is normalized by the particle volume.
4
5Definition
6----------
7
8The 1D scattering intensity is calculated in the following way (Guinier, 1955)
9
10.. math::
11
12    P(q) = \frac{\text{scale}}{V} F^2(q) + \text{background}
13
14where
15
16.. math::
17    F^2(q)=\frac{3}{V_s}\left[V_c(\rho_c-\rho_s)\frac{\sin(qr_c)-qr_c\cos(qr_c)}{(qr_c)^3}+
18    V_s(\rho_s-\rho_{solv})\frac{\sin(qr_s)-qr_s\cos(qr_s)}{(qr_s)^3}\right]
19
20where $V_s$ is the volume of the outer shell, $V_c$ is
21the volume of the core, $r_s$ is the radius of the shell, $r_c$ is the radius of the
22core, $\rho_c$ is the scattering length density of the core, $\rho_s$ is the scattering length
23density of the shell, $\rho_{solv}$ is the scattering length density of the solvent.
24
25The 2D scattering intensity is the same as $P(q)$ above, regardless of the
26orientation of the $q$ vector.
27
28NB: The outer most radius (ie, = radius + thickness) is used as the
29effective radius for $S(Q)$ when $P(Q) \cdot S(Q)$ is applied.
30
31Reference
32---------
33
34A Guinier and G Fournet, *Small-Angle Scattering of X-Rays*, John Wiley and Sons, New York, (1955)
35
36Validation
37----------
38
39Validation of our code was done by comparing the output of the 1D model to the output of
40the software provided by NIST (Kline, 2006). Figure 1 shows a comparison of the output of
41our model and the output of the NIST software.
42
43.. image:: img/core_shell_sphere_1d.jpg
44
45    Figure 1: Comparison of the SasView scattering intensity for a core-shell sphere with
46    the output of the NIST SANS analysis software. The parameters were set to:
47    *scale* = 1.0, *radius* = 60 , *contrast* = 1e-6 |Ang^-2|, and
48    *background* = 0.001 |cm^-1|.
49"""
50
51from numpy import pi, inf
52
53name = "core_shell_sphere"
54title = "Form factor for a monodisperse spherical particle with particle with a core-shell structure."
55description = """
56    F^2(q) = 3/V_s [V_c (core_sld-shell_sld) (sin(q*radius)-q*radius*cos(q*radius))/(q*radius)^3
57                   + V_s (shell_sld-solvent_sld) (sin(q*r_s)-q*r_s*cos(q*r_s))/(q*r_s)^3]
58
59            V_s: Volume of the sphere shell
60            V_c: Volume of the sphere core
61            r_s: Shell radius = radius + thickness
62"""
63category = "shape:sphere"
64
65# pylint: disable=bad-whitespace, line-too-long
66#             ["name", "units", default, [lower, upper], "type","description"],
67parameters = [["radius",      "Ang",        60.0, [0, inf],    "volume", "Sphere core radius"],
68              ["thickness",   "Ang",        10.0, [0, inf],    "volume", "Sphere shell thickness"],
69              ["core_sld",    "1e-6/Ang^2", 1.0,  [-inf, inf], "",       "Sphere core scattering length density"],
70              ["shell_sld",   "1e-6/Ang^2", 2.0,  [-inf, inf], "",       "Sphere shell scattering length density"],
71              ["solvent_sld", "1e-6/Ang^2", 3.0,  [-inf, inf],  "",      "Solvent scattering length density"]]
72# pylint: enable=bad-whitespace, line-too-long
73
74source = ["lib/sph_j1c.c", "core_shell_sphere.c"]
75
76demo = dict(scale=1, background=0, radius=60, thickness=10,
77            core_sld=1.0, shell_sld=2.0, solvent_sld=0.0)
78
79oldname = 'CoreShellModel'
80oldpars = {}
81
82def ER(radius, thickness):
83    """
84        Equivalent radius
85        @param radius: core radius
86        @param thickness: shell thickness
87    """
88    return radius + thickness
89
90def VR(radius, thickness):
91    """
92        Volume ratio
93        @param radius: core radius
94        @param thickness: shell thickness
95    """
96    whole = 4.0 * pi / 3.0 * pow((radius + thickness), 3)
97    core = 4.0 * pi / 3.0 * radius * radius * radius
98    return whole, whole - core
99
100tests = [[{'radius': 20.0, 'thickness': 10.0}, 'ER', 30.0],
101         [{'radius': 20.0, 'thickness': 10.0}, 'VR', 0.703703704],
102
103         # The SasView test result was 0.00169, with a background of 0.001
104         [{'radius': 60.0,
105           'thickness': 10.0,
106           'core_sld': 1.0,
107           'shell_sld':2.0,
108           'solvent_sld':3.0,
109           'background':0.0
110          }, 0.4, 0.000698838]]
Note: See TracBrowser for help on using the repository browser.