Changeset 4cdc4b1 in sasmodels


Ignore:
Timestamp:
Jul 9, 2018 6:01:08 PM (6 years ago)
Author:
GitHub <noreply@…>
Branches:
master, core_shell_microgels, magnetic_model, ticket-1257-vesicle-product, ticket_1156, ticket_1265_superball, ticket_822_more_unit_tests
Children:
9a99993
Parents:
dc76240 (diff), c9fc873 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
git-author:
Paul Butler <butlerpd@…> (07/09/18 18:01:08)
git-committer:
GitHub <noreply@…> (07/09/18 18:01:08)
Message:

Merge pull request #71 from SasView?/ticket-1112

Ticket 1112 - Guinier model does not allow negative Rg2

Andrew is on extended holiday leave so not likely to review in timely fashion. It has been reviewed fairly extensively in the ticket stage and is only a very minor change to code and docs. Since SasView? 0.97 has already been tagged and will be used for beta release it should be safe to merge this now. It should be good for the full 4.2.0 release.

Files:
4 edited

Legend:

Unmodified
Added
Removed
  • sasmodels/models/guinier.py

    r2d81cfe rc9fc873  
    77.. math:: 
    88 
    9     I(q) = \text{scale} \cdot \exp{\left[ \frac{-Q^2R_g^2}{3} \right]} 
     9    I(q) = \text{scale} \cdot \exp{\left[ \frac{-Q^2 R_g^2 }{3} \right]} 
    1010            + \text{background} 
    1111 
     
    1919 
    2020.. math:: q = \sqrt{q_x^2 + q_y^2} 
     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 
     24SLD centre of mass. It is defined by 
     25 
     26.. math:: R_g^2 = \frac{\sum_i\rho_i\left(r_i-r_0\right)^2}{\sum_i\rho_i} 
     27 
     28where $r_0$ denotes the object's SLD centre of mass and $\rho_i$ is the SLD at 
     29a point $i$. 
     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). 
     38 
     39To specify a negative value of $R_g^2$ in SasView, simply give $R_g$ a negative 
     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$. 
    2144 
    2245References 
     
    4265 
    4366#             ["name", "units", default, [lower, upper], "type","description"], 
    44 parameters = [["rg", "Ang", 60.0, [0, inf], "", "Radius of Gyration"]] 
     67parameters = [["rg", "Ang", 60.0, [-inf, inf], "", "Radius of Gyration"]] 
    4568 
    4669Iq = """ 
    47     double exponent = rg*rg*q*q/3.0; 
     70    double exponent = fabs(rg)*rg*q*q/3.0; 
    4871    double value = exp(-exponent); 
    4972    return value; 
     
    6689 
    6790# parameters for demo 
    68 demo = dict(scale=1.0, rg=60.0) 
     91demo = dict(scale=1.0,  background=0.001, rg=60.0 ) 
    6992 
    7093# parameters for unit tests 
  • doc/guide/pd/polydispersity.rst

    r29afc50 rd712a0f  
    2020  P(q) = \text{scale} \langle F^* F \rangle / V + \text{background} 
    2121 
    22 where $F$ is the scattering amplitude and $\langle\cdot\rangle$ denotes an 
    23 average over the size distribution. 
     22where $F$ is the scattering amplitude and $\langle\cdot\rangle$ denotes an  
     23average over the size distribution $f(x; \bar x, \sigma)$, giving 
     24 
     25.. math:: 
     26 
     27  P(q) = \frac{\text{scale}}{V} \int_\mathbb{R}  
     28  f(x; \bar x, \sigma) F^2(q, x)\, dx + \text{background} 
    2429 
    2530Each distribution is characterized by a center value $\bar x$ or 
     
    4146with larger values of $N_\sigma$ required for heavier tailed distributions. 
    4247The scattering in general falls rapidly with $qr$ so the usual assumption 
    43 that $G(r - 3\sigma_r)$ is tiny and therefore $f(r - 3\sigma_r)G(r - 3\sigma_r)$ 
     48that $f(r - 3\sigma_r)$ is tiny and therefore $f(r - 3\sigma_r)f(r - 3\sigma_r)$ 
    4449will not contribute much to the average may not hold when particles are large. 
    4550This, too, will require increasing $N_\sigma$. 
     
    6368 
    6469Additional distributions are under consideration. 
     70 
     71.. note:: In 2009 IUPAC decided to introduce the new term 'dispersity' to replace  
     72           the term 'polydispersity' (see `Pure Appl. Chem., (2009), 81(2),  
     73           351-353 <http://media.iupac.org/publications/pac/2009/pdf/8102x0351.pdf>`_  
     74           in order to make the terminology describing distributions of properties  
     75           unambiguous. Throughout the SasView documentation we continue to use the  
     76           term polydispersity because one of the consequences of the IUPAC change is  
     77           that orientational polydispersity would not meet their new criteria (which  
     78           requires dispersity to be dimensionless). 
    6579 
    6680Suggested Applications 
  • sasmodels/compare.py

    r65fbf7c r1e7b202a  
    107107    -title="note" adds note to the plot title, after the model name 
    108108    -weights shows weights plots for the polydisperse parameters 
     109    -profile shows the sld profile if the model has a plottable sld profile 
    109110 
    110111    === output options === 
     
    775776            dim = base._kernel.dim 
    776777            plot_weights(model_info, get_mesh(model_info, base_pars, dim=dim)) 
     778        if opts['show_profile']: 
     779            import pylab 
     780            base, comp = opts['engines'] 
     781            base_pars, comp_pars = opts['pars'] 
     782            have_base = base._kernel.info.profile is not None 
     783            have_comp = ( 
     784                comp is not None 
     785                and comp._kernel.info.profile is not None 
     786                and base_pars != comp_pars 
     787            ) 
     788            if have_base or have_comp: 
     789                pylab.figure() 
     790            if have_base: 
     791                plot_profile(base._kernel.info, **base_pars) 
     792            if have_comp: 
     793                plot_profile(comp._kernel.info, label='comp', **comp_pars) 
     794                pylab.legend() 
    777795    if opts['plot']: 
    778796        import matplotlib.pyplot as plt 
    779797        plt.show() 
    780798    return limits 
     799 
     800def plot_profile(model_info, label='base', **args): 
     801    # type: (ModelInfo, List[Tuple[float, np.ndarray, np.ndarray]]) -> None 
     802    """ 
     803    Plot the profile returned by the model profile method. 
     804 
     805    *model_info* defines model parameters, etc. 
     806 
     807    *mesh* is a list of tuples containing (*value*, *dispersity*, *weights*) 
     808    for each parameter, where (*dispersity*, *weights*) pairs are the 
     809    distributions to be plotted. 
     810    """ 
     811    import pylab 
     812 
     813    args = dict((k, v) for k, v in args.items() 
     814                if "_pd" not in k 
     815                   and ":" not in k 
     816                   and k not in ("background", "scale", "theta", "phi", "psi")) 
     817    args = args.copy() 
     818 
     819    args.pop('scale', 1.) 
     820    args.pop('background', 0.) 
     821    z, rho = model_info.profile(**args) 
     822    #pylab.interactive(True) 
     823    pylab.plot(z, rho, '-', label=label) 
     824    pylab.grid(True) 
     825    #pylab.show() 
     826 
     827 
    781828 
    782829def run_models(opts, verbose=False): 
     
    949996OPTIONS = [ 
    950997    # Plotting 
    951     'plot', 'noplot', 'weights', 
     998    'plot', 'noplot', 
     999    'weights', 'profile', 
    9521000    'linear', 'log', 'q4', 
    9531001    'rel', 'abs', 
     
    11031151        'count'     : '1', 
    11041152        'show_weights' : False, 
     1153        'show_profile' : False, 
    11051154        'sphere'    : 0, 
    11061155        'ngauss'    : '0', 
     
    11631212        elif arg == '-default': opts['use_demo'] = False 
    11641213        elif arg == '-weights': opts['show_weights'] = True 
     1214        elif arg == '-profile': opts['show_profile'] = True 
    11651215        elif arg == '-html':    opts['html'] = True 
    11661216        elif arg == '-help':    opts['html'] = True 
  • sasmodels/models/core_shell_sphere.py

    r2d81cfe rdc76240  
    2121.. math:: 
    2222 
    23     F^2(q) = \frac{3}{V_s}\left[ 
     23    F(q) = \frac{3}{V_s}\left[ 
    2424       V_c(\rho_c-\rho_s)\frac{\sin(qr_c)-qr_c\cos(qr_c)}{(qr_c)^3} + 
    2525       V_s(\rho_s-\rho_\text{solv})\frac{\sin(qr_s)-qr_s\cos(qr_s)}{(qr_s)^3} 
Note: See TracChangeset for help on using the changeset viewer.