22 complex_t normalizedSLD(
const Material& material)
25 throw std::runtime_error(
"Error in normalizedSLD: passed material has wrong type");
32 complex_t checkForUnderflow(complex_t val)
34 return std::norm(val) < 1e-80 ? complex_t(0.0, 1e-40) : val;
45 const size_t N = slices.size();
47 const size_t i_ref = k.z() > 0. ?
N - 1 : 0;
48 const double n_ref = slices[i_ref].material().refractiveIndex(
M_TWOPI / k.mag()).real();
49 const double k_base = k.mag() * (k.z() > 0.0 ? -1 : 1);
51 std::vector<complex_t> result(
N);
53 for (
size_t i = 0; i <
N; ++i) {
54 complex_t
rad = slices[i].scalarReducedPotential(k, n_ref);
56 rad = checkForUnderflow(
rad);
57 result[i] = k_base * std::sqrt(
rad);
64 const size_t N = slices.size();
65 const double k_sign = kz > 0.0 ? -1 : 1;
66 complex_t kz2_base = kz * kz + normalizedSLD(slices[0].material());
68 std::vector<complex_t> result(
N);
71 for (
size_t i = 1; i <
N; ++i) {
72 complex_t kz2 = checkForUnderflow(kz2_base - normalizedSLD(slices[i].material()));
73 result[i] = k_sign * std::sqrt(kz2);
80 const size_t N = slices.size();
81 const double kz = k.z();
82 const double k_sign = kz > 0.0 ? -1 : 1;
83 const double k2 = k.mag2();
84 const double kz2 = kz * kz;
85 const double wl =
M_TWOPI / std::sqrt(k2);
86 const complex_t n2_ref = slices[0].material().refractiveIndex2(wl);
88 std::vector<complex_t> result(
N);
90 for (
size_t i = 1; i <
N; ++i) {
91 const complex_t n2_norm = slices[i].material().refractiveIndex2(wl) - n2_ref;
92 result[i] = k_sign * std::sqrt(checkForUnderflow(k2 * n2_norm + kz2));
Defines M_PI and some more mathematical constants.
Declares functions in namespace ComputateKz.
Defines class SliceStack.
Defines some unit conversion factors and other constants in namespace Units.
A wrapper for underlying material implementation.
MATERIAL_TYPES typeID() const
Returns the type of underlying material implementation.
complex_t materialData() const
Returns delta + i beta.
std::vector< complex_t > computeReducedKz(const SliceStack &slices, R3 k)
Computes kz values from known k vector and slices with the following assumptions:
std::vector< complex_t > computeKzFromSLDs(const SliceStack &slices, double kz)
Computes kz values from kz of the incoming beam known at a distant point in vacuum....
std::vector< complex_t > computeKzFromRefIndices(const SliceStack &slices, R3 k)
Computes kz values from k-vector of the incoming beam known at a distant point in vacuum....
static constexpr double rad
Radian, internal unit for angles.
static constexpr double angstrom