Skip to content

( "_pd_n") defaults to 1 in sasmodels.__version__ 1.0.12 #746

Description

@TLO218

TLDR

For polydispersity calculations, if only pd_type and pdi are set, the curve is calculated as monodisperse

Expected behaviour

Testing in our group did not show any significant improvement in increasing the number of points or the number of sigmas used in the calculation of polydispersity compared to the defaults provided by the SASView GUI.
I would expect, from the general behaviour of sasview/sasmodels, that there is a default setting for "pd_n" and "pd_nsigma" while "_pd" and "_pd_type" should be mandatory.

bug

if the number of points is not set for the calculation of the $I_{poly}(q)$ it defaults to 1; see mwe below

Suggested fixes

  • give warnings if parameters are not set but use a default
  • use the same defaults as in the gui for the number of points and number of sigmas
  • check that "_pd" and "_pd_type" are used together
# MWE
import numpy as np
from sasmodels.core import load_model
from sasmodels.direct_model import call_kernel
import matplotlib.pyplot as plt

q = np.logspace(-3, -0, 200)

# model = load_model("sphere")
model = load_model("sphere")
calculator = model.make_kernel([q])

pars = {
    "radius_pd": 0.1,
    "radius_pd_type": "lognormal",
    # "radius_pd_n": 40,
    "radius_pd_nsigma": 4,
}
Iq = call_kernel(calculator, pars)
plt.loglog(q, Iq, label="2 pd params")

pars = {
    "radius_pd": 0.1,
    "radius_pd_type": "lognormal",
    "radius_pd_n": 40,
    "radius_pd_nsigma": 4,
}
Iq = call_kernel(calculator, pars)
plt.loglog(q, Iq, label="3 pd params")

plt.tight_layout()
plt.legend()
plt.show()

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions