feat: add functions to calculate δ, β, n, and k components of the ind…#111
Conversation
…ex of refraction as extensions from the `xsf.index_of_refraction(...)` function.
|
n and k are frequently used as looping variables. I'm nervous about making them global symbols in the module. I would be okay with them as properties or methods on a class. Maybe we could create a function I'm also okay with them having longer names. Though in the spirit of python, having k and β return the same thing feel like "there's more than one way to do it". Similarly for n, 1-δ and index_of_refraction.real Note that for scattering I was expecting k to be a wave vector rather than imaginary index of refraction. |
|
I think there are two ways forward.
Both implementations are fairly simple to make; however, I'm not sure what the best option is based on the project's design philosophy. |
|
I think that separate delta() and beta() functions are going to be easiest for students to understand and use. Please drop n() and k() since they will cause problems with shadowed names. |
This pull request adds new utility functions to the
periodictable/xsf.pymodule to enable more granular calculations of the index of refraction for X-ray scattering. These functions allow users to separately compute the δ (delta), β (beta), n (real part), and k (imaginary part) components, improving the flexibility and clarity of the API for scientific usage.Resolves #103
New index of refraction component calculations:
deltafunction to calculate the δ component of the index of refraction for a compound, with support for both energy and wavelength inputs.betafunction to calculate the β component of the index of refraction for a compound, using a standard sign convention for the imaginary part.Convenience functions for real and imaginary parts:
nfunction to compute the real part of the index of refraction (n = 1 - delta).kfunction to compute the imaginary part of the index of refraction (k = beta).TODO:
There are still some things that I have not checked.