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

Oriented sesans transform #536

Open pkienzle opened 1 year ago

pkienzle commented 1 year ago

Allow modelling of SESANS for oriented samples.

This is an old set of changes that was never submitted for review.

I'm opening this PR as a draft so that SESANS developers can discuss it.

Note: there is a corresponding branch in the sasview repository. https://github.com/SasView/sasview/tree/costrafo411

smk78 commented 1 year ago

I will bring this to the attention of our SESANS team.

I note that the allied SasView branch is >4000 commits behand main...

rmdalgliesh commented 1 year ago

I suspect that this is the code that should have been worked on in the last code camp. The sesanscosine.py code contains a lot of modifications that make a lot more sense for TOF-SESANS. They answer quite a lot of the questions I had regarding how the sesans.py code was working for TOF. I do have some concerns. The call to HankelAccept contains a reference to magfield in order to define the spin-echo length. This doesn't make sense in TOF. If this is required then I would suggest the calculation for SEL should be SEL= SELC*wavelength^2 where SELC is a constant defined by the parameters of the beamline.

My other concern is the need for a reference for the cosine transform. The hankel transform is well established and references but I'm not aware of anything where the cosine transform for anisotropic scattering is specifically discussed.

So... my comment is that I think this work and the work from the code camp need to be merged to remove the bugs that were ironed out but it is probably best if those patches are made and then we merge in these changes.

Rob

lucas-wilkins commented 1 year ago

Note, I've opened the corresponding PR in sasview as a draft.

smk78 commented 1 year ago

@rmdalgliesh commented:

My other concern is the need for a reference for the cosine transform. The hankel transform is well established and references but I'm not aware of anything where the cosine transform for anisotropic scattering is specifically discussed.

@wimbouwman replies by email:

The cosine transform is one of the first SESANS articles (1996) by Theo Rekveldt (https://doi.org/10.1016/0168-583X(96)00213-3). The numerical drawback of the cosine transform is that it is 2D. Only later we found out that it can be written as the Hankeltransform (2008, https://dx.doi.org/10.1107/S0021889808026770), which is only 1D.

butlerpd commented 10 months ago

@caitwolf , @dehoni @rmdalgliesh @gnsmith @wimbouwman - Should this be a priority for 6.0?

wimbouwman commented 10 months ago

Hi Dirk, For your reference, it started even with the cosine transform: Rekveldt, M. T. (1996). Novel SANS instrument using neutron spin echo. Nuclear Instruments and Methods in Physics Research Section B: Beam Interactions with Materials and Atoms, 114(3-4), 366-370.

Only later with Timofei Kruglov we saw that the integral could be made 1D with the Hankel transform.

Wim

From: Dirk Honecker @.> Sent: zaterdag 25 november 2023 16:06 To: SasView/sasmodels @.> Cc: Wim Bouwman @.>; Mention @.> Subject: Re: [SasView/sasmodels] Oriented sesans transform (PR #536)

I suspect that this is the code that should have been worked on in the last code camp. The sesanscosine.py code contains a lot of modifications that make a lot more sense for TOF-SESANS. They answer quite a lot of the questions I had regarding how the sesans.py code was working for TOF. I do have some concerns. The call to HankelAccept contains a reference to magfield in order to define the spin-echo length. This doesn't make sense in TOF. If this is required then I would suggest the calculation for SEL should be SEL= SELC*wavelength^2 where SELC is a constant defined by the parameters of the beamline.

My other concern is the need for a reference for the cosine transform. The hankel transform is well established and references but I'm not aware of anything where the cosine transform for anisotropic scattering is specifically discussed.

So... my comment is that I think this work and the work from the code camp need to be merged to remove the bugs that were ironed out but it is probably best if those patches are made and then we merge in these changes.

Rob

Only for spherically symmetric (i.e. isotropic) density distribution you will have the Fourier–Abel–Hankel. For an oriented system, one has to consider the projection of the scattering length density correlation function along the encoding direction J. Krouglov et al., Appl. Cryst. (2003). 36, 1417.

— Reply to this email directly, view it on GitHubhttps://urldefense.com/v3/__https:/github.com/SasView/sasmodels/pull/536*issuecomment-1826353544__;Iw!!PAKc-5URQlI!4BvOZm5ggtDppH70C-Gr6pgdyUYJ-WCKtMZNcsNeKTgJA_KXLM6JS0V0hmBMfvX4fl52y4IL7zeAx5LdRAAt8Hd_rgJ1QQ$, or unsubscribehttps://urldefense.com/v3/__https:/github.com/notifications/unsubscribe-auth/ACUIQEJ5KTGFEIKZKZJBPILYGICOPAVCNFSM6AAAAAARXTNHMOVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTQMRWGM2TGNJUGQ__;!!PAKc-5URQlI!4BvOZm5ggtDppH70C-Gr6pgdyUYJ-WCKtMZNcsNeKTgJA_KXLM6JS0V0hmBMfvX4fl52y4IL7zeAx5LdRAAt8HcajV2EIg$. You are receiving this because you were mentioned.Message ID: @.**@.>>

wimbouwman commented 10 months ago

Hi Dirk, I am indeed surprised by this polarisation calculation. I didn’t think we originally had a polarisation calculation to avoid instrument specific parameters in SasView.

If anybody would really feel a strong need for it, then it should not be in the cosine transform to avoid code duplication. Wim

From: Dirk Honecker @.> Sent: zaterdag 25 november 2023 16:51 To: SasView/sasmodels @.> Cc: Wim Bouwman @.>; Mention @.> Subject: Re: [SasView/sasmodels] Oriented sesans transform (PR #536)

@dehoni commented on this pull request.


In sasmodels/sesanscosine.pyhttps://urldefense.com/v3/__https:/github.com/SasView/sasmodels/pull/536*discussion_r1405146543__;Iw!!PAKc-5URQlI!7ijUgtX8YouLiMuTclrcWzts8b_GlkltLETyqGifuIHqV8lH1ufhYehSCJ6-P9CyGt01ilyt5YZ583udKVtYQCngJtcuaQ$:

  • alldq = (allq[1]-allq[0])*1e10

+# G[i]=np.sum(integral)

+

One would expect to get corrected data in reduced data (spin-echolength, correlation function G). Separate the conversion to polarisation into separate function to avoid code repetition. I would assume that the data format will develop with time and instrument specific information (wavelength, sample thickness, magnetic field) is retained in the data reduction.

— Reply to this email directly, view it on GitHubhttps://urldefense.com/v3/__https:/github.com/SasView/sasmodels/pull/536*pullrequestreview-1749205098__;Iw!!PAKc-5URQlI!7ijUgtX8YouLiMuTclrcWzts8b_GlkltLETyqGifuIHqV8lH1ufhYehSCJ6-P9CyGt01ilyt5YZ583udKVtYQClasUAUOQ$, or unsubscribehttps://urldefense.com/v3/__https:/github.com/notifications/unsubscribe-auth/ACUIQEKMXWZRFJKTAY3K6RLYGIHWZAVCNFSM6AAAAAARXTNHMOVHI2DSMVQWIX3LMV43YUDVNRWFEZLROVSXG5CSMV3GSZLXHMYTONBZGIYDKMBZHA__;!!PAKc-5URQlI!7ijUgtX8YouLiMuTclrcWzts8b_GlkltLETyqGifuIHqV8lH1ufhYehSCJ6-P9CyGt01ilyt5YZ583udKVtYQCmlrDpJig$. You are receiving this because you were mentioned.Message ID: @.**@.>>