Changeset a151caa in sasmodels


Ignore:
Timestamp:
Jul 28, 2017 10:49:09 PM (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:
404ebbd
Parents:
0bdddc2
Message:

tuned random model generator for be_polyelectrolyte, barbell, core multishell, core-shell bicelle

Location:
sasmodels/models
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • sasmodels/models/barbell.py

    r9802ab3 ra151caa  
    115115source = ["lib/polevl.c", "lib/sas_J1.c", "lib/gauss76.c", "barbell.c"] 
    116116 
     117def random(): 
     118    import numpy as np 
     119    pars = dict( 
     120        scale=10**np.random.uniform(-4,-1), 
     121        radius_bell=10**np.random.uniform(1.3,3), 
     122        length=10**np.random.uniform(0,3), 
     123    ) 
     124    pars['radius'] = pars['radius_bell']*np.random.uniform(0,1) 
     125    if pars['radius_bell'] < 100: 
     126        pars['length'] *= 10 
     127        pars['scale'] *= 100 
     128    return pars 
     129 
    117130# parameters for demo 
    118131demo = dict(scale=1, background=0, 
  • sasmodels/models/be_polyelectrolyte.py

    r3330bb4 ra151caa  
    1717    r_{0}^2 = \frac{1}{\alpha \sqrt{C_a} \left( b/\sqrt{48\pi L_b}\right)} 
    1818 
    19 where  
     19where 
    2020 
    2121$K$ is the contrast factor for the polymer which is defined differently than in 
     
    2828 
    2929    a = b_p - (v_p/v_s) b_s 
    30      
     30 
    3131where $b_p$ and $b_s$ are sum of the scattering lengths of the atoms 
    3232constituting the monomer of the polymer and the sum of the scattering lengths 
     
    3535 
    3636$L_b$ is the Bjerrum length(|Ang|) - **Note:** This parameter needs to be 
    37 kept constant for a given solvent and temperature!  
     37kept constant for a given solvent and temperature! 
    3838 
    3939$h$ is the virial parameter (|Ang^3|/mol) - **Note:** See [#Borue]_ for the 
     
    6767* **Author:** NIST IGOR/DANSE **Date:** pre 2010 
    6868* **Last Modified by:** Paul Kienzle **Date:** July 24, 2016 
    69 * **Last Reviewed by:** Paul Butler and Richard Heenan **Date:**  
     69* **Last Reviewed by:** Paul Butler and Richard Heenan **Date:** 
    7070  October 07, 2016 
    7171""" 
     
    139139Iq.vectorized = True  # Iq accepts an array of q values 
    140140 
     141def random(): 
     142    import numpy as np 
     143    pars = dict( 
     144        scale=10000, #background=0, 
     145        #polymer_concentration=0.7, 
     146        polymer_concentration=np.random.beta(5, 3), # around 70% 
     147        #salt_concentration=0.0, 
     148        # keep salt concentration extremely low 
     149        # and use explicit molar to match polymer concentration 
     150        salt_concentration=np.random.beta(1, 100)*6.022136e-4, 
     151        #contrast_factor=10.0, 
     152        contrast_fact=np.random.uniform(1, 100), 
     153        #bjerrum_length=7.1, 
     154        bjerrum_length=np.random.uniform(1, 10), 
     155        #virial_param=12.0, 
     156        virial_param=np.random.uniform(-1000, 30), 
     157        #monomer_length=10.0, 
     158        monomer_length=10.0**(4*np.random.beta(1.5, 3)), 
     159        #ionization_degree=0.05, 
     160        ionization_degree=np.random.beta(1.5, 4), 
     161    ) 
     162    return pars 
    141163 
    142164demo = dict(scale=1, background=0.1, 
  • sasmodels/models/core_multi_shell.py

    r5a0b3d7 ra151caa  
    7070        sld_shell: the SLD of the shell# 
    7171        A_shell#: the coefficient in the exponential function 
    72          
    73          
     72 
     73 
    7474    scale: 1.0 if data is on absolute scale 
    7575    volfraction: volume fraction of spheres 
     
    102102 
    103103source = ["lib/sas_3j1x_x.c", "core_multi_shell.c"] 
     104 
     105def random(): 
     106    import numpy as np 
     107    num_shells = np.minimum(np.random.poisson(3)+1, 10) 
     108    total_radius = 10**np.random.uniform(1.7, 4) 
     109    thickness = np.random.exponential(size=num_shells+1) 
     110    thickness *= total_radius/np.sum(thickness) 
     111    volume_fraction = 10**np.random.uniform(-4, -1) 
     112    pars = dict( 
     113        #background=0, 
     114        scale=volume_fraction/total_radius**3*1e10, 
     115        n=num_shells, 
     116        radius=thickness[0], 
     117    ) 
     118    for k, v in enumerate(thickness[1:]): 
     119        pars['thickness%d'%(k+1)] = v 
     120    return pars 
    104121 
    105122def profile(sld_core, radius, sld_solvent, n, sld, thickness): 
  • sasmodels/models/core_shell_bicelle.py

    r9802ab3 ra151caa  
    1717.. figure:: img/core_shell_bicelle_parameters.png 
    1818 
    19    Cross section of cylindrical symmetry model used here. Users will have  
    20    to decide how to distribute "heads" and "tails" between the rim, face  
     19   Cross section of cylindrical symmetry 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; 
     
    4747.. math:: 
    4848 
    49     \begin{align}     
    50     F(Q,\alpha) = &\bigg[  
     49    \begin{align} 
     50    F(Q,\alpha) = &\bigg[ 
    5151    (\rho_c - \rho_f) V_c \frac{2J_1(QRsin \alpha)}{QRsin\alpha}\frac{sin(QLcos\alpha/2)}{Q(L/2)cos\alpha} \\ 
    5252    &+(\rho_f - \rho_r) V_{c+f} \frac{2J_1(QRsin\alpha)}{QRsin\alpha}\frac{sin(Q(L/2+t_f)cos\alpha)}{Q(L/2+t_f)cos\alpha} \\ 
    5353    &+(\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} 
    5454    \bigg] 
    55     \end{align}  
     55    \end{align} 
    5656 
    5757where $V_t$ is the total volume of the bicelle, $V_c$ the volume of the core, 
     
    6363cylinders is then given by integrating over all possible $\theta$ and $\phi$. 
    6464 
    65 For oriented bicelles the *theta*, and *phi* orientation parameters will appear when fitting 2D data,  
     65For oriented bicelles the *theta*, and *phi* orientation parameters will appear when fitting 2D data, 
    6666see the :ref:`cylinder` model for further information. 
    6767Our implementation of the scattering kernel and the 1D scattering intensity 
     
    9696title = "Circular cylinder with a core-shell scattering length density profile.." 
    9797description = """ 
    98     P(q,alpha)= (scale/Vs)*f(q)^(2) + bkg,  where:  
     98    P(q,alpha)= (scale/Vs)*f(q)^(2) + bkg,  where: 
    9999    f(q)= Vt(sld_rim - sld_solvent)* sin[qLt.cos(alpha)/2] 
    100100    /[qLt.cos(alpha)/2]*J1(qRout.sin(alpha)) 
     
    147147          "core_shell_bicelle.c"] 
    148148 
     149def random(): 
     150    import numpy as np 
     151    pars = dict( 
     152        radius=10**np.random.uniform(1.3, 3), 
     153        length=10**np.random.uniform(1.3, 4), 
     154        thick_rim=10**np.random.uniform(0, 1.7), 
     155        thick_face=10**np.random.uniform(0, 1.7), 
     156    ) 
     157    return pars 
     158 
    149159demo = dict(scale=1, background=0, 
    150160            radius=20.0, 
Note: See TracChangeset for help on using the changeset viewer.