Opened 8 years ago

Last modified 8 years ago

#562 new defect

fix handling of q==0 for various models

Reported by: pkienzle Owned by:
Priority: minor Milestone: SasView Next Release +1
Component: SasView Keywords:
Cc: Work Package: SasView Bug Fixing

Description

A number of models do not return a finite value at q = 0.

adsorbed_layer → inf
binary_hard_sphere → nan
broad_peak → inf
correlation_length → inf
fractal → nan
linear_pearls → nan
mass_fractal → nan
polymer_excl_volume → nan
porod → inf
power_law → inf
star_polymer → nan
surface_fractal → nan
two_power_law → inf

The -zero option to compare will cause q=0 to be included in the set of q to be calculated. You may want to add a test against a specific value for q=0, but this is optional; once these models are fixed we can include a check for finite q=0 as part of model_test.

Change History (3)

comment:1 Changed 8 years ago by pkienzle

Some models do go to infinity at q=0 (power law, porod, fractals?); these can include explicit tests for infinity at zero.

Still need special handling in the code to suppress the divide by zero warning:

from numpy import power, errstate

def Iq(q):
    with errstate(divide='ignore'):
        return power(q, -4)

or avoid the divide by zero:

from numpy import empty_like, inf
def Iq(q):
    result = empty_like(q)
    index = q > 0
    result[index] = power(q[index], -4)
    result[~index] = inf


comment:2 Changed 8 years ago by butler

Note that this becomes a problem when smearing with broad resolution function at low Q (i.e. do you have to include I(q=0) or close enough to zero for single precision for example to diverge?

NOTE: the discussion about USANS smearing being more problematic because of its very large q spread is not in fact a particular issue here since one is smearing over qy=0 but qx is definitely well outside of zero hence q=(qx2+qy2)0.5 is not in fact ever zero.

It can however be a problem when simulating (a theory curve) in 2D without a beamstop. SasView may currently allow that so would need to be checked.

comment:3 Changed 8 years ago by pkienzle

  • Milestone changed from SasView 4.0.0 to SasView Next Release +1
Note: See TracTickets for help on using tickets.