Changeset 404ebbd in sasmodels for sasmodels/models/polymer_micelle.py


Ignore:
Timestamp:
Jul 30, 2017 12:56:22 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:
48462b0
Parents:
a151caa
Message:

tuned random model generation for more models

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sasmodels/models/polymer_micelle.py

    r925ad6e r404ebbd  
    1616which then defines a micelle core of $radius\_core$, which is a separate parameter 
    1717even though it could be directly determined. 
    18 The Gaussian random coil tails, of gyration radius $rg$, are imagined uniformly  
     18The Gaussian random coil tails, of gyration radius $rg$, are imagined uniformly 
    1919distributed around the spherical core, centred at a distance $radius\_core + d\_penetration.rg$ 
    2020from the micelle centre, where $d\_penetration$ is of order unity. 
     
    2727.. math:: 
    2828    P(q) = N^2\beta^2_s\Phi(qR)^2+N\beta^2_cP_c(q)+2N^2\beta_s\beta_cS_{sc}s_c(q)+N(N-1)\beta_c^2S_{cc}(q) 
    29      
     29 
    3030    \beta_s = v\_core(sld\_core - sld\_solvent) 
    31      
     31 
    3232    \beta_c = v\_corona(sld\_corona - sld\_solvent) 
    3333 
    34 where $N = n\_aggreg$, and for the spherical core of radius $R$  
     34where $N = n\_aggreg$, and for the spherical core of radius $R$ 
    3535 
    36 .. math::    
     36.. math:: 
    3737   \Phi(qR)= \frac{\sin(qr) - qr\cos(qr)}{(qr)^3} 
    3838 
     
    4949 
    5050.. math:: 
    51     
     51 
    5252   S_{sc}(q)=\Phi(qR)\psi(Z)\frac{sin(q(R+d.R_g))}{q(R+d.R_g)} 
    53     
     53 
    5454   S_{cc}(q)=\psi(Z)^2\left[\frac{sin(q(R+d.R_g))}{q(R+d.R_g)} \right ]^2 
    55     
     55 
    5656   \psi(Z)=\frac{[1-exp^{-Z}]}{Z} 
    5757 
     
    6060 
    6161$P(q)$ above is multiplied by $ndensity$, and a units conversion of 10^{-13}, so $scale$ 
    62 is likely 1.0 if the scattering data is in absolute units. This model has not yet been  
     62is likely 1.0 if the scattering data is in absolute units. This model has not yet been 
    6363independently validated. 
    6464 
     
    7171""" 
    7272 
    73 from numpy import inf 
     73from numpy import inf, pi 
    7474 
    7575name = "polymer_micelle" 
     
    8080to block copolymer micelles. To work well the Gaussian chains must be much 
    8181smaller than the core, which is often not the case.  Please study the 
    82 reference to Pedersen and full documentation carefully.  
     82reference to Pedersen and full documentation carefully. 
    8383    """ 
    8484 
     
    106106source = ["lib/sas_3j1x_x.c", "polymer_micelle.c"] 
    107107 
    108 demo = dict(scale=1, background=0, 
    109             ndensity=8.94, 
    110             v_core=62624.0, 
    111             v_corona=61940.0, 
    112             sld_solvent=6.4, 
    113             sld_core=0.34, 
    114             sld_corona=0.8, 
    115             radius_core=45.0, 
    116             rg=20.0, 
    117             d_penetration=1.0, 
    118             n_aggreg=6.0) 
    119  
     108def random(): 
     109    import numpy as np 
     110    radius_core = 10**np.random.uniform(1, 3) 
     111    rg = radius_core * 10**np.random.uniform(-2, -0.3) 
     112    d_penetration = np.random.randn()*0.05 + 1 
     113    n_aggreg = np.random.randint(3, 30) 
     114    # volume of head groups is the core volume over the number of groups, 
     115    # with a correction for packing fraction of the head groups. 
     116    v_core = 4*pi/3*radius_core**3/n_aggreg * 0.68 
     117    # Rg^2 for gaussian coil is a^2n/6 => a^2 = 6 Rg^2/n 
     118    # a=2r => r = Rg sqrt(3/2n) 
     119    # v = 4/3 pi r^3 n => v = 4/3 pi Rg^3 (3/2n)^(3/2) n = pi Rg^3 sqrt(6/n) 
     120    tail_segments = np.random.randint(6, 30) 
     121    v_corona = pi * rg**3 * np.sqrt(6/tail_segments) 
     122    V = 4*pi/3*(radius_core + rg)**3 
     123    pars = dict( 
     124        background=0, 
     125        scale=1e7/V, 
     126        ndensity=8.94, 
     127        v_core=v_core, 
     128        v_corona=v_corona, 
     129        radius_core=radius_core, 
     130        rg=rg, 
     131        d_penetration=d_penetration, 
     132        n_aggreg=n_aggreg, 
     133    ) 
     134    return pars 
    120135 
    121136tests = [ 
Note: See TracChangeset for help on using the changeset viewer.