Changeset 64eecf7 in sasmodels for sasmodels/models/core_shell_bicelle_elliptical.py
- Timestamp:
- Sep 5, 2017 11:40:09 AM (7 years ago)
- Branches:
- master, core_shell_microgels, costrafo411, magnetic_model, ticket-1257-vesicle-product, ticket_1156, ticket_1265_superball, ticket_822_more_unit_tests
- Children:
- 30b60d2
- Parents:
- a53bf6b (diff), 142a8e2 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent. - File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sasmodels/models/core_shell_bicelle_elliptical.py
ra53bf6b r64eecf7 6 6 core-shell scattering length density profile. Thus this is a variation 7 7 of the core-shell bicelle model, but with an elliptical cylinder for the core. 8 Outer shells on the rims and flat ends may be of different thicknesses and 8 Outer shells on the rims and flat ends may be of different thicknesses and 9 9 scattering length densities. The form factor is normalized by the total particle volume. 10 10 … … 17 17 .. figure:: img/core_shell_bicelle_parameters.png 18 18 19 Cross section of model used here. Users will have 20 to decide how to distribute "heads" and "tails" between the rim, face 19 Cross section of model used here. Users will have 20 to decide how to distribute "heads" and "tails" between the rim, face 21 21 and core regions in order to estimate appropriate starting parameters. 22 22 … … 27 27 .. math:: 28 28 29 \rho(r) = 30 \begin{cases} 29 \rho(r) = 30 \begin{cases} 31 31 &\rho_c \text{ for } 0 \lt r \lt R; -L \lt z\lt L \\[1.5ex] 32 32 &\rho_f \text{ for } 0 \lt r \lt R; -(L+2t) \lt z\lt -L; … … 50 50 51 51 \begin{align} 52 F(Q,\alpha,\psi) = &\bigg[ 52 F(Q,\alpha,\psi) = &\bigg[ 53 53 (\rho_c - \rho_f) V_c \frac{2J_1(QR'sin \alpha)}{QR'sin\alpha}\frac{sin(QLcos\alpha/2)}{Q(L/2)cos\alpha} \\ 54 54 &+(\rho_f - \rho_r) V_{c+f} \frac{2J_1(QR'sin\alpha)}{QR'sin\alpha}\frac{sin(Q(L/2+t_f)cos\alpha)}{Q(L/2+t_f)cos\alpha} \\ 55 55 &+(\rho_r - \rho_s) V_t \frac{2J_1(Q(R'+t_r)sin\alpha)}{Q(R'+t_r)sin\alpha}\frac{sin(Q(L/2+t_f)cos\alpha)}{Q(L/2+t_f)cos\alpha} 56 56 \bigg] 57 \end{align} 57 \end{align} 58 58 59 59 where … … 62 62 63 63 R'=\frac{R}{\sqrt{2}}\sqrt{(1+X_{core}^{2}) + (1-X_{core}^{2})cos(\psi)} 64 65 66 and $V_t = \pi.(R+t_r)(Xcore.R+t_r)^2.(L+2.t_f)$ is the total volume of the bicelle, 67 $V_c = \pi.Xcore.R^2.L$ the volume of the core, $V_{c+f} = \pi.Xcore.R^2.(L+2.t_f)$ 64 65 66 and $V_t = \pi.(R+t_r)(Xcore.R+t_r)^2.(L+2.t_f)$ is the total volume of the bicelle, 67 $V_c = \pi.Xcore.R^2.L$ the volume of the core, $V_{c+f} = \pi.Xcore.R^2.(L+2.t_f)$ 68 68 the volume of the core plus the volume of the faces, $R$ is the radius 69 of the core, $Xcore$ is the axial ratio of the core, $L$ the length of the core, 70 $t_f$ the thickness of the face, $t_r$ the thickness of the rim and $J_1$ the usual 71 first order bessel function. The core has radii $R$ and $Xcore.R$ so is circular, 72 as for the core_shell_bicelle model, for $Xcore$ =1. Note that you may need to 73 limit the range of $Xcore$, especially if using the Monte-Carlo algorithm, as 69 of the core, $Xcore$ is the axial ratio of the core, $L$ the length of the core, 70 $t_f$ the thickness of the face, $t_r$ the thickness of the rim and $J_1$ the usual 71 first order bessel function. The core has radii $R$ and $Xcore.R$ so is circular, 72 as for the core_shell_bicelle model, for $Xcore$ =1. Note that you may need to 73 limit the range of $Xcore$, especially if using the Monte-Carlo algorithm, as 74 74 setting radius to $R/Xcore$ and axial ratio to $1/Xcore$ gives an equivalent solution! 75 75 … … 77 77 bicelles is then given by integrating over all possible $\alpha$ and $\psi$. 78 78 79 For oriented bicell les the *theta*, *phi* and *psi* orientation parameters only appear when fitting 2D data,79 For oriented bicelles the *theta*, *phi* and *psi* orientation parameters will appear when fitting 2D data, 80 80 see the :ref:`elliptical-cylinder` model for further information. 81 81 82 82 83 .. figure:: img/elliptical_cylinder_angle_definition. jpg83 .. figure:: img/elliptical_cylinder_angle_definition.png 84 84 85 Definition of the angles for the oriented core_shell_bicelle_elliptical model.86 Note that *theta* and *phi* are currently defined differently to those for the core_shell_bicelle model. 85 Definition of the angles for the oriented core_shell_bicelle_elliptical particles. 86 87 87 88 88 … … 100 100 """ 101 101 102 from numpy import inf, sin, cos 102 from numpy import inf, sin, cos, pi 103 103 104 104 name = "core_shell_bicelle_elliptical" … … 106 106 description = """ 107 107 core_shell_bicelle_elliptical 108 Elliptical cylinder core, optional shell on the two flat faces, and shell of 109 uniform thickness on its rim (extending around the end faces). 108 Elliptical cylinder core, optional shell on the two flat faces, and shell of 109 uniform thickness on its rim (extending around the end faces). 110 110 Please see full documentation for equations and further details. 111 111 Involves a double numerical integral around the ellipsoid diameter … … 120 120 ["radius", "Ang", 30, [0, inf], "volume", "Cylinder core radius"], 121 121 ["x_core", "None", 3, [0, inf], "volume", "axial ratio of core, X = r_polar/r_equatorial"], 122 ["thick_rim", "Ang", 8, [0, inf], "volume", "Rim shell thickness"],123 ["thick_face", "Ang", 14, [0, inf], "volume", "Cylinder face thickness"],124 ["length", "Ang", 50, [0, inf], "volume", "Cylinder length"],122 ["thick_rim", "Ang", 8, [0, inf], "volume", "Rim shell thickness"], 123 ["thick_face", "Ang", 14, [0, inf], "volume", "Cylinder face thickness"], 124 ["length", "Ang", 50, [0, inf], "volume", "Cylinder length"], 125 125 ["sld_core", "1e-6/Ang^2", 4, [-inf, inf], "sld", "Cylinder core scattering length density"], 126 126 ["sld_face", "1e-6/Ang^2", 7, [-inf, inf], "sld", "Cylinder face scattering length density"], 127 127 ["sld_rim", "1e-6/Ang^2", 1, [-inf, inf], "sld", "Cylinder rim scattering length density"], 128 128 ["sld_solvent", "1e-6/Ang^2", 6, [-inf, inf], "sld", "Solvent scattering length density"], 129 ["theta", "degrees", 90, [-360, 360], "orientation", "In planeangle"],130 ["phi", "degrees", 0, [-360, 360], "orientation", "Out of plane angle"],131 ["psi", "degrees", 0, [-360, 360], "orientation", "Major axis angle relative to Q"],129 ["theta", "degrees", 90.0, [-360, 360], "orientation", "cylinder axis to beam angle"], 130 ["phi", "degrees", 0, [-360, 360], "orientation", "rotation about beam"], 131 ["psi", "degrees", 0, [-360, 360], "orientation", "rotation about cylinder axis"] 132 132 ] 133 133 … … 137 137 "core_shell_bicelle_elliptical.c"] 138 138 139 demo = dict(scale=1, background=0, 140 radius=30.0, 141 x_core=3.0, 142 thick_rim=8.0, 143 thick_face=14.0, 144 length=50.0, 145 sld_core=4.0, 146 sld_face=7.0, 147 sld_rim=1.0, 148 sld_solvent=6.0, 149 theta=90, 150 phi=0, 151 psi=0) 139 def random(): 140 import numpy as np 141 outer_major = 10**np.random.uniform(1, 4.7) 142 outer_minor = 10**np.random.uniform(1, 4.7) 143 # Use a distribution with a preference for thin shell or thin core, 144 # limited by the minimum radius. Avoid core,shell radii < 1 145 min_radius = min(outer_major, outer_minor) 146 thick_rim = np.random.beta(0.5, 0.5)*(min_radius-2) + 1 147 radius_major = outer_major - thick_rim 148 radius_minor = outer_minor - thick_rim 149 radius = radius_major 150 x_core = radius_minor/radius_major 151 outer_length = 10**np.random.uniform(1, 4.7) 152 # Caps should be a small percentage of the total length, but at least one 153 # angstrom long. Since outer length >= 10, the following will suffice 154 thick_face = 10**np.random.uniform(-np.log10(outer_length), -1)*outer_length 155 length = outer_length - thick_face 156 pars = dict( 157 radius=radius, 158 x_core=x_core, 159 thick_rim=thick_rim, 160 thick_face=thick_face, 161 length=length 162 ) 163 return pars 152 164 153 #qx, qy = 0.4 * cos(pi/2.0), 0.5 * sin(0) 165 166 q = 0.1 167 # april 6 2017, rkh added a 2d unit test, NOT READY YET pull #890 branch assume correct! 168 qx = q*cos(pi/6.0) 169 qy = q*sin(pi/6.0) 154 170 155 171 tests = [ … … 160 176 'sld_core':4.0, 'sld_face':7.0, 'sld_rim':1.0, 'sld_solvent':6.0, 'background':0.0}, 161 177 0.015, 286.540286], 162 ] 178 # [{'theta':80., 'phi':10.}, (qx, qy), 7.88866563001 ], 179 ] 180 181 del qx, qy # not necessary to delete, but cleaner
Note: See TracChangeset
for help on using the changeset viewer.