Changeset 41c7e68 in sasmodels


Ignore:
Timestamp:
Mar 11, 2016 1:58:18 PM (7 years ago)
Author:
smk78
Branches:
master, core_shell_microgels, costrafo411, magnetic_model, release_v0.94, release_v0.95, ticket-1257-vesicle-product, ticket_1156, ticket_1265_superball, ticket_822_more_unit_tests
Children:
4b0e1f3
Parents:
1369fe6
Message:

Now compiles

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sasmodels/models/adsorbed_layer.py

    r1369fe6 r41c7e68  
    77This model describes the scattering from a layer of surfactant or polymer adsorbed on spherical particles under the conditions that (i) the particles (cores) are contrast-matched to the dispersion medium, (ii) *S(Q)* ~ 1 (ie, the particle volume fraction is dilute), (iii) the particle radius is >> layer thickness (ie, the interface is locally flat), and (iv) scattering from excess unadsorbed adsorbate in the bulk medium is absent or has been corrected for. 
    88 
    9 Unlike many other core-shell models, this model does not assume any form for the density distribution of the adsorbed species normal to the interface (cf, a core-shell model normally assumes the density distribution to be a homogeneous step-function). For comparison, if the thickness of a (traditional core-shell like) step function distribution is *t*, the second moment about the mean of the density distribution (ie, the distance of the centre-of-mass of the distribution from the interface), |sigma| :  sqrt((*t* :sup:`2` )/12). 
     9Unlike many other core-shell models, this model does not assume any form for the density distribution of the adsorbed species normal to the interface (cf, a core-shell model normally assumes the density distribution to be a homogeneous step-function). For comparison, if the thickness of a (traditional core-shell like) step function distribution is *t*, the second moment about the mean of the density distribution (ie, the distance of the centre-of-mass of the distribution from the interface), |sigma| =  sqrt((*t* :sup:`2` )/12). 
    1010 
    1111Definition 
     
    1414.. math:: 
    1515 
    16      I(q) : \text{scale} \cdot(\rho_\text{poly}-\rho_\text{solvent})^2    \left[\frac{6\pi\phi_\text{core}}{Q^2}\frac{\Gamma^2}{\delta_\text{poly}^2R_\text{core}} \exp(-Q^2\sigma^2)\right] + \text{background} 
     16     I(q) = \text{scale} \cdot(\rho_\text{poly}-\rho_\text{solvent})^2    \left[\frac{6\pi\phi_\text{core}}{Q^2}\frac{\Gamma^2}{\delta_\text{poly}^2R_\text{core}} \exp(-Q^2\sigma^2)\right] + \text{background} 
    1717 
    1818where *scale* is a scale factor, |rho|\ :sub:`poly` is the sld of the polymer (or surfactant) layer, |rho|\ :sub:`solv` is the sld of the solvent/medium and cores, |phi|\ :sub:`core` is the volume fraction of the core paraticles, |delta|\ :sub:`poly` is the bulk density of the polymer, |biggamma| is the adsorbed amount, and |sigma| is the second moment of the thickness distribution. 
     
    3131""" 
    3232 
    33 from numpy import inf, sqrt 
     33from numpy import inf, sqrt, pi, exp 
    3434 
    35 name :  "adsorbed_layer" 
    36 title :  "Scattering from an adsorbed layer on particles" 
     35name =  "adsorbed_layer" 
     36title =  "Scattering from an adsorbed layer on particles" 
    3737 
    38 description :  """ 
     38description =  """ 
    3939    Evaluates the scattering from particles 
    4040    with an adsorbed layer of surfactant or 
     
    4242    density distribution. 
    4343    """ 
    44 category :  "shape:sphere" 
     44category =  "shape:sphere" 
    4545 
    4646#             ["name", "units", default, [lower, upper], "type", "description"], 
    47 parameters :  [["second_moment", "Ang", 23.0, [0.0, inf], "", "Second moment"], 
     47parameters =  [["second_moment", "Ang", 23.0, [0.0, inf], "", "Second moment"], 
    4848              ["adsorbed_amount", "mg/m2", 1.9, [0.0, inf], "", "Adsorbed amount"], 
    4949              ["density_poly", "g/cm3", 0.7, [0.0, inf], "", "Polymer density"], 
     
    5454 
    5555# NB: Scale and Background are implicit parameters on every model 
    56 def Iq(q, power): 
    57     # pylint: disable: missing-docstring 
    58     deltarhosqrd :  (polymer_sld - solvent_sld) * (polymer_sld - solvent_sld) 
    59     numerator :  6.0 * numpy.pi * vol_frac * (adsorbed_amount * adsorbed_amount) 
    60     denominator :  (q * q) * (density_poly * density_poly) * radius 
    61     eterm :  numpy.exp(-1.0 * (q * q) * (second_moment * second_moment)) 
    62     inten :  deltarhosqrd * ((numerator / denominator) * eterm) 
    63     return inten 
    64 Iq.vectorized :  True  # Iq accepts an array of q values 
     56def Iq(q, second_moment, adsorbed_amount, density_poly, radius,  
     57        vol_frac, polymer_sld, solvent_sld): 
     58    # pylint: disable = missing-docstring 
     59    deltarhosqrd =  (polymer_sld - solvent_sld) * (polymer_sld - solvent_sld) 
     60    numerator =  6.0 * pi * vol_frac * (adsorbed_amount * adsorbed_amount) 
     61    denominator =  (q * q) * (density_poly * density_poly) * radius 
     62    eterm =  exp(-1.0 * (q * q) * (second_moment * second_moment)) 
     63    inten =  deltarhosqrd * ((numerator / denominator) * eterm) 
     64    #scale by 10^10 for units conversion to cm^-1 
     65    return inten * 1.0e+10 
     66Iq.vectorized =  True  # Iq accepts an array of q values 
    6567 
    6668def Iqxy(qx, qy, *args): 
    67     # pylint: disable: missing-docstring 
     69    # pylint: disable = missing-docstring 
    6870    return Iq(sqrt(qx ** 2 + qy ** 2), *args) 
    69 Iqxy.vectorized :  True # Iqxy accepts an array of qx, qy values 
     71Iqxy.vectorized =  True # Iqxy accepts an array of qx, qy values 
    7072 
    71 demo :  dict(scale: 1.0, 
    72             second_moment: 23.0, 
    73             adsorbed_amount: 1.9, 
    74             density_poly: 0.7, 
    75             radius: 500.0, 
    76             vol_frac: 0.14, 
    77             polymer_sld: 1.5e-06, 
    78             solvent_sld: 6.3e-06, 
    79             background: 0.0) 
     73demo =  dict(scale = 1.0, 
     74            second_moment = 23.0, 
     75            adsorbed_amount = 1.9, 
     76            density_poly = 0.7, 
     77            radius = 500.0, 
     78            vol_frac = 0.14, 
     79            polymer_sld = 1.5e-06, 
     80            solvent_sld = 6.3e-06, 
     81            background = 0.0) 
    8082 
    81 oldname :  "Core2ndMomentModel" 
    82 oldpars :  dict(scale: 'scale', 
    83                second_moment: 'second_moment', 
    84                adsorbed_amount: 'ads_amount', 
    85                density_poly: 'density_poly', 
    86                radius: 'radius_core', 
    87                vol_frac: 'volf_cores', 
    88                polymer_sld: 'sld_poly', 
    89                solvent_sld: 'sld_solv', 
    90                background: 'background') 
     83oldname =  "Core2ndMomentModel" 
     84oldpars =  dict(scale = 'scale', 
     85               second_moment = 'second_moment', 
     86               adsorbed_amount = 'ads_amount', 
     87               density_poly = 'density_poly', 
     88               radius = 'radius_core', 
     89               vol_frac = 'volf_cores', 
     90               polymer_sld = 'sld_poly', 
     91               solvent_sld = 'sld_solv', 
     92               background = 'background') 
    9193 
    92 tests :  [ 
     94tests =  [ 
    9395    [{'scale': 1.0, 'second_moment': 23.0, 'adsorbed_amount': 1.9,  
    9496     'density_poly': 0.7, 'radius': 500.0, 'vol_frac': 0.14,  
Note: See TracChangeset for help on using the changeset viewer.