source: sasmodels/sasmodels/models/guinier.py @ c9fc873

core_shell_microgelsmagnetic_modelticket-1257-vesicle-productticket_1156ticket_1265_superballticket_822_more_unit_tests
Last change on this file since c9fc873 was c9fc873, checked in by Torin Cooper-Bennun <torin.cooper-bennun@…>, 6 years ago

normalise R_g in guinier docs; use 'SLD centre of mass'

  • Property mode set to 100644
File size: 3.0 KB
RevLine 
[3330bb4]1r"""
2Definition
3----------
4
5This model fits the Guinier function
6
7.. math::
8
[4476951]9    I(q) = \text{scale} \cdot \exp{\left[ \frac{-Q^2 R_g^2 }{3} \right]}
[3330bb4]10            + \text{background}
11
12to the data directly without any need for linearisation (*cf*. the usual
13plot of $\ln I(q)$ vs $q^2$\ ). Note that you may have to restrict the data
14range to include small q only, where the Guinier approximation actually
15applies. See also the guinier_porod model.
16
17For 2D data the scattering intensity is calculated in the same way as 1D,
18where the $q$ vector is defined as
19
[751da81]20.. math:: q = \sqrt{q_x^2 + q_y^2}
[3ba2251]21
22In scattering, the radius of gyration $R_g$ quantifies the objects's
23distribution of SLD (not mass density, as in mechanics) from the objects's
[c9fc873]24SLD centre of mass. It is defined by
[3ba2251]25
[c9fc873]26.. math:: R_g^2 = \frac{\sum_i\rho_i\left(r_i-r_0\right)^2}{\sum_i\rho_i}
[3ba2251]27
[c9fc873]28where $r_0$ denotes the object's SLD centre of mass and $\rho_i$ is the SLD at
29a point $i$.
[3ba2251]30
31Notice that $R_g^2$ may be negative (since SLD can be negative), which happens
32when a form factor $P(Q)$ is increasing with $Q$ rather than decreasing. This
33can occur for core/shell particles, hollow particles, or for composite
34particles with domains of different SLDs in a solvent with an SLD close to the
35average match point. (Alternatively, this might be regarded as there being an
36internal inter-domain "structure factor" within a single particle which gives
37rise to a peak in the scattering).
[4476951]38
39To specify a negative value of $R_g^2$ in SasView, simply give $R_g$ a negative
[3b8a004]40value ($R_g^2$ will be evaluated as $R_g |R_g|$). Note that the physical radius
41of gyration, of the exterior of the particle, will still be large and positive.
42It is only the apparent size from the small $Q$ data that will give a small or
43negative value of $R_g^2$.
[4476951]44
[3330bb4]45References
46----------
47
48A Guinier and G Fournet, *Small-Angle Scattering of X-Rays*,
49John Wiley & Sons, New York (1955)
50"""
51
[2d81cfe]52import numpy as np
[3330bb4]53from numpy import inf
54
55name = "guinier"
56title = ""
57description = """
58 I(q) = scale.exp ( - rg^2 q^2 / 3.0 )
[404ebbd]59
[3330bb4]60    List of default parameters:
61    scale = scale
62    rg = Radius of gyration
63"""
64category = "shape-independent"
65
66#             ["name", "units", default, [lower, upper], "type","description"],
[4476951]67parameters = [["rg", "Ang", 60.0, [-inf, inf], "", "Radius of Gyration"]]
[3330bb4]68
69Iq = """
[05cd67f]70    double exponent = fabs(rg)*rg*q*q/3.0;
[3330bb4]71    double value = exp(-exponent);
72    return value;
73"""
74
[404ebbd]75def random():
[48462b0]76    scale = 10**np.random.uniform(1, 4)
77    # Note: compare.py has Rg cutoff of 1e-30 at q=1 for guinier, so use that
78    # log_10 Ae^(-(q Rg)^2/3) = log_10(A) - (q Rg)^2/ (3 ln 10) > -30
79    #   => log_10(A) > Rg^2/(3 ln 10) - 30
[404ebbd]80    q_max = 1.0
81    rg_max = np.sqrt(90*np.log(10) + 3*np.log(scale))/q_max
82    rg = 10**np.random.uniform(0, np.log10(rg_max))
83    pars = dict(
84        #background=0,
85        scale=scale,
86        rg=rg,
87    )
88    return pars
89
[3330bb4]90# parameters for demo
[3b8a004]91demo = dict(scale=1.0,  background=0.001, rg=60.0 )
[3330bb4]92
93# parameters for unit tests
94tests = [[{'rg' : 31.5}, 0.005, 0.992756]]
Note: See TracBrowser for help on using the repository browser.