19 complex_t checkForUnderflow(complex_t val);
22 std::pair<Eigen::Matrix2cd, Eigen::Matrix2cd>
27 complex_t beta_i = coeff_i.m_lambda(1) - coeff_i.m_lambda(0);
28 complex_t beta_i1 = coeff_i1.m_lambda(1) - coeff_i1.m_lambda(0);
30 auto roughness_matrix = [sigma, &coeff_i, &coeff_i1, beta_i, beta_i1](
double sign) {
31 const complex_t alpha_p = coeff_i1.m_lambda(0) + coeff_i1.m_lambda(1)
32 + sign * (coeff_i.m_lambda(0) + coeff_i.m_lambda(1));
33 auto b_p_vec = beta_i1 * coeff_i1.m_b + sign * beta_i * coeff_i.m_b;
35 auto square = [](
auto& v) {
return v.x() * v.x() + v.y() * v.y() + v.z() * v.z(); };
36 complex_t beta_p = std::sqrt(checkForUnderflow(square(b_p_vec)));
39 const complex_t alpha_pp = -(alpha_p * alpha_p + beta_p * beta_p) * sigma * sigma / 8.;
40 const complex_t beta_pp = -alpha_p * beta_p * sigma * sigma / 4.;
42 Eigen::Matrix2cd QL, QR;
44 const complex_t factor1 = std::sqrt(2. * (1. + b_p_vec.z()));
45 const complex_t factor2 = std::sqrt(2. * (1. - b_p_vec.z()));
46 QL << (b_p_vec.z() + 1.) / factor1, (b_p_vec.z() - 1.) / factor2,
47 (b_p_vec.x() + I * b_p_vec.y()) / factor1, (b_p_vec.x() + I * b_p_vec.y()) / factor2;
48 QR << (b_p_vec.z() + 1.) / factor1, (b_p_vec.x() - I * b_p_vec.y()) / factor1,
49 (b_p_vec.z() - 1.) / factor2, (b_p_vec.x() - I * b_p_vec.y()) / factor2;
51 const Eigen::Matrix2cd exp1 =
52 Eigen::DiagonalMatrix<complex_t, 2>({std::exp(alpha_pp), std::exp(alpha_pp)});
54 if (std::abs(beta_p) > std::numeric_limits<double>::epsilon() * 10.) {
55 Eigen::Matrix2cd exp2 = Eigen::Matrix2cd(
56 Eigen::DiagonalMatrix<complex_t, 2>({std::exp(beta_pp), std::exp(-beta_pp)}));
57 return Eigen::Matrix2cd{exp1 * QL * exp2 * QR};
63 const Eigen::Matrix2cd roughness_sum = roughness_matrix(1.);
64 const Eigen::Matrix2cd roughness_diff = roughness_matrix(-1.);
66 return {roughness_sum, roughness_diff};
69 std::pair<Eigen::Matrix2cd, Eigen::Matrix2cd>
74 Eigen::Matrix2cd roughness_sum{Eigen::Matrix2cd::Identity()};
75 Eigen::Matrix2cd roughness_diff{Eigen::Matrix2cd::Identity()};
77 const auto ret = computeRoughnessMatrices(coeff_i, coeff_i1, sigma);
78 roughness_sum = std::get<0>(ret);
79 roughness_diff = std::get<1>(ret);
82 const auto P = Eigen::Matrix2cd(coeff_i.computeInverseP() * coeff_i1.computeP());
83 const auto mp = 0.5 * (Eigen::Matrix2cd::Identity() + P) * roughness_diff;
84 const auto mm = 0.5 * (Eigen::Matrix2cd::Identity() - P) * roughness_sum;
91 complex_t checkForUnderflow(complex_t val)
93 return std::abs(val.imag()) < 1e-80 && val.real() < 0 ? complex_t(val.real(), 1e-40) : val;
Defines class SpecularMagneticNewNCStrategy.
Specular reflection and transmission coefficients in a layer in case of magnetic interactions between...