Changeset 40a87fa in sasmodels for sasmodels/models/poly_gauss_coil.py


Ignore:
Timestamp:
Aug 8, 2016 11:24:11 AM (8 years ago)
Author:
Paul Kienzle <pkienzle@…>
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:
2472141
Parents:
2d65d51
Message:

lint and latex cleanup

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sasmodels/models/poly_gauss_coil.py

    r2c74c11 r40a87fa  
    22#conversion of Poly_GaussCoil.py 
    33#converted by Steve King, Mar 2016 
     4r""" 
     5This empirical model describes the scattering from *polydisperse* polymer 
     6chains in theta solvents or polymer melts, assuming a Schulz-Zimm type 
     7molecular weight distribution. 
    48 
    5  
    6   
    7 r""" 
    8 This empirical model describes the scattering from *polydisperse* polymer chains in theta solvents or polymer melts, assuming a Schulz-Zimm type molecular weight distribution. 
    9  
    10 To describe the scattering from *monodisperse* polymer chains, see the :ref:`mono_gauss_coil <mono-gauss-coil>` model. 
     9To describe the scattering from *monodisperse* polymer chains, see the 
     10:ref:`mono-gauss-coil` model. 
    1111 
    1212Definition 
    1313---------- 
    1414 
    15      *I(q)* = *scale* |cdot| *I* \ :sub:`0` |cdot| *P(q)* + *background* 
     15.. math:: 
     16 
     17     I(q) = \text{scale} \cdot I_0 \cdot P(q) + \text{background} 
    1618 
    1719where 
    1820 
    19      *I*\ :sub:`0` = |phi|\ :sub:`poly` |cdot| *V* |cdot| (|rho|\ :sub:`poly` - |rho|\ :sub:`solv`)\ :sup:`2` 
     21.. math:: 
    2022 
    21      *P(q)* = 2 [(1 + UZ)\ :sup:`-1/U` + Z - 1] / [(1 + U) Z\ :sup:`2`] 
     23     I_0 &= \phi_\text{poly} \cdot V \cdot (\rho_\text{poly}-\rho_\text{solv})^2 
    2224 
    23      *Z* = [(*q R*\ :sub:`g`)\ :sup:`2`] / (1 + 2U) 
     25     P(q) &= 2 [(1 + UZ)^{-1/U} + Z - 1] / [(1 + U) Z^2] 
    2426 
    25      *U* = (Mw / Mn) - 1 = (*polydispersity ratio*) - 1 
     27     Z &= [(q R_g)^2] / (1 + 2U) 
    2628 
    27 and 
     29     U &= (Mw / Mn) - 1 = \text{polydispersity ratio} - 1 
    2830 
    29      *V* = *M* / (*N*\ :sub:`A` |delta|) 
     31     V &= M / (N_A \delta) 
    3032 
    31 Here, |phi|\ :sub:`poly`, is the volume fraction of polymer, *V* is the volume of a polymer coil, *M* is the molecular weight of the polymer, *N*\ :sub:`A` is Avogadro's Number, |delta| is the bulk density of the polymer, |rho|\ :sub:`poly` is the sld of the polymer, |rho|\ :sub:`solv` is the sld of the solvent, and *R*\ :sub:`g` is the radius of gyration of the polymer coil. 
     33Here, $\phi_\text{poly}$, is the volume fraction of polymer, $V$ is the 
     34volume of a polymer coil, $M$ is the molecular weight of the polymer, 
     35$N_A$ is Avogadro's Number, $\delta$ is the bulk density of the polymer, 
     36$\rho_\text{poly}$ is the sld of the polymer, $\rho_\text{solv}$ is the 
     37sld of the solvent, and $R_g$ is the radius of gyration of the polymer coil. 
    3238 
    33 The 2D scattering intensity is calculated in the same way as the 1D, but where the *q* vector is redefined as 
     39The 2D scattering intensity is calculated in the same way as the 1D, 
     40but where the $q$ vector is redefined as 
    3441 
    3542.. math:: 
     
    4047---------- 
    4148 
    42 O Glatter and O Kratky (editors), *Small Angle X-ray Scattering*, Academic Press, (1982) 
    43 Page 404. 
     49O Glatter and O Kratky (editors), *Small Angle X-ray Scattering*, 
     50Academic Press, (1982) Page 404. 
    4451 
    45 J S Higgins, H C Benoit, *Polymers and Neutron Scattering*, Oxford Science Publications, (1996). 
     52J S Higgins, H C Benoit, *Polymers and Neutron Scattering*, 
     53Oxford Science Publications, (1996). 
    4654 
    47 S M King, *Small Angle Neutron Scattering* in *Modern Techniques for Polymer Characterisation*, Wiley, (1999). 
     55S M King, *Small Angle Neutron Scattering* in *Modern Techniques for 
     56Polymer Characterisation*, Wiley, (1999). 
    4857 
    4958http://www.ncnr.nist.gov/staff/hammouda/distance_learning/chapter_28.pdf 
     
    5261from numpy import inf, exp, power 
    5362 
    54 name =  "poly_gauss_coil" 
    55 title =  "Scattering from polydisperse polymer coils" 
     63name = "poly_gauss_coil" 
     64title = "Scattering from polydisperse polymer coils" 
    5665 
    57 description =  """ 
     66description = """ 
    5867    Evaluates the scattering from  
    5968    polydisperse polymer chains. 
    6069    """ 
    61 category =  "shape-independent" 
     70category = "shape-independent" 
    6271 
    63 #             ["name", "units", default, [lower, upper], "type", "description"], 
    64 parameters =  [["i_zero", "1/cm", 70.0, [0.0, inf], "", "Intensity at q=0"], 
    65                ["radius_gyration", "Ang", 75.0, [0.0, inf], "", "Radius of gyration"], 
    66                ["polydispersity", "None", 2.0, [1.0, inf], "", "Polymer Mw/Mn"]] 
     72# pylint: disable=bad-whitespace, line-too-long 
     73#   ["name", "units", default, [lower, upper], "type", "description"], 
     74parameters = [ 
     75    ["i_zero",          "1/cm", 70.0, [0.0, inf], "", "Intensity at q=0"], 
     76    ["radius_gyration",  "Ang", 75.0, [0.0, inf], "", "Radius of gyration"], 
     77    ["polydispersity",  "None",  2.0, [1.0, inf], "", "Polymer Mw/Mn"], 
     78    ] 
     79# pylint: enable=bad-whitespace, line-too-long 
    6780 
    6881# NB: Scale and Background are implicit parameters on every model 
     
    7184    u = polydispersity - 1.0 
    7285    z = (q*radius_gyration)**2 / (1.0 + 2.0*u) 
    73     # need to trap the case of the polydispersity being 1 (ie, monodispersity!) 
     86    # need to trap the case of the polydispersity being 1 (ie, monodisperse!) 
    7487    if polydispersity == 1.0: 
    7588        inten = i_zero * 2.0 * (exp(-z) + z - 1.0) 
     
    8093    inten[index] /= z[index]**2 
    8194    return inten 
    82 Iq.vectorized =  True  # Iq accepts an array of q values 
     95Iq.vectorized = True  # Iq accepts an array of q values 
    8396 
    84 demo =  dict(scale = 1.0, 
    85             i_zero = 70.0, 
    86             radius_gyration = 75.0, 
    87             polydispersity = 2.0, 
    88             background = 0.0) 
     97demo = dict(scale=1.0, 
     98            i_zero=70.0, 
     99            radius_gyration=75.0, 
     100            polydispersity=2.0, 
     101            background=0.0) 
    89102 
    90103# these unit test values taken from SasView 3.1.2 
    91 tests =  [ 
    92     [{'scale': 1.0, 'i_zero': 70.0, 'radius_gyration': 75.0, 'polydispersity': 2.0, 'background': 0.0}, 
     104tests = [ 
     105    [{'scale': 1.0, 'i_zero': 70.0, 'radius_gyration': 75.0, 
     106      'polydispersity': 2.0, 'background': 0.0}, 
    93107     [0.0106939, 0.469418], [57.6405, 0.169016]], 
    94108    ] 
Note: See TracChangeset for help on using the changeset viewer.