[5d4777d] | 1 | r""" |
---|
| 2 | Definition |
---|
| 3 | ---------- |
---|
| 4 | |
---|
| 5 | The output of the 2D scattering intensity function for oriented core-shell |
---|
[755ecc2] | 6 | cylinders is given by (Kline, 2006 [#kline]_). The form factor is normalized |
---|
[e31b19a] | 7 | by the particle volume. Note that in this model the shell envelops the entire |
---|
| 8 | core so that besides a "sleeve" around the core, the shell also provides two |
---|
| 9 | flat end caps of thickness = shell thickness. In other words the length of the |
---|
| 10 | total cyclinder is the length of the core cylinder plus twice the thickness of |
---|
| 11 | the shell. If no end caps are desired one should use the |
---|
| 12 | :ref:`core-shell-bicelle` and set the thickness of the end caps (in this case |
---|
| 13 | the "thick_face") to zero. |
---|
[5d4777d] | 14 | |
---|
| 15 | .. math:: |
---|
| 16 | |
---|
[fcb33e4] | 17 | I(q,\alpha) = \frac{\text{scale}}{V_s} F^2(q,\alpha).sin(\alpha) + \text{background} |
---|
[5d4777d] | 18 | |
---|
| 19 | where |
---|
| 20 | |
---|
| 21 | .. math:: |
---|
| 22 | |
---|
[fcb33e4] | 23 | F(q,\alpha) = &\ (\rho_c - \rho_s) V_c |
---|
[eb69cce] | 24 | \frac{\sin \left( q \tfrac12 L\cos\alpha \right)} |
---|
| 25 | {q \tfrac12 L\cos\alpha} |
---|
| 26 | \frac{2 J_1 \left( qR\sin\alpha \right)} |
---|
| 27 | {qR\sin\alpha} \\ |
---|
[19dcb933] | 28 | &\ + (\rho_s - \rho_\text{solv}) V_s |
---|
[eb69cce] | 29 | \frac{\sin \left( q \left(\tfrac12 L+T\right) \cos\alpha \right)} |
---|
| 30 | {q \left(\tfrac12 L +T \right) \cos\alpha} |
---|
| 31 | \frac{ 2 J_1 \left( q(R+T)\sin\alpha \right)} |
---|
| 32 | {q(R+T)\sin\alpha} |
---|
[5d4777d] | 33 | |
---|
| 34 | and |
---|
| 35 | |
---|
| 36 | .. math:: |
---|
| 37 | |
---|
[19dcb933] | 38 | V_s = \pi (R + T)^2 (L + 2T) |
---|
[5d4777d] | 39 | |
---|
| 40 | and $\alpha$ is the angle between the axis of the cylinder and $\vec q$, |
---|
[e31b19a] | 41 | $V_s$ is the total volume (i.e. including both the core and the outer shell), |
---|
| 42 | $V_c$ is the volume of the core, $L$ is the length of the core, |
---|
[5d4777d] | 43 | $R$ is the radius of the core, $T$ is the thickness of the shell, $\rho_c$ |
---|
| 44 | is the scattering length density of the core, $\rho_s$ is the scattering |
---|
| 45 | length density of the shell, $\rho_\text{solv}$ is the scattering length |
---|
| 46 | density of the solvent, and *background* is the background level. The outer |
---|
| 47 | radius of the shell is given by $R+T$ and the total length of the outer |
---|
| 48 | shell is given by $L+2T$. $J1$ is the first order Bessel function. |
---|
| 49 | |
---|
[19dcb933] | 50 | .. _core-shell-cylinder-geometry: |
---|
| 51 | |
---|
| 52 | .. figure:: img/core_shell_cylinder_geometry.jpg |
---|
[5d4777d] | 53 | |
---|
| 54 | Core shell cylinder schematic. |
---|
| 55 | |
---|
| 56 | To provide easy access to the orientation of the core-shell cylinder, we |
---|
[40a87fa] | 57 | define the axis of the cylinder using two angles $\theta$ and $\phi$. |
---|
[01eece6] | 58 | (see :ref:`cylinder model <cylinder-angle-definition>`) |
---|
[5d4777d] | 59 | |
---|
| 60 | NB: The 2nd virial coefficient of the cylinder is calculated based on |
---|
| 61 | the radius and 2 length values, and used as the effective radius for |
---|
[eb69cce] | 62 | $S(q)$ when $P(q) \cdot S(q)$ is applied. |
---|
[5d4777d] | 63 | |
---|
[eb69cce] | 64 | The $\theta$ and $\phi$ parameters are not used for the 1D output. |
---|
[5d4777d] | 65 | |
---|
[01eece6] | 66 | Reference |
---|
| 67 | --------- |
---|
| 68 | |
---|
[755ecc2] | 69 | .. [#] see, for example, Ian Livsey J. Chem. Soc., Faraday Trans. 2, 1987,83, |
---|
| 70 | 1445-1452 |
---|
| 71 | .. [#kline] S R Kline, *J Appl. Cryst.*, 39 (2006) 895 |
---|
[0507e09] | 72 | .. [#] L. Onsager, *Ann. New York Acad. Sci.*, 51 (1949) 627-659 |
---|
| 73 | |
---|
| 74 | Source |
---|
| 75 | ------ |
---|
| 76 | |
---|
| 77 | `core_shell_cylinder.py <https://github.com/SasView/sasmodels/blob/master/sasmodels/models/core_shell_cylinder.py>`_ |
---|
| 78 | |
---|
| 79 | `core_shell_cylinder.c <https://github.com/SasView/sasmodels/blob/master/sasmodels/models/core_shell_cylinder.c>`_ |
---|
[755ecc2] | 80 | |
---|
| 81 | Authorship and Verification |
---|
| 82 | ---------------------------- |
---|
| 83 | |
---|
| 84 | * **Author:** NIST IGOR/DANSE **Date:** pre 2010 |
---|
| 85 | * **Last Modified by:** Paul Kienzle **Date:** Aug 8, 2016 |
---|
| 86 | * **Last Reviewed by:** Richard Heenan **Date:** March 18, 2016 |
---|
[0507e09] | 87 | * **Source added by :** Steve King **Date:** March 25, 2019 |
---|
[5d4777d] | 88 | """ |
---|
| 89 | |
---|
[2d81cfe] | 90 | import numpy as np |
---|
[0b56f38] | 91 | from numpy import pi, inf, sin, cos |
---|
[5d4777d] | 92 | |
---|
[19dcb933] | 93 | name = "core_shell_cylinder" |
---|
[5d4777d] | 94 | title = "Right circular cylinder with a core-shell scattering length density profile." |
---|
| 95 | description = """ |
---|
| 96 | P(q,alpha)= scale/Vs*f(q)^(2) + background, |
---|
[01eece6] | 97 | where: f(q)= 2(sld_core - solvant_sld) |
---|
[485aee2] | 98 | * Vc*sin[qLcos(alpha/2)] |
---|
| 99 | /[qLcos(alpha/2)]*J1(qRsin(alpha)) |
---|
[01eece6] | 100 | /[qRsin(alpha)]+2(sld_shell-sld_solvent) |
---|
[485aee2] | 101 | *Vs*sin[q(L+T)cos(alpha/2)][[q(L+T) |
---|
| 102 | *cos(alpha/2)]*J1(q(R+T)sin(alpha)) |
---|
| 103 | /q(R+T)sin(alpha)] |
---|
| 104 | |
---|
| 105 | alpha:is the angle between the axis of |
---|
| 106 | the cylinder and the q-vector |
---|
| 107 | Vs: the volume of the outer shell |
---|
| 108 | Vc: the volume of the core |
---|
| 109 | L: the length of the core |
---|
[01eece6] | 110 | sld_shell: the scattering length density of the shell |
---|
| 111 | sld_solvent: the scattering length density of the solvent |
---|
[485aee2] | 112 | background: the background |
---|
| 113 | T: the thickness |
---|
| 114 | R+T: is the outer radius |
---|
| 115 | L+2T: The total length of the outershell |
---|
| 116 | J1: the first order Bessel function |
---|
| 117 | theta: axis_theta of the cylinder |
---|
| 118 | phi: the axis_phi of the cylinder |
---|
[5d4777d] | 119 | """ |
---|
[a5d0d00] | 120 | category = "shape:cylinder" |
---|
[5d4777d] | 121 | |
---|
[485aee2] | 122 | # ["name", "units", default, [lower, upper], "type", "description"], |
---|
[42356c8] | 123 | parameters = [["sld_core", "1e-6/Ang^2", 4, [-inf, inf], "sld", |
---|
[485aee2] | 124 | "Cylinder core scattering length density"], |
---|
[42356c8] | 125 | ["sld_shell", "1e-6/Ang^2", 4, [-inf, inf], "sld", |
---|
[485aee2] | 126 | "Cylinder shell scattering length density"], |
---|
[42356c8] | 127 | ["sld_solvent", "1e-6/Ang^2", 1, [-inf, inf], "sld", |
---|
[485aee2] | 128 | "Solvent scattering length density"], |
---|
| 129 | ["radius", "Ang", 20, [0, inf], "volume", |
---|
| 130 | "Cylinder core radius"], |
---|
| 131 | ["thickness", "Ang", 20, [0, inf], "volume", |
---|
| 132 | "Cylinder shell thickness"], |
---|
| 133 | ["length", "Ang", 400, [0, inf], "volume", |
---|
| 134 | "Cylinder length"], |
---|
[9b79f29] | 135 | ["theta", "degrees", 60, [-360, 360], "orientation", |
---|
| 136 | "cylinder axis to beam angle"], |
---|
[2d81cfe] | 137 | ["phi", "degrees", 60, [-360, 360], "orientation", |
---|
[9b79f29] | 138 | "rotation about beam"], |
---|
[485aee2] | 139 | ] |
---|
| 140 | |
---|
[40a87fa] | 141 | source = ["lib/polevl.c", "lib/sas_J1.c", "lib/gauss76.c", "core_shell_cylinder.c"] |
---|
[71b751d] | 142 | have_Fq = True |
---|
[ee60aa7] | 143 | effective_radius_type = [ |
---|
[99658f6] | 144 | "excluded volume", "equivalent volume sphere", "outer radius", "half outer length", |
---|
| 145 | "half min outer dimension", "half max outer dimension", "half outer diagonal", |
---|
[ee60aa7] | 146 | ] |
---|
[5d4777d] | 147 | |
---|
[8f04da4] | 148 | def random(): |
---|
[b297ba9] | 149 | """Return a random parameter set for the model.""" |
---|
[8f04da4] | 150 | outer_radius = 10**np.random.uniform(1, 4.7) |
---|
| 151 | # Use a distribution with a preference for thin shell or thin core |
---|
| 152 | # Avoid core,shell radii < 1 |
---|
| 153 | radius = np.random.beta(0.5, 0.5)*(outer_radius-2) + 1 |
---|
[9f6823b] | 154 | thickness = outer_radius - radius |
---|
[8f04da4] | 155 | length = np.random.uniform(1, 4.7) |
---|
| 156 | pars = dict( |
---|
| 157 | radius=radius, |
---|
| 158 | thickness=thickness, |
---|
| 159 | length=length, |
---|
| 160 | ) |
---|
| 161 | return pars |
---|
| 162 | |
---|
[485aee2] | 163 | demo = dict(scale=1, background=0, |
---|
[01eece6] | 164 | sld_core=6, sld_shell=8, sld_solvent=1, |
---|
[485aee2] | 165 | radius=45, thickness=25, length=340, |
---|
| 166 | theta=30, phi=15, |
---|
| 167 | radius_pd=.2, radius_pd_n=1, |
---|
| 168 | length_pd=.2, length_pd_n=10, |
---|
| 169 | thickness_pd=.2, thickness_pd_n=10, |
---|
| 170 | theta_pd=15, theta_pd_n=45, |
---|
| 171 | phi_pd=15, phi_pd_n=1) |
---|
[0b56f38] | 172 | q = 0.1 |
---|
| 173 | # april 6 2017, rkh add unit tests, NOT compared with any other calc method, assume correct! |
---|
| 174 | qx = q*cos(pi/6.0) |
---|
| 175 | qy = q*sin(pi/6.0) |
---|
[2d81cfe] | 176 | tests = [ |
---|
| 177 | [{}, 0.075, 10.8552692237], |
---|
| 178 | [{}, (qx, qy), 0.444618752741], |
---|
| 179 | ] |
---|
[0b56f38] | 180 | del qx, qy # not necessary to delete, but cleaner |
---|