SasView / sasmodels

Package for calculation of small angle scattering models using OpenCL.
BSD 3-Clause "New" or "Revised" License
15 stars 27 forks source link

flexible cylinder polydispersity normalization may be wrong (Trac #1110) #286

Open butlerpd opened 5 years ago

butlerpd commented 5 years ago

Originally reported by Peter Schmidt of UMN in September of 2017 as follows:


Hi SASView Coders,

I have been using SASView to fit SAXS patterns for methylcellulose hydrogels. My group has used IgorPro previously to fit SANS results of these materials previously to the "semiflexible cylinder model with polydisperse radius." I noticed I was consistently getting a fit with a higher fibril diameter.

I played around with SASView and the Igor SANS macro by inputting various values into the flexible cylinder model. I have found that when I incorporate polydispersity, I get slightly different shaped scattering patterns. To my knowledge Igor uses a Schulz distribution, but even using the Schulz distribution in SASView, I get a slightly different answer. Without the polydispersity in the radius term the two plots superpose as they likely should.

I was wondering if there is a reason why this might be occurring (based on how the distribution is implemented), if there might be an issue with the code, or if there is another reason why these two aren't generating the same plot when adding in a dispersity term.

Best regards, Peter

Attached is the graph he sent -- note that the length must be 1e4 not 1. Yun Liu has recently looked at the polydispersity code he says because of the beta approximation and believes it is correct "For number average" representation.

However, IGOR also claims to report number averages I believe. Further Peter Schmidt recently told me (at IPRIME meeting end of May 2018) that he did some digging and discovered that IGOR is averaging using the second moment of the distribution (as the documentation suggests and which should be correct for proper scattering normalization, in particular for such things as the Invariant etc) while !SasView uses the first moment.

I have created the IGOR version with the parameters given as a data file and attached as well. If SASFIT has the same model it would be good to check against it as well?

It is not clear that this is simply a nomenclature issue (which is fixed with better documentation) but could be giving somewhat "incorrect" results for very polydisperse systems which would propagate as noted in the IGOR documentation to the invariant calculator as well and perhaps elsewhere?

Migrated from http://trac.sasview.org/ticket/1110

{
    "status": "new",
    "changetime": "2018-06-26T03:00:43",
    "_ts": "2018-06-26 03:00:43.238171+00:00",
    "description": "Originally reported by Peter Schmidt of UMN in September of 2017 as follows:\n\n--------------------------\nHi SASView Coders,\n\nI have been using SASView to fit SAXS patterns for methylcellulose hydrogels. My group has used IgorPro previously to fit SANS results of these materials previously to the \"semiflexible cylinder model with polydisperse radius.\" I noticed I was consistently getting a fit with a higher fibril diameter.\n\nI played around with SASView and the Igor SANS macro by inputting various values into the flexible cylinder model. I have found that when I incorporate polydispersity, I get slightly different shaped scattering patterns. To my knowledge Igor uses a Schulz distribution, but even using the Schulz distribution in SASView, I get a slightly different answer. Without the polydispersity in the radius term the two plots superpose as they likely should.\n\nI was wondering if there is a reason why this might be occurring (based on how the distribution is implemented), if there might be an issue with the code, or if there is another reason why these two aren't generating the same plot when adding in a dispersity term.\n\nBest regards,\nPeter\n-------------------------------\n\nAttached is the graph he sent -- note that the length must be 1e4 not 1.  Yun Liu has recently looked at the polydispersity code he says because of the beta approximation and believes it is correct \"For number average\" representation.\n\nHowever, IGOR also claims to report number averages I believe.  Further Peter Schmidt recently told me (at IPRIME meeting end of May 2018) that he did some digging and discovered that IGOR is averaging using the second moment of the distribution (as the documentation suggests and which should be correct for proper scattering normalization, in particular for such things as the Invariant etc) while !SasView uses the first moment.\n\nI have created the IGOR version with the parameters given as a data file and attached as well.  If SASFIT has the same model it would be good to check against it as well?\n\nIt is not clear that this is simply a nomenclature issue (which is fixed with better documentation) but could be giving somewhat \"incorrect\" results for very polydisperse systems which would propagate as noted in the IGOR documentation to the invariant calculator as well and perhaps elsewhere?",
    "reporter": "butler",
    "cc": "",
    "resolution": "",
    "workpackage": "SasView Bug Fixing",
    "time": "2018-06-17T16:35:49",
    "component": "SasView",
    "summary": "Basis for polydispersity normalization may be wrong",
    "priority": "major",
    "keywords": "",
    "milestone": "SasView 4.3.0",
    "owner": "",
    "type": "defect"
}
butlerpd commented 5 years ago

Trac update at 2018/06/17 16:39:59:

Plot showing diff between IGOR and !SasView? for a PD of 3 on wormlike chain - courtesy of Peter Schmidt

butlerpd commented 5 years ago

Trac update at 2018/06/17 16:43:33:

Data File from IGOR using flexible cylinder model with parameters described in ticket

RichardHeenan commented 5 years ago

Trac update at 2018/06/18 10:49:47: richardh commented:

Could some kind person perhaps compare IGOR& sasview with a simple model such as a polydisperse sphere or cylinder, just to make sure that we are not dealing with an issue specific to the implementation of the rather complex flexible cylinder model (even though I might guess that the sasview code was based on the NIST one).

butlerpd commented 5 years ago

Trac update at 2018/06/21 21:45:03: butler commented:

Interestingly, yes - the shpere with polydisperse R of 0.4 is exactly the same for !SasView and IGOR and so is the cylinder with polydisperse Radius of 0.4 and so is cylinder with polydisperse Length of 0.4. This leaves us with the question of what is going on with the flexible chain model and how to validate.

RichardHeenan commented 5 years ago

Trac update at 2018/06/22 09:15:30: richardh commented:

Suspect a systematic comparison of both codes is required. With very long contour length and long Kuhn length it ought to look like a cylinder. Looking at the plot, my guess would be that IGOR is applying the polydispersity to the wrong variable?? (e.g. to the Kuhn length instead of the radius. A quick look at the sasview code suggests sasview ought to be OK in this regard.)  But since I don't have IGOR myself I cannot test this.

butlerpd commented 5 years ago

Trac update at 2018/06/26 03:00:43:

Indeed --- given however this is for one particular model, and clearly long standing, I think this cannot block a release so moving to 4.3 for now.

pkienzle commented 4 years ago

As reported by Sebastian Lages, the Iq function is returning 1e-4 volume contrast^2 form^2 rather than 1e-4 volume^2 contrast^2 form^2.

In order to get the correct absolute scaling, the form_volume() function is currently returning 1.0 rather than the volume. As a result, the polydispersity distribution will not be the number density distribution as is the case for other models. This may explain the discrepancy with the IGOR results.

(Probably ought to check all our other models for similar issues !)

pkienzle commented 4 years ago

Maybe add an effective radius function as well. You should be able to estimate the occupied volume based on kuhn length and turn that into various approximations for effective radius in structure factor calculations.