source: sasmodels/sasmodels/models/poly_gauss_coil.py @ bf227cd

core_shell_microgelscostrafo411magnetic_modelrelease_v0.94release_v0.95ticket-1257-vesicle-productticket_1156ticket_1265_superballticket_822_more_unit_tests
Last change on this file since bf227cd was bf227cd, checked in by smk78, 8 years ago

Improved

  • Property mode set to 100644
File size: 3.5 KB
Line 
1#poly_gauss_coil model
2#conversion of Poly_GaussCoil.py
3#converted by Steve King, Mar 2016
4
5
6 
7r"""
8This empirical model describes the scattering from *polydisperse* polymer chains in theta solvents or polymer melts, assuming a Schulz-Zimm type molecular weight distribution.
9
10To describe the scattering from *monodisperse* polymer chains, see the :ref:`mono_gauss_coil <mono-gauss-coil>` model.
11
12Definition
13----------
14
15     *I(q)* = *scale* |cdot| *I* \ :sub:`0` |cdot| *P(q)* + *background*
16         
17where
18
19     *I*\ :sub:`0` = |phi|\ :sub:`poly` |cdot| *V* |cdot| (|rho|\ :sub:`poly` - |rho|\ :sub:`solv`)\ :sup:`2`
20
21     *P(q)* = 2 [(1 + UZ)\ :sup:`-1/U` + Z - 1] / [(1 + U) Z\ :sup:`2`]
22         
23         *Z* = [(*q R*\ :sub:`g`)\ :sup:`2`] / (1 + 2U)
24         
25         *U* = (Mw / Mn) - 1 = (*polydispersity ratio*) - 1
26
27and
28
29         *V* = *M* / (*N*\ :sub:`A` |delta|)
30         
31Here, |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.
32
33The 2D scattering intensity is calculated in the same way as the 1D, but where the *q* vector is redefined as
34
35.. image:: img/2d_q_vector.gif
36
37References
38----------
39
40O Glatter and O Kratky (editors), *Small Angle X-ray Scattering*, Academic Press, (1982)
41Page 404.
42
43J S Higgins, H C Benoit, *Polymers and Neutron Scattering*, Oxford Science Publications, (1996).
44
45S M King, *Small Angle Neutron Scattering* in *Modern Techniques for Polymer Characterisation*, Wiley, (1999).
46
47http://www.ncnr.nist.gov/staff/hammouda/distance_learning/chapter_28.pdf
48"""
49
50from numpy import inf, sqrt, power
51
52name =  "poly_gauss_coil"
53title =  "Scattering from polydisperse polymer coils"
54
55description =  """
56    Evaluates the scattering from
57        polydisperse polymer chains.
58    """
59category =  "shape-independent"
60
61#             ["name", "units", default, [lower, upper], "type", "description"],
62parameters =  [["i_zero", "1/cm", 1.0, [-inf, inf], "", "Intensity at q=0"],
63               ["radius_gyration", "Ang", 50.0, [0.0, inf], "", "Radius of gyration"],
64               ["polydispersity", "None", 2.0, [1.0, inf], "", "Polymer Mw/Mn"]]
65
66# NB: Scale and Background are implicit parameters on every model
67def Iq(q, radius_gyration, polydispersity):
68    # pylint: disable = missing-docstring
69        u = polydispersity - 1.0
70    # TO DO
71        # should trap the case of polydispersity = 1 by switching to a taylor expansion
72        minusoneonu = -1.0 / u
73        z = ((x * radius_gyration) * (x * radius_gyration)) / (1.0 + 2.0 * u)
74        if x == 0:
75           inten = i_zero * 1.0
76        else:
77           inten = i_zero * 2.0 * (power((1.0 + u * z),minusoneonu) + z - 1.0 ) / ((1.0 + u) * (z * z))
78        return inten
79Iq.vectorized =  True  # Iq accepts an array of q values
80
81def Iqxy(qx, qy, *args):
82    # pylint: disable = missing-docstring
83    return Iq(sqrt(qx ** 2 + qy ** 2), *args)
84Iqxy.vectorized =  True # Iqxy accepts an array of qx, qy values
85
86demo =  dict(scale = 1.0,
87            i_zero = 1.0,
88            radius_gyration = 50.0,
89            polydispersity = 2.0,
90            background = 0.0)
91
92oldname =  "Poly_GaussCoil"
93oldpars =  dict(scale = 'scale',
94               radius_gyration = 'rg',
95               polydispersity = 'poly_m',
96               background = 'background')
97
98tests =  [
99    [{'scale': 1.0, 'radius_gyration': 50.0, 'polydispersity': 2.0, 'background': 0.0},
100     [0.0106939, 0.469418], [0.912993, 0.0054163]],
101    ]
Note: See TracBrowser for help on using the repository browser.