Line data Source code
1 : // SPDX-FileCopyrightText: 2024 PairInteraction Developers 2 : // SPDX-License-Identifier: LGPL-3.0-or-later 3 : 4 : #include "pairinteraction/utils/spherical.hpp" 5 : 6 : #include <doctest/doctest.h> 7 : 8 : namespace pairinteraction { 9 3 : DOCTEST_TEST_CASE("convert cartesian to spherical basis") { 10 3 : DOCTEST_SUBCASE("kappa == 0") { 11 : // The monopole is a scalar, the transformation is trivial 12 1 : const auto &real_mat = spherical::get_transformator<double>(0); 13 1 : const auto &complex_mat = spherical::get_transformator<std::complex<double>>(0); 14 : 15 1 : DOCTEST_CHECK(real_mat.rows() == 1); 16 1 : DOCTEST_CHECK(real_mat.cols() == 1); 17 1 : DOCTEST_CHECK(real_mat(0, 0) == 1); 18 1 : DOCTEST_CHECK(complex_mat.rows() == 1); 19 1 : DOCTEST_CHECK(complex_mat.cols() == 1); 20 1 : DOCTEST_CHECK(complex_mat(0, 0) == std::complex<double>(1, 0)); 21 3 : } 22 : 23 3 : DOCTEST_SUBCASE("kappa == 1") { 24 : auto identity = spherical::CARTESIAN_TO_SPHERICAL_KAPPA1 * 25 1 : spherical::CARTESIAN_TO_SPHERICAL_KAPPA1.adjoint(); 26 : 27 1 : DOCTEST_CHECK(identity.isApprox(Eigen::Matrix3<double>::Identity(), 1e-9)); 28 3 : } 29 : 30 3 : DOCTEST_SUBCASE("kappa == 2") { 31 : auto diagonal = spherical::CARTESIAN_TO_SPHERICAL_KAPPA2 * 32 1 : spherical::CARTESIAN_TO_SPHERICAL_KAPPA2.adjoint(); 33 : 34 1 : DOCTEST_CHECK(diagonal.isDiagonal(1e-9)); 35 3 : } 36 3 : } 37 : } // namespace pairinteraction