Ignore:
Timestamp:
Aug 2, 2017 12:53:56 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:
bd21b12
Parents:
1511c37c
Message:

tuned random model generation for more models

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sasmodels/models/core_shell_bicelle_elliptical.py

    r9802ab3 r8f04da4  
    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; 
     
    4848.. math:: 
    4949 
    50         \begin{align}     
    51     F(Q,\alpha,\psi) = &\bigg[  
     50        \begin{align} 
     51    F(Q,\alpha,\psi) = &\bigg[ 
    5252    (\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} \\ 
    5353    &+(\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} \\ 
    5454    &+(\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} 
    5555    \bigg] 
    56     \end{align}  
     56    \end{align} 
    5757 
    5858where 
     
    6161 
    6262    R'=\frac{R}{\sqrt{2}}\sqrt{(1+X_{core}^{2}) + (1-X_{core}^{2})cos(\psi)} 
    63      
    64      
    65 and $V_t = \pi.(R+t_r)(Xcore.R+t_r)^2.(L+2.t_f)$ is the total volume of the bicelle,  
    66 $V_c = \pi.Xcore.R^2.L$ the volume of the core, $V_{c+f} = \pi.Xcore.R^2.(L+2.t_f)$  
     63 
     64 
     65and $V_t = \pi.(R+t_r)(Xcore.R+t_r)^2.(L+2.t_f)$ is the total volume of the bicelle, 
     66$V_c = \pi.Xcore.R^2.L$ the volume of the core, $V_{c+f} = \pi.Xcore.R^2.(L+2.t_f)$ 
    6767the volume of the core plus the volume of the faces, $R$ is the radius 
    68 of the core, $Xcore$ is the axial ratio of the core, $L$ the length of the core,  
    69 $t_f$ the thickness of the face, $t_r$ the thickness of the rim and $J_1$ the usual  
    70 first order bessel function. The core has radii $R$ and $Xcore.R$ so is circular,  
    71 as for the core_shell_bicelle model, for $Xcore$ =1. Note that you may need to  
    72 limit the range of $Xcore$, especially if using the Monte-Carlo algorithm, as  
     68of the core, $Xcore$ is the axial ratio of the core, $L$ the length of the core, 
     69$t_f$ the thickness of the face, $t_r$ the thickness of the rim and $J_1$ the usual 
     70first order bessel function. The core has radii $R$ and $Xcore.R$ so is circular, 
     71as for the core_shell_bicelle model, for $Xcore$ =1. Note that you may need to 
     72limit the range of $Xcore$, especially if using the Monte-Carlo algorithm, as 
    7373setting radius to $R/Xcore$ and axial ratio to $1/Xcore$ gives an equivalent solution! 
    7474 
     
    7676bicelles is then given by integrating over all possible $\alpha$ and $\psi$. 
    7777 
    78 For oriented bicelles the *theta*, *phi* and *psi* orientation parameters will appear when fitting 2D data,  
     78For oriented bicelles the *theta*, *phi* and *psi* orientation parameters will appear when fitting 2D data, 
    7979see the :ref:`elliptical-cylinder` model for further information. 
    8080 
     
    8282.. figure:: img/elliptical_cylinder_angle_definition.png 
    8383 
    84     Definition of the angles for the oriented core_shell_bicelle_elliptical particles.    
     84    Definition of the angles for the oriented core_shell_bicelle_elliptical particles. 
    8585 
    8686 
     
    105105description = """ 
    106106    core_shell_bicelle_elliptical 
    107     Elliptical cylinder core, optional shell on the two flat faces, and shell of  
    108     uniform thickness on its rim (extending around the end faces).     
     107    Elliptical cylinder core, optional shell on the two flat faces, and shell of 
     108    uniform thickness on its rim (extending around the end faces). 
    109109    Please see full documentation for equations and further details. 
    110110    Involves a double numerical integral around the ellipsoid diameter 
     
    136136          "core_shell_bicelle_elliptical.c"] 
    137137 
    138 demo = dict(scale=1, background=0, 
    139             radius=30.0, 
    140             x_core=3.0, 
    141             thick_rim=8.0, 
    142             thick_face=14.0, 
    143             length=50.0, 
    144             sld_core=4.0, 
    145             sld_face=7.0, 
    146             sld_rim=1.0, 
    147             sld_solvent=6.0, 
    148             theta=90, 
    149             phi=0, 
    150             psi=0) 
     138def random(): 
     139    import numpy as np 
     140    outer_major = 10**np.random.uniform(1, 4.7) 
     141    outer_minor = 10**np.random.uniform(1, 4.7) 
     142    # Use a distribution with a preference for thin shell or thin core, 
     143    # limited by the minimum radius. Avoid core,shell radii < 1 
     144    min_radius = min(outer_major, outer_minor) 
     145    thick_rim = np.random.beta(0.5, 0.5)*(min_radius-2) + 1 
     146    radius_major = outer_major - thick_rim 
     147    radius_minor = outer_minor - thick_rim 
     148    radius = radius_major 
     149    x_core = radius_minor/radius_major 
     150    outer_length = 10**np.random.uniform(1, 4.7) 
     151    # Caps should be a small percentage of the total length, but at least one 
     152    # angstrom long.  Since outer length >= 10, the following will suffice 
     153    thick_face = 10**np.random.uniform(-np.log10(outer_length), -1)*outer_length 
     154    length = outer_length - thick_face 
     155    pars = dict( 
     156        radius=radius, 
     157        x_core=x_core, 
     158        thick_rim=thick_rim, 
     159        thick_face=thick_face, 
     160        length=length 
     161    ) 
     162    return pars 
     163 
    151164 
    152165q = 0.1 
Note: See TracChangeset for help on using the changeset viewer.