Line data Source code
1 : // SPDX-FileCopyrightText: 2024 Pairinteraction Developers 2 : // SPDX-License-Identifier: LGPL-3.0-or-later 3 : 4 : #include "pairinteraction/utils/wigner.hpp" 5 : 6 : #include <complex> 7 : #include <doctest/doctest.h> 8 : #include <limits> 9 : 10 : namespace pairinteraction { 11 1 : DOCTEST_TEST_CASE("construction of wigner D matrix") { 12 1 : constexpr double PI = 3.141592653589793238462643383279502884; 13 1 : constexpr double numerical_precision = 100 * std::numeric_limits<double>::epsilon(); 14 : 15 : auto wigner_real_entry = 16 1 : wigner::wigner_uppercase_d_matrix<double>(0.5, 0.5, -0.5, 4 * PI, PI / 3, 2 * PI); 17 1 : auto wigner_real_entry_reference = -0.5; 18 1 : DOCTEST_CHECK((wigner_real_entry - wigner_real_entry_reference) <= numerical_precision); 19 : 20 : std::string error_msg = 21 1 : "The scalar type must be complex if m_initial*alpha is not a multiple of pi"; 22 1 : DOCTEST_CHECK_THROWS_WITH_AS( 23 : wigner::wigner_uppercase_d_matrix<double>(0.5, 0.5, -0.5, 0.1 * PI, 0, 0); 24 : , error_msg.c_str(), std::invalid_argument); 25 : 26 1 : error_msg = "The scalar type must be complex if m_final*gamma is not a multiple of pi"; 27 1 : DOCTEST_CHECK_THROWS_WITH_AS( 28 : wigner::wigner_uppercase_d_matrix<double>(0.5, 0.5, -0.5, 0, 0, 0.1 * PI); 29 : , error_msg.c_str(), std::invalid_argument); 30 : 31 1 : auto wigner_complex_entry = wigner::wigner_uppercase_d_matrix<std::complex<double>>( 32 : 0.5, 0.5, -0.5, 0.5 * PI, PI, -0.5 * PI); 33 1 : auto wigner_complex_entry_reference = std::complex<double>(0, 1); 34 1 : DOCTEST_CHECK(std::abs(wigner_complex_entry - wigner_complex_entry_reference) <= 35 : numerical_precision); 36 1 : } 37 : } // namespace pairinteraction