source: sasmodels/sasmodels/models/core_shell_parallelepiped.py @ 6431056

core_shell_microgelscostrafo411magnetic_modelticket-1257-vesicle-productticket_1156ticket_1265_superballticket_822_more_unit_tests
Last change on this file since 6431056 was 797a8e3, checked in by butler, 7 years ago

Merge branch 'master' of https://github.com/SasView/sasmodels.git

  • Property mode set to 100644
File size: 7.6 KB
RevLine 
[44bd2be]1r"""
[5810f00]2Definition
3----------
4
[44bd2be]5Calculates the form factor for a rectangular solid with a core-shell structure.
6**The thickness and the scattering length density of the shell or "rim"
7can be different on all three (pairs) of faces.**
8
[500128b]9The form factor is normalized by the particle volume $V$ such that
[44bd2be]10
[500128b]11.. math::
12
13    I(q) = \text{scale}\frac{\langle f^2 \rangle}{V} + \text{background}
[44bd2be]14
[500128b]15where $\langle \ldots \rangle$ is an average over all possible orientations
16of the rectangular solid.
[44bd2be]17
18
19The function calculated is the form factor of the rectangular solid below.
[500128b]20The core of the solid is defined by the dimensions $A$, $B$, $C$ such that
21$A < B < C$.
[44bd2be]22
[2f0c07d]23.. image:: img/core_shell_parallelepiped_geometry.jpg
[44bd2be]24
[500128b]25There are rectangular "slabs" of thickness $t_A$ that add to the $A$ dimension
26(on the $BC$ faces). There are similar slabs on the $AC$ $(=t_B)$ and $AB$
27$(=t_C)$ faces. The projection in the $AB$ plane is then
[44bd2be]28
29.. image:: img/core_shell_parallelepiped_projection.jpg
30
31The volume of the solid is
32
33.. math::
34
35    V = ABC + 2t_ABC + 2t_BAC + 2t_CAB
36
37**meaning that there are "gaps" at the corners of the solid.**
38
[5810f00]39The intensity calculated follows the :ref:`parallelepiped` model, with the
40core-shell intensity being calculated as the square of the sum of the
41amplitudes of the core and shell, in the same manner as a core-shell model.
[44bd2be]42
[5810f00]43.. math::
44
45    F_{a}(Q,\alpha,\beta)=
46    \Bigg(\frac{sin(Q(L_A+2t_A)/2sin\alpha sin\beta)}{Q(L_A+2t_A)/2sin\alpha
47    sin\beta)}
48    - \frac{sin(QL_A/2sin\alpha sin\beta)}{QL_A/2sin\alpha sin\beta)} \Bigg)
49    + \frac{sin(QL_B/2sin\alpha sin\beta)}{QL_B/2sin\alpha sin\beta)}
50    + \frac{sin(QL_C/2sin\alpha sin\beta)}{QL_C/2sin\alpha sin\beta)}
51
52.. note::
53
54    For the calculation of the form factor to be valid, the sides of the solid
55    MUST be chosen such that** $A < B < C$.
56    If this inequality is not satisfied, the model will not report an error,
57    but the calculation will not be correct and thus the result wrong.
[44bd2be]58
59FITTING NOTES
60If the scale is set equal to the particle volume fraction, |phi|, the returned
[500128b]61value is the scattered intensity per unit volume, $I(q) = \phi P(q)$.
[5810f00]62However, **no interparticle interference effects are included in this
63calculation.**
[44bd2be]64
65There are many parameters in this model. Hold as many fixed as possible with
66known values, or you will certainly end up at a solution that is unphysical.
67
68Constraints must be applied during fitting to ensure that the inequality
[500128b]69$A < B < C$ is not violated. The calculation will not report an error,
[44bd2be]70but the results will not be correct.
71
72The returned value is in units of |cm^-1|, on absolute scale.
73
74NB: The 2nd virial coefficient of the core_shell_parallelepiped is calculated
75based on the the averaged effective radius $(=\sqrt{(A+2t_A)(B+2t_B)/\pi})$
76and length $(C+2t_C)$ values, and used as the effective radius
[500128b]77for $S(Q)$ when $P(Q) * S(Q)$ is applied.
[44bd2be]78
79To provide easy access to the orientation of the parallelepiped, we define the
[500128b]80axis of the cylinder using three angles $\theta$, $\phi$ and $\Psi$.
[2f0c07d]81(see :ref:`cylinder orientation <cylinder-angle-definition>`).
[500128b]82The angle $\Psi$ is the rotational angle around the *long_c* axis against the
83$q$ plane. For example, $\Psi = 0$ when the *short_b* axis is parallel to the
[44bd2be]84*x*-axis of the detector.
85
[2f0c07d]86.. figure:: img/parallelepiped_angle_definition.jpg
[44bd2be]87
88    Definition of the angles for oriented core-shell parallelepipeds.
89
[2f0c07d]90.. figure:: img/parallelepiped_angle_projection.jpg
[44bd2be]91
92    Examples of the angles for oriented core-shell parallelepipeds against the
93    detector plane.
94
95Validation
96----------
97
98The model uses the form factor calculations implemented in a c-library provided
99by the NIST Center for Neutron Research (Kline, 2006).
100
[aa2edb2]101References
102----------
[44bd2be]103
[5810f00]104.. [#] P Mittelbach and G Porod, *Acta Physica Austriaca*, 14 (1961) 185-211
105    Equations (1), (13-14). (in German)
106.. [#] D Singh (2009). *Small angle scattering studies of self assembly in
107   lipid mixtures*, John's Hopkins University Thesis (2009) 223-225. `Available
108   from Proquest <http://search.proquest.com/docview/304915826?accountid
109   =26379>`_
110
111Authorship and Verification
112----------------------------
[44bd2be]113
[5810f00]114* **Author:** NIST IGOR/DANSE **Date:** pre 2010
115* **Last Modified by:** Paul Butler **Date:** September 30, 2016
116* **Last Reviewed by:** Miguel Gonzales **Date:** March 21, 2016
[44bd2be]117"""
118
119import numpy as np
120from numpy import pi, inf, sqrt
121
122name = "core_shell_parallelepiped"
123title = "Rectangular solid with a core-shell structure."
124description = """
125     P(q)=
126"""
127category = "shape:parallelepiped"
128
129#             ["name", "units", default, [lower, upper], "type","description"],
[42356c8]130parameters = [["sld_core", "1e-6/Ang^2", 1, [-inf, inf], "sld",
[44bd2be]131               "Parallelepiped core scattering length density"],
[42356c8]132              ["sld_a", "1e-6/Ang^2", 2, [-inf, inf], "sld",
[44bd2be]133               "Parallelepiped A rim scattering length density"],
[42356c8]134              ["sld_b", "1e-6/Ang^2", 4, [-inf, inf], "sld",
[44bd2be]135               "Parallelepiped B rim scattering length density"],
[42356c8]136              ["sld_c", "1e-6/Ang^2", 2, [-inf, inf], "sld",
[44bd2be]137               "Parallelepiped C rim scattering length density"],
[42356c8]138              ["sld_solvent", "1e-6/Ang^2", 6, [-inf, inf], "sld",
[44bd2be]139               "Solvent scattering length density"],
[2222134]140              ["length_a", "Ang", 35, [0, inf], "volume",
[44bd2be]141               "Shorter side of the parallelepiped"],
[2222134]142              ["length_b", "Ang", 75, [0, inf], "volume",
[44bd2be]143               "Second side of the parallelepiped"],
[2222134]144              ["length_c", "Ang", 400, [0, inf], "volume",
[44bd2be]145               "Larger side of the parallelepiped"],
[2222134]146              ["thick_rim_a", "Ang", 10, [0, inf], "volume",
[44bd2be]147               "Thickness of A rim"],
[2222134]148              ["thick_rim_b", "Ang", 10, [0, inf], "volume",
[44bd2be]149               "Thickness of B rim"],
[2222134]150              ["thick_rim_c", "Ang", 10, [0, inf], "volume",
[44bd2be]151               "Thickness of C rim"],
152              ["theta", "degrees", 0, [-inf, inf], "orientation",
153               "In plane angle"],
154              ["phi", "degrees", 0, [-inf, inf], "orientation",
155               "Out of plane angle"],
156              ["psi", "degrees", 0, [-inf, inf], "orientation",
157               "Rotation angle around its own c axis against q plane"],
158             ]
159
[43b7eea]160source = ["lib/gauss76.c", "core_shell_parallelepiped.c"]
[44bd2be]161
162
[2222134]163def ER(length_a, length_b, length_c, thick_rim_a, thick_rim_b, thick_rim_c):
[44bd2be]164    """
165        Return equivalent radius (ER)
166    """
167
168    # surface average radius (rough approximation)
[2222134]169    surf_rad = sqrt((length_a + 2.0*thick_rim_a) * (length_b + 2.0*thick_rim_b) / pi)
[44bd2be]170
[2222134]171    height = length_c + 2.0*thick_rim_c
[44bd2be]172
173    ddd = 0.75 * surf_rad * (2 * surf_rad * height + (height + surf_rad) * (height + pi * surf_rad))
174    return 0.5 * (ddd) ** (1. / 3.)
175
176# VR defaults to 1.0
177
178# parameters for demo
179demo = dict(scale=1, background=0.0,
[14838a3]180            sld_core=1, sld_a=2, sld_b=4, sld_c=2, sld_solvent=6,
[2222134]181            length_a=35, length_b=75, length_c=400,
182            thick_rim_a=10, thick_rim_b=10, thick_rim_c=10,
[44bd2be]183            theta=0, phi=0, psi=0,
[2222134]184            length_a_pd=0.1, length_a_pd_n=1,
185            length_b_pd=0.1, length_b_pd_n=1,
186            length_c_pd=0.1, length_c_pd_n=1,
187            thick_rim_a_pd=0.1, thick_rim_a_pd_n=1,
188            thick_rim_b_pd=0.1, thick_rim_b_pd_n=1,
189            thick_rim_c_pd=0.1, thick_rim_c_pd_n=1,
[44bd2be]190            theta_pd=10, theta_pd_n=1,
191            phi_pd=10, phi_pd_n=1,
[14838a3]192            psi_pd=10, psi_pd_n=1)
[44bd2be]193
194qx, qy = 0.2 * np.cos(2.5), 0.2 * np.sin(2.5)
[6dd90c1]195tests = [[{}, 0.2, 0.533149288477],
196         [{}, [0.2], [0.533149288477]],
197         [{'theta':10.0, 'phi':10.0}, (qx, qy), 0.032102135569],
198         [{'theta':10.0, 'phi':10.0}, [(qx, qy)], [0.032102135569]],
[44bd2be]199        ]
200del qx, qy  # not necessary to delete, but cleaner
Note: See TracBrowser for help on using the repository browser.