Open delongchamp opened 3 months ago
The mostly developed approach is as follows:
The creation of the histogram greatly reduces the number of polarization calculations, however this has some drawbacks. Namely, the current approach only works for a single material system (+ vacuum) which is fully ordered (S=1). For systems where materials are mixed at the voxel level, or 0 < S < 1, the histogramming approach won't work, I think.
For a completely general approach, I think we need to do this at the voxel level, and the easiest way to achieve this is to re-use the polarization calculation that CyRSoXS already does
... that's a good point! Could you remind me whether we have an NRSS framework to expose those CyRSoXS p-components?
It does look like we have the hook to return polarization, but I'm not sure it's fleshed out properly. The CUDA code overwrites the polarization arrays for each energy. If we used that method as is, it would only return polarization for the final energy. The polarization is also of size Nz x Ny x Nx x 3, so that's quite a large array to be moving for each energy.
I would propose we modify CyRSoXS to calculate the effective attenuation coefficient at each energy, and return that for further processing. That lets you play with thickness, q-dependence, etc. on the NRSS side
Hrm I agree this is a tough one. We don't want to do the calculation twice. To do the calculation "right" requires building the 1st half of pyRSoXS (virtual STXM).
I agree that doing the effective attenuation at each energy within CyRSoXS would be a good start at a q-independent approximation. The q-dependence could be added in python with a fictive thickness.
I'd propose that this be an optional switch in CyRSoXS,
I agree!
Created issue in CyRSoXS to address this https://github.com/usnistgov/cyrsoxs/issues/14
@pdudenas here is the math I was alluding to. It's somewhat more complicated than simple absorbance because we're integrating it through the sample thickness. You're asking CyRSoXS to calculate mu(energy), and then the below math can be done in python to get the correct q-dependence.
These equations are from Pauw, Brian Richard. "Everything SAXS: small-angle scattering pattern collection and correction." J. Phys.: Condens. Matter, vol. 25, no. 38, 29 Aug. 2013, p. 383201, doi:10.1088/0953-8984/25/38/383201.
I think there are slightly more simplified versions via Taylor series in other references like Stribeck p77. Stribeck, Norbert. X-Ray Scattering of Soft Matter. Springer, link.springer.com/book/10.1007/978-3-540-69856-2.
The NRSS simulation currently doesn't account for attenuation by absorbance, which likely produces an unrealistic dependence of scattering intensity on energy. An approximation of this effect might be helpful to make simulation results more realistic. It is understood that this is no replacement for a true beyond-Born layer-by-layer scattering model, but it could get close enough to satisfy many use cases.
@pdudenas has a mostly-developed approach for this and would be an ideal contributor if available.
TODO:
Decisions that need to be made include: