Skip to content

Correct for sample absorption in cylindrical powder diffraction#202

Merged
AndrewSazonov merged 23 commits into
developfrom
model-sample-absorption
Jun 15, 2026
Merged

Correct for sample absorption in cylindrical powder diffraction#202
AndrewSazonov merged 23 commits into
developfrom
model-sample-absorption

Conversation

@AndrewSazonov

Copy link
Copy Markdown
Member

Powder samples in a cylindrical (Debye–Scherrer) holder absorb the beam by an amount that varies with scattering angle, slightly distorting the measured peak intensities. EasyDiffraction can now model this: switch it on with experiment.absorption.type = 'cylinder-hewat' and set the sample's mu_r (absorption coefficient × radius).

The correction is applied consistently for both the CrysPy and CrysFML calculation engines and reproduces FullProf's cylindrical correction to four decimal places, removing an intensity mismatch of several percent for absorbing samples — demonstrated on the LaB₆ reference at μR = 0.7, where enabling the correction brings the calculated pattern into agreement with FullProf. Values beyond the validated range are still calculated but now raise a clear warning instead of failing silently.

Time-of-flight and flat-plate geometries are designed for but not yet enabled.

@AndrewSazonov AndrewSazonov added the [scope] enhancement Adds/improves features (major.MINOR.patch) label Jun 12, 2026
@codecov

codecov Bot commented Jun 12, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 93.63057% with 10 lines in your changes missing coverage. Please review.
✅ Project coverage is 90.46%. Comparing base (bfa1f08) to head (0f50238).

Files with missing lines Patch % Lines
...easydiffraction/datablocks/experiment/item/base.py 86.36% 2 Missing and 1 partial ⚠️
...asydiffraction/datablocks/experiment/item/enums.py 75.00% 2 Missing and 1 partial ⚠️
src/easydiffraction/io/cif/iucr_writer.py 50.00% 1 Missing and 1 partial ⚠️
...atablocks/experiment/categories/absorption/base.py 96.15% 1 Missing ⚠️
...diffraction/datablocks/experiment/item/bragg_pd.py 87.50% 0 Missing and 1 partial ⚠️
Additional details and impacted files

Impacted file tree graph

@@             Coverage Diff             @@
##           develop     #202      +/-   ##
===========================================
+ Coverage    90.30%   90.46%   +0.16%     
===========================================
  Files          274      280       +6     
  Lines        23380    23535     +155     
  Branches      2727     2742      +15     
===========================================
+ Hits         21113    21291     +178     
+ Misses        1693     1664      -29     
- Partials       574      580       +6     
Flag Coverage Δ
unittests 90.46% <93.63%> (+0.16%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
...easydiffraction/analysis/calculators/absorption.py 100.00% <100.00%> (ø)
...rc/easydiffraction/analysis/calculators/crysfml.py 49.00% <100.00%> (+8.59%) ⬆️
src/easydiffraction/analysis/calculators/cryspy.py 49.65% <100.00%> (+4.37%) ⬆️
...locks/experiment/categories/absorption/__init__.py 100.00% <100.00%> (ø)
...experiment/categories/absorption/cylinder_hewat.py 100.00% <100.00%> (ø)
...blocks/experiment/categories/absorption/factory.py 100.00% <100.00%> (ø)
...atablocks/experiment/categories/absorption/none.py 100.00% <100.00%> (ø)
...atablocks/experiment/categories/absorption/base.py 96.15% <96.15%> (ø)
...diffraction/datablocks/experiment/item/bragg_pd.py 94.56% <87.50%> (-0.68%) ⬇️
src/easydiffraction/io/cif/iucr_writer.py 96.23% <50.00%> (-0.29%) ⬇️
... and 2 more
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@AndrewSazonov AndrewSazonov merged commit 6ed1c61 into develop Jun 15, 2026
34 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

[scope] enhancement Adds/improves features (major.MINOR.patch)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant