source: sasmodels/sasmodels/models/core_shell_parallelepiped.py @ 43b7eea

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

Initial clean-up of Bessel functions

  • Property mode set to 100644
File size: 7.6 KB
Line 
1# core_shell_parallelepiped model
2# Note: model title and parameter table are inserted automatically
3r"""
4Calculates the form factor for a rectangular solid with a core-shell structure.
5**The thickness and the scattering length density of the shell or "rim"
6can be different on all three (pairs) of faces.**
7
8The form factor is normalized by the particle volume *V* such that
9
10*I(q)* = *scale* \* <*f*\ :sup:`2`> / *V* + *background*
11
12where < > is an average over all possible orientations of the rectangular solid.
13
14An instrument resolution smeared version of the model is also provided.
15
16
17Definition
18----------
19
20The function calculated is the form factor of the rectangular solid below.
21The core of the solid is defined by the dimensions *A*, *B*, *C* such that
22*A* < *B* < *C*.
23
24.. image:: img/core_shell_parallelepiped_geometry.jpg
25
26There are rectangular "slabs" of thickness $t_A$ that add to the *A* dimension
27(on the *BC* faces). There are similar slabs on the *AC* $(=t_B)$ and *AB*
28$(=t_C)$ faces. The projection in the *AB* plane is then
29
30.. image:: img/core_shell_parallelepiped_projection.jpg
31
32The volume of the solid is
33
34.. math::
35
36    V = ABC + 2t_ABC + 2t_BAC + 2t_CAB
37
38**meaning that there are "gaps" at the corners of the solid.**
39
40The intensity calculated follows the :ref:`parallelepiped` model, with the core-shell
41intensity being calculated as the square of the sum of the amplitudes of the
42core and shell, in the same manner as a core-shell model.
43
44**For the calculation of the form factor to be valid, the sides of the solid
45MUST be chosen such that** *A* < *B* < *C*.
46**If this inequality is not satisfied, the model will not report an error,
47and the calculation will not be correct.**
48
49FITTING NOTES
50If the scale is set equal to the particle volume fraction, |phi|, the returned
51value is the scattered intensity per unit volume; ie, *I(q)* = |phi| *P(q)*.
52However, **no interparticle interference effects are included in this calculation.**
53
54There are many parameters in this model. Hold as many fixed as possible with
55known values, or you will certainly end up at a solution that is unphysical.
56
57Constraints must be applied during fitting to ensure that the inequality
58*A* < *B* < *C* is not violated. The calculation will not report an error,
59but the results will not be correct.
60
61The returned value is in units of |cm^-1|, on absolute scale.
62
63NB: The 2nd virial coefficient of the core_shell_parallelepiped is calculated
64based on the the averaged effective radius $(=\sqrt{(A+2t_A)(B+2t_B)/\pi})$
65and length $(C+2t_C)$ values, and used as the effective radius
66for *S(Q)* when *P(Q)* \* *S(Q)* is applied.
67
68.. Comment by Miguel Gonzalez:
69   The later seems to contradict the previous statement that interparticle interference
70   effects are not included.
71
72To provide easy access to the orientation of the parallelepiped, we define the
73axis of the cylinder using three angles |theta|, |phi| and |bigpsi|.
74(see :ref:`cylinder orientation <cylinder-angle-definition>`).
75The angle |bigpsi| is the rotational angle around the *long_c* axis against the
76*q* plane. For example, |bigpsi| = 0 when the *short_b* axis is parallel to the
77*x*-axis of the detector.
78
79.. figure:: img/parallelepiped_angle_definition.jpg
80
81    Definition of the angles for oriented core-shell parallelepipeds.
82
83.. figure:: img/parallelepiped_angle_projection.jpg
84
85    Examples of the angles for oriented core-shell parallelepipeds against the
86    detector plane.
87
88Validation
89----------
90
91The model uses the form factor calculations implemented in a c-library provided
92by the NIST Center for Neutron Research (Kline, 2006).
93
94References
95----------
96
97P Mittelbach and G Porod, *Acta Physica Austriaca*, 14 (1961) 185-211
98Equations (1), (13-14). (in German)
99
100"""
101
102import numpy as np
103from numpy import pi, inf, sqrt
104
105name = "core_shell_parallelepiped"
106title = "Rectangular solid with a core-shell structure."
107description = """
108     P(q)=
109"""
110category = "shape:parallelepiped"
111
112#             ["name", "units", default, [lower, upper], "type","description"],
113parameters = [["core_sld", "1e-6/Ang^2", 1, [-inf, inf], "",
114               "Parallelepiped core scattering length density"],
115              ["arim_sld", "1e-6/Ang^2", 2, [-inf, inf], "",
116               "Parallelepiped A rim scattering length density"],
117              ["brim_sld", "1e-6/Ang^2", 4, [-inf, inf], "",
118               "Parallelepiped B rim scattering length density"],
119              ["crim_sld", "1e-6/Ang^2", 2, [-inf, inf], "",
120               "Parallelepiped C rim scattering length density"],
121              ["solvent_sld", "1e-6/Ang^2", 6, [-inf, inf], "",
122               "Solvent scattering length density"],
123              ["a_side", "Ang", 35, [0, inf], "volume",
124               "Shorter side of the parallelepiped"],
125              ["b_side", "Ang", 75, [0, inf], "volume",
126               "Second side of the parallelepiped"],
127              ["c_side", "Ang", 400, [0, inf], "volume",
128               "Larger side of the parallelepiped"],
129              ["arim_thickness", "Ang", 10, [0, inf], "volume",
130               "Thickness of A rim"],
131              ["brim_thickness", "Ang", 10, [0, inf], "volume",
132               "Thickness of B rim"],
133              ["crim_thickness", "Ang", 10, [0, inf], "volume",
134               "Thickness of C rim"],
135              ["theta", "degrees", 0, [-inf, inf], "orientation",
136               "In plane angle"],
137              ["phi", "degrees", 0, [-inf, inf], "orientation",
138               "Out of plane angle"],
139              ["psi", "degrees", 0, [-inf, inf], "orientation",
140               "Rotation angle around its own c axis against q plane"],
141             ]
142
143source = ["lib/gauss76.c", "core_shell_parallelepiped.c"]
144
145
146def ER(a_side, b_side, c_side, arim_thickness, brim_thickness, crim_thickness):
147    """
148        Return equivalent radius (ER)
149    """
150
151    # surface average radius (rough approximation)
152    surf_rad = sqrt((a_side + 2.0*arim_thickness) * (b_side + 2.0*brim_thickness) / pi)
153
154    height = c_side + 2.0*crim_thickness
155
156    ddd = 0.75 * surf_rad * (2 * surf_rad * height + (height + surf_rad) * (height + pi * surf_rad))
157    return 0.5 * (ddd) ** (1. / 3.)
158
159# VR defaults to 1.0
160
161# parameters for demo
162demo = dict(scale=1, background=0.0,
163            core_sld=1e-6, arim_sld=2e-6, brim_sld=4e-6,
164            crim_sld=2e-6, solvent_sld=6e-6,
165            a_side=35, b_side=75, c_side=400,
166            arim_thickness=10, brim_thickness=10, crim_thickness=10,
167            theta=0, phi=0, psi=0,
168            a_side_pd=0.1, a_side_pd_n=1,
169            b_side_pd=0.1, b_side_pd_n=1,
170            c_side_pd=0.1, c_side_pd_n=1,
171            arim_thickness_pd=0.1, arim_thickness_pd_n=1,
172            brim_thickness_pd=0.1, brim_thickness_pd_n=1,
173            crim_thickness_pd=0.1, crim_thickness_pd_n=1,
174            theta_pd=10, theta_pd_n=1,
175            phi_pd=10, phi_pd_n=1,
176            psi_pd=10, psi_pd_n=10)
177
178
179# For testing against the old sasview models, include the converted parameter
180# names and the target sasview model name.
181oldname = 'CSParallelepipedModel'
182oldpars = dict(theta='parallel_theta', phi='parallel_phi', psi='parallel_psi',
183               core_sld='sld_pcore', arim_sld='sld_rimA', brim_sld='sld_rimB',
184               crim_sld='sld_rimC', solvent_sld='sld_solv',
185               a_side='shortA', b_side='midB', c_side='longC',
186               arim_thickness='rimA', brim_thickness='rimB', crim_thickness='rimC')
187
188qx, qy = 0.2 * np.cos(2.5), 0.2 * np.sin(2.5)
189tests = [[{}, 0.2, 0.533149288477],
190         [{}, [0.2], [0.533149288477]],
191         [{'theta':10.0, 'phi':10.0}, (qx, qy), 0.032102135569],
192         [{'theta':10.0, 'phi':10.0}, [(qx, qy)], [0.032102135569]],
193        ]
194del qx, qy  # not necessary to delete, but cleaner
Note: See TracBrowser for help on using the repository browser.