pairinteraction
A Rydberg Interaction Calculator
wigner.test.cpp
Go to the documentation of this file.
1// SPDX-FileCopyrightText: 2024 Pairinteraction Developers
2// SPDX-License-Identifier: LGPL-3.0-or-later
3
5
6#include <complex>
7#include <doctest/doctest.h>
8#include <limits>
9
10namespace pairinteraction {
11DOCTEST_TEST_CASE("construction of wigner D matrix") {
12 constexpr double PI = 3.141592653589793238462643383279502884;
13 constexpr double numerical_precision = 100 * std::numeric_limits<double>::epsilon();
14
15 auto wigner_real_entry =
16 wigner::wigner_uppercase_d_matrix<double>(0.5, 0.5, -0.5, 4 * PI, PI / 3, 2 * PI);
17 auto wigner_real_entry_reference = -0.5;
18 DOCTEST_CHECK((wigner_real_entry - wigner_real_entry_reference) <= numerical_precision);
19
20 std::string error_msg =
21 "The scalar type must be complex if m_initial*alpha is not a multiple of pi";
22 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 error_msg = "The scalar type must be complex if m_final*gamma is not a multiple of pi";
27 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 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 auto wigner_complex_entry_reference = std::complex<double>(0, 1);
34 DOCTEST_CHECK(std::abs(wigner_complex_entry - wigner_complex_entry_reference) <=
35 numerical_precision);
36}
37} // namespace pairinteraction
DOCTEST_TEST_CASE("create a basis for strontium 88")