Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Energy- and q-dependent attenuation correction (via post-processing) #15

Open
delongchamp opened this issue Aug 31, 2024 · 8 comments
Open
Labels
enhancement New feature or request hackathon_2024 appropriate issues for RSoXS hackathon Sep 3-6, 2024 help wanted Extra attention is needed

Comments

@delongchamp
Copy link
Collaborator

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:

  • Calculation of polarization field for model as layer-by-layer or projection (which would add a "virtual STXM" capability as well), or returning from the pybind after simulation since it is already calculated there.
  • Conversion of beta to extinction coefficient and conversion of that to %T vs. energy & q
  • It is envisioned that this calculation could be an optional part of the morphology class, and it should return an array object that can be cleanly broadcasted onto PyHyperscattering-imported results as a post-simulation correction. It will be important to avoid breaking changes to the morphology class if possible.

Decisions that need to be made include:

  • Whether to handle z-position realistically / according to the structure provided by the model, which would have different layers contributing more or less depending on their z-position. Alternative would be to average the provided morphology, accepting that the model is somewhat abstract.
  • How to handle realistic thickness. Options include accepting the model and its PhysSize to report accurate thickness, and having the user provide a different thickness more representative of the expected attenuation.
@delongchamp delongchamp added enhancement New feature or request help wanted Extra attention is needed hackathon_2024 appropriate issues for RSoXS hackathon Sep 3-6, 2024 labels Aug 31, 2024
@pdudenas
Copy link
Collaborator

pdudenas commented Sep 5, 2024

The mostly developed approach is as follows:

  1. Create 2D histogram of theta and psi across all voxels
  2. For each histogram bin, calculate transmission based on imaginary component of induced polarization
  3. Add up transmission from each orientation, weighted by histogram bin value
  4. The transmission calculation is repeated for each energy
  5. Multiply CyRSoXS scattering pattern by transmission correction at each energy

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

@delongchamp
Copy link
Collaborator Author

... that's a good point! Could you remind me whether we have an NRSS framework to expose those CyRSoXS p-components?

@pdudenas
Copy link
Collaborator

pdudenas commented Sep 5, 2024

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

@delongchamp
Copy link
Collaborator Author

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.

@delongchamp
Copy link
Collaborator Author

I'd propose that this be an optional switch in CyRSoXS,

@pdudenas
Copy link
Collaborator

pdudenas commented Sep 5, 2024

I agree!

@pdudenas
Copy link
Collaborator

pdudenas commented Sep 5, 2024

Created issue in CyRSoXS to address this usnistgov/cyrsoxs#14

@delongchamp
Copy link
Collaborator Author

@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.

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request hackathon_2024 appropriate issues for RSoXS hackathon Sep 3-6, 2024 help wanted Extra attention is needed
Projects
None yet
Development

When branches are created from issues, their pull requests are automatically linked.

2 participants