source: sasmodels/sasmodels/models/core_shell_parallelepiped.py @ 2f0c07d

core_shell_microgelscostrafo411magnetic_modelrelease_v0.94release_v0.95ticket-1257-vesicle-productticket_1156ticket_1265_superballticket_822_more_unit_tests
Last change on this file since 2f0c07d was 2f0c07d, checked in by Paul Kienzle <pkienzle@…>, 8 years ago

make figure names regular (geometry, angle_definition, angle_projection)

  • 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
94REFERENCE
95
96P Mittelbach and G Porod, *Acta Physica Austriaca*, 14 (1961) 185-211
97Equations (1), (13-14). (in German)
98
99"""
100
101import numpy as np
102from numpy import pi, inf, sqrt
103
104name = "core_shell_parallelepiped"
105title = "Rectangular solid with a core-shell structure."
106description = """
107     P(q)=
108"""
109category = "shape:parallelepiped"
110
111#             ["name", "units", default, [lower, upper], "type","description"],
112parameters = [["core_sld", "1e-6/Ang^2", 1, [-inf, inf], "",
113               "Parallelepiped core scattering length density"],
114              ["arim_sld", "1e-6/Ang^2", 2, [-inf, inf], "",
115               "Parallelepiped A rim scattering length density"],
116              ["brim_sld", "1e-6/Ang^2", 4, [-inf, inf], "",
117               "Parallelepiped B rim scattering length density"],
118              ["crim_sld", "1e-6/Ang^2", 2, [-inf, inf], "",
119               "Parallelepiped C rim scattering length density"],
120              ["solvent_sld", "1e-6/Ang^2", 6, [-inf, inf], "",
121               "Solvent scattering length density"],
122              ["a_side", "Ang", 35, [0, inf], "volume",
123               "Shorter side of the parallelepiped"],
124              ["b_side", "Ang", 75, [0, inf], "volume",
125               "Second side of the parallelepiped"],
126              ["c_side", "Ang", 400, [0, inf], "volume",
127               "Larger side of the parallelepiped"],
128              ["arim_thickness", "Ang", 10, [0, inf], "volume",
129               "Thickness of A rim"],
130              ["brim_thickness", "Ang", 10, [0, inf], "volume",
131               "Thickness of B rim"],
132              ["crim_thickness", "Ang", 10, [0, inf], "volume",
133               "Thickness of C rim"],
134              ["theta", "degrees", 0, [-inf, inf], "orientation",
135               "In plane angle"],
136              ["phi", "degrees", 0, [-inf, inf], "orientation",
137               "Out of plane angle"],
138              ["psi", "degrees", 0, [-inf, inf], "orientation",
139               "Rotation angle around its own c axis against q plane"],
140             ]
141
142source = ["lib/J1.c", "lib/gauss76.c", "core_shell_parallelepiped.c"]
143
144
145def ER(a_side, b_side, c_side, arim_thickness, brim_thickness, crim_thickness):
146    """
147        Return equivalent radius (ER)
148    """
149
150    # surface average radius (rough approximation)
151    surf_rad = sqrt((a_side + 2.0*arim_thickness) * (b_side + 2.0*brim_thickness) / pi)
152
153    height = c_side + 2.0*crim_thickness
154
155    ddd = 0.75 * surf_rad * (2 * surf_rad * height + (height + surf_rad) * (height + pi * surf_rad))
156    return 0.5 * (ddd) ** (1. / 3.)
157
158# VR defaults to 1.0
159
160# parameters for demo
161demo = dict(scale=1, background=0.0,
162            core_sld=1e-6, arim_sld=2e-6, brim_sld=4e-6,
163            crim_sld=2e-6, solvent_sld=6e-6,
164            a_side=35, b_side=75, c_side=400,
165            arim_thickness=10, brim_thickness=10, crim_thickness=10,
166            theta=0, phi=0, psi=0,
167            a_side_pd=0.1, a_side_pd_n=1,
168            b_side_pd=0.1, b_side_pd_n=1,
169            c_side_pd=0.1, c_side_pd_n=1,
170            arim_thickness_pd=0.1, arim_thickness_pd_n=1,
171            brim_thickness_pd=0.1, brim_thickness_pd_n=1,
172            crim_thickness_pd=0.1, crim_thickness_pd_n=1,
173            theta_pd=10, theta_pd_n=1,
174            phi_pd=10, phi_pd_n=1,
175            psi_pd=10, psi_pd_n=10)
176
177
178# For testing against the old sasview models, include the converted parameter
179# names and the target sasview model name.
180oldname = 'CSParallelepipedModel'
181oldpars = dict(theta='parallel_theta', phi='parallel_phi', psi='parallel_psi',
182               core_sld='sld_pcore', arim_sld='sld_rimA', brim_sld='sld_rimB',
183               crim_sld='sld_rimC', solvent_sld='sld_solv',
184               a_side='shortA', b_side='midB', c_side='longC',
185               arim_thickness='rimA', brim_thickness='rimB', crim_thickness='rimC')
186
187qx, qy = 0.2 * np.cos(2.5), 0.2 * np.sin(2.5)
188tests = [[{}, 0.2, 0.532149288477],
189         [{}, [0.2], [0.532149288477]],
190         [{'theta':10.0, 'phi':10.0}, (qx, qy), 0.031102135569],
191         [{'theta':10.0, 'phi':10.0}, [(qx, qy)], [0.031102135569]],
192        ]
193del qx, qy  # not necessary to delete, but cleaner
Note: See TracBrowser for help on using the repository browser.