# Changeset 4cdc4b1 in sasmodels

Ignore:
Timestamp:
Jul 9, 2018 6:01:08 PM (4 years ago)
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:
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

Unmodified
Removed
• ## sasmodels/models/guinier.py

 r2d81cfe .. math:: I(q) = \text{scale} \cdot \exp{\left[ \frac{-Q^2R_g^2}{3} \right]} I(q) = \text{scale} \cdot \exp{\left[ \frac{-Q^2 R_g^2 }{3} \right]} + \text{background} .. math:: q = \sqrt{q_x^2 + q_y^2} In scattering, the radius of gyration $R_g$ quantifies the objects's distribution of SLD (not mass density, as in mechanics) from the objects's SLD centre of mass. It is defined by .. math:: R_g^2 = \frac{\sum_i\rho_i\left(r_i-r_0\right)^2}{\sum_i\rho_i} where $r_0$ denotes the object's SLD centre of mass and $\rho_i$ is the SLD at a point $i$. Notice that $R_g^2$ may be negative (since SLD can be negative), which happens when a form factor $P(Q)$ is increasing with $Q$ rather than decreasing. This can occur for core/shell particles, hollow particles, or for composite particles with domains of different SLDs in a solvent with an SLD close to the average match point. (Alternatively, this might be regarded as there being an internal inter-domain "structure factor" within a single particle which gives rise to a peak in the scattering). To specify a negative value of $R_g^2$ in SasView, simply give $R_g$ a negative value ($R_g^2$ will be evaluated as $R_g |R_g|$). Note that the physical radius of gyration, of the exterior of the particle, will still be large and positive. It is only the apparent size from the small $Q$ data that will give a small or negative value of $R_g^2$. References #             ["name", "units", default, [lower, upper], "type","description"], parameters = [["rg", "Ang", 60.0, [0, inf], "", "Radius of Gyration"]] parameters = [["rg", "Ang", 60.0, [-inf, inf], "", "Radius of Gyration"]] Iq = """ double exponent = rg*rg*q*q/3.0; double exponent = fabs(rg)*rg*q*q/3.0; double value = exp(-exponent); return value; # parameters for demo demo = dict(scale=1.0, rg=60.0) demo = dict(scale=1.0,  background=0.001, rg=60.0 ) # parameters for unit tests
• ## doc/guide/pd/polydispersity.rst

 r29afc50 P(q) = \text{scale} \langle F^* F \rangle / V + \text{background} where $F$ is the scattering amplitude and $\langle\cdot\rangle$ denotes an average over the size distribution. where $F$ is the scattering amplitude and $\langle\cdot\rangle$ denotes an average over the size distribution $f(x; \bar x, \sigma)$, giving .. math:: P(q) = \frac{\text{scale}}{V} \int_\mathbb{R} f(x; \bar x, \sigma) F^2(q, x)\, dx + \text{background} Each distribution is characterized by a center value $\bar x$ or with larger values of $N_\sigma$ required for heavier tailed distributions. The scattering in general falls rapidly with $qr$ so the usual assumption that $G(r - 3\sigma_r)$ is tiny and therefore $f(r - 3\sigma_r)G(r - 3\sigma_r)$ that $f(r - 3\sigma_r)$ is tiny and therefore $f(r - 3\sigma_r)f(r - 3\sigma_r)$ will not contribute much to the average may not hold when particles are large. This, too, will require increasing $N_\sigma$. Additional distributions are under consideration. .. note:: In 2009 IUPAC decided to introduce the new term 'dispersity' to replace the term 'polydispersity' (see Pure Appl. Chem., (2009), 81(2), 351-353 _ in order to make the terminology describing distributions of properties unambiguous. Throughout the SasView documentation we continue to use the term polydispersity because one of the consequences of the IUPAC change is that orientational polydispersity would not meet their new criteria (which requires dispersity to be dimensionless). Suggested Applications
• ## sasmodels/compare.py

 r65fbf7c -title="note" adds note to the plot title, after the model name -weights shows weights plots for the polydisperse parameters -profile shows the sld profile if the model has a plottable sld profile === output options === dim = base._kernel.dim plot_weights(model_info, get_mesh(model_info, base_pars, dim=dim)) if opts['show_profile']: import pylab base, comp = opts['engines'] base_pars, comp_pars = opts['pars'] have_base = base._kernel.info.profile is not None have_comp = ( comp is not None and comp._kernel.info.profile is not None and base_pars != comp_pars ) if have_base or have_comp: pylab.figure() if have_base: plot_profile(base._kernel.info, **base_pars) if have_comp: plot_profile(comp._kernel.info, label='comp', **comp_pars) pylab.legend() if opts['plot']: import matplotlib.pyplot as plt plt.show() return limits def plot_profile(model_info, label='base', **args): # type: (ModelInfo, List[Tuple[float, np.ndarray, np.ndarray]]) -> None """ Plot the profile returned by the model profile method. *model_info* defines model parameters, etc. *mesh* is a list of tuples containing (*value*, *dispersity*, *weights*) for each parameter, where (*dispersity*, *weights*) pairs are the distributions to be plotted. """ import pylab args = dict((k, v) for k, v in args.items() if "_pd" not in k and ":" not in k and k not in ("background", "scale", "theta", "phi", "psi")) args = args.copy() args.pop('scale', 1.) args.pop('background', 0.) z, rho = model_info.profile(**args) #pylab.interactive(True) pylab.plot(z, rho, '-', label=label) pylab.grid(True) #pylab.show() def run_models(opts, verbose=False): OPTIONS = [ # Plotting 'plot', 'noplot', 'weights', 'plot', 'noplot', 'weights', 'profile', 'linear', 'log', 'q4', 'rel', 'abs', 'count'     : '1', 'show_weights' : False, 'show_profile' : False, 'sphere'    : 0, 'ngauss'    : '0', elif arg == '-default': opts['use_demo'] = False elif arg == '-weights': opts['show_weights'] = True elif arg == '-profile': opts['show_profile'] = True elif arg == '-html':    opts['html'] = True elif arg == '-help':    opts['html'] = True
• ## sasmodels/models/core_shell_sphere.py

 r2d81cfe .. math:: F^2(q) = \frac{3}{V_s}\left[ F(q) = \frac{3}{V_s}\left[ V_c(\rho_c-\rho_s)\frac{\sin(qr_c)-qr_c\cos(qr_c)}{(qr_c)^3} + 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.