Ignore:
Timestamp:
Sep 5, 2017 11:40:09 AM (7 years ago)
Author:
Paul Kienzle <pkienzle@…>
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.
Message:

Merge branch 'master' into ticket-510

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sasmodels/models/core_shell_bicelle_elliptical.py

    ra53bf6b r64eecf7  
    66core-shell scattering length density profile. Thus this is a variation 
    77of 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  
     8Outer shells on the rims and flat ends may be of different thicknesses and 
    99scattering length densities. The form factor is normalized by the total particle volume. 
    1010 
     
    1717.. figure:: img/core_shell_bicelle_parameters.png 
    1818 
    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 
    2121   and core regions in order to estimate appropriate starting parameters. 
    2222 
     
    2727.. math:: 
    2828 
    29     \rho(r) =  
    30       \begin{cases}  
     29    \rho(r) = 
     30      \begin{cases} 
    3131      &\rho_c \text{ for } 0 \lt r \lt R; -L \lt z\lt L \\[1.5ex] 
    3232      &\rho_f \text{ for } 0 \lt r \lt R; -(L+2t) \lt z\lt -L; 
     
    5050 
    5151    \begin{align} 
    52     F(Q,\alpha,\psi) = &\bigg[  
     52    F(Q,\alpha,\psi) = &\bigg[ 
    5353    (\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} \\ 
    5454    &+(\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} \\ 
    5555    &+(\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} 
    5656    \bigg] 
    57     \end{align}  
     57    \end{align} 
    5858 
    5959where 
     
    6262 
    6363    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 
     66and $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)$ 
    6868the 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  
     69of 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 
     71first order bessel function. The core has radii $R$ and $Xcore.R$ so is circular, 
     72as for the core_shell_bicelle model, for $Xcore$ =1. Note that you may need to 
     73limit the range of $Xcore$, especially if using the Monte-Carlo algorithm, as 
    7474setting radius to $R/Xcore$ and axial ratio to $1/Xcore$ gives an equivalent solution! 
    7575 
     
    7777bicelles is then given by integrating over all possible $\alpha$ and $\psi$. 
    7878 
    79 For oriented bicellles the *theta*, *phi* and *psi* orientation parameters only appear when fitting 2D data,  
     79For oriented bicelles the *theta*, *phi* and *psi* orientation parameters will appear when fitting 2D data, 
    8080see the :ref:`elliptical-cylinder` model for further information. 
    8181 
    8282 
    83 .. figure:: img/elliptical_cylinder_angle_definition.jpg 
     83.. figure:: img/elliptical_cylinder_angle_definition.png 
    8484 
    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 
    8787 
    8888 
     
    100100""" 
    101101 
    102 from numpy import inf, sin, cos 
     102from numpy import inf, sin, cos, pi 
    103103 
    104104name = "core_shell_bicelle_elliptical" 
     
    106106description = """ 
    107107    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). 
    110110    Please see full documentation for equations and further details. 
    111111    Involves a double numerical integral around the ellipsoid diameter 
     
    120120    ["radius",         "Ang",       30, [0, inf],    "volume",      "Cylinder core radius"], 
    121121    ["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"], 
    125125    ["sld_core",       "1e-6/Ang^2", 4, [-inf, inf], "sld",         "Cylinder core scattering length density"], 
    126126    ["sld_face",       "1e-6/Ang^2", 7, [-inf, inf], "sld",         "Cylinder face scattering length density"], 
    127127    ["sld_rim",        "1e-6/Ang^2", 1, [-inf, inf], "sld",         "Cylinder rim scattering length density"], 
    128128    ["sld_solvent",    "1e-6/Ang^2", 6, [-inf, inf], "sld",         "Solvent scattering length density"], 
    129     ["theta",          "degrees",   90, [-360, 360], "orientation", "In plane angle"], 
    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"] 
    132132    ] 
    133133 
     
    137137          "core_shell_bicelle_elliptical.c"] 
    138138 
    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) 
     139def 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 
    152164 
    153 #qx, qy = 0.4 * cos(pi/2.0), 0.5 * sin(0) 
     165 
     166q = 0.1 
     167# april 6 2017, rkh added a 2d unit test, NOT READY YET pull #890 branch assume correct! 
     168qx = q*cos(pi/6.0) 
     169qy = q*sin(pi/6.0) 
    154170 
    155171tests = [ 
     
    160176    'sld_core':4.0, 'sld_face':7.0, 'sld_rim':1.0, 'sld_solvent':6.0, 'background':0.0}, 
    161177    0.015, 286.540286], 
    162 ] 
     178#    [{'theta':80., 'phi':10.}, (qx, qy), 7.88866563001 ], 
     179        ] 
     180 
     181del qx, qy  # not necessary to delete, but cleaner 
Note: See TracChangeset for help on using the changeset viewer.