37#define LEGENDRE_DEGREE 7
43#define COUPLING_DEGREE 3
45class AssocLegendreTester
48 AssocLegendreTester(
long l,
long m,
49 long lprime,
long mprime) : A(l, m), B(lprime, mprime) {}
51 double operator()(
double x)
const
63class SphericalHarmonicTester
66 SphericalHarmonicTester(
int l,
int m,
67 int lprime,
int mprime) : A(l, m), B(lprime, mprime) {}
69 double operator()(
double theta,
double phi)
const
71 return A(theta, phi) * B(theta, phi) * sin(theta);
81inline void fuzzy_check(
double is,
double should, std::string message)
83 const double tol = 1e-7;
85 && std::max(std::abs(is), std::abs(should)) > 1e-4)
87 std::cerr <<
"Failed at: " << message << std::endl;
99 const double pi = 3.1415926535897932384626433832795;
103 std::cout <<
"Test 1: Value of Y_00" << std::endl;
104 fuzzy_check(Y_00(0, 0), 1.0 / sqrt(4.0 * pi),
"Value of Y_00" );
106 std::cout <<
"Test 2: Orthonormality of associated Legendre functions up to degree " << LEGENDRE_DEGREE << std::endl;
107 for (
long l=0; l <= LEGENDRE_DEGREE; ++l)
109 for (
long m=0; m<=l; ++m)
112 for (
long lprime=0; lprime <= LEGENDRE_DEGREE; ++lprime)
117 std::stringstream ss;
118 ss <<
"Testing P(" << l <<
"," << m <<
") "
119 <<
"with P(" << lprime <<
"," << m <<
")" << std::endl;
121 double expected_result = 0.0;
129 fuzzy_check(is_result, expected_result, ss.str());
135 std::cout <<
"Test 3: Orthonormality of Spherical Harmonics up to degree " << SH_DEGREE << std::endl;
136 for (
int l=0; l <= SH_DEGREE; ++l)
138 for (
int m=-l; m<=l; ++m)
140 for (
int lprime=0; lprime <= SH_DEGREE; ++lprime)
142 for (
int mprime=-lprime; mprime <= lprime; ++mprime)
144 std::stringstream ss;
145 ss <<
"Testing Y(" << l <<
"," << m <<
") "
146 <<
"with Y(" << lprime <<
"," << mprime <<
")" << std::endl;
148 double expected_result = 0.0;
149 if ( (l == lprime) && (m == mprime) )
150 expected_result = 1.0;
154 SphericalHarmonicTester(l, m, lprime, mprime),
156 fuzzy_check(is_result, expected_result, ss.str());
164 std::cout <<
"Test 4: Coupling matrices up to degree " << COUPLING_DEGREE <<
" (this might take a while...)" << std::endl;
165 for (
int l=0; l <= COUPLING_DEGREE; ++l)
167 for (
int m=-l; m<=l; ++m)
169 for (
int lprime=0; lprime <= COUPLING_DEGREE; ++lprime)
171 for (
int mprime=-lprime; mprime <= lprime; ++mprime)
189 if (std::abs(l - lprime) > 1)
191 fuzzy_check(result_a_x, 0,
"result_a_x");
192 fuzzy_check(result_a_y, 0,
"result_a_y");
193 fuzzy_check(result_a_z, 0,
"result_a_z");
195 fuzzy_check(result_b_x, 0,
"result_b_x");
196 fuzzy_check(result_b_y, 0,
"result_b_y");
197 fuzzy_check(result_b_z, 0,
"result_b_z");
206 std::cout <<
"*******************************" << std::endl;
207 std::cout <<
"* Test finished successfully! *" << std::endl;
208 std::cout <<
"*******************************" << std::endl;
Associated Legendre polynomial.
Tag for an adaptive integration rule.
x-component of the Gamma coupling integral (cf. Dissertation Rupp)
y-component of the Gamma coupling integral (cf. Dissertation Rupp)
z-component of the Gamma coupling integral (cf. Dissertation Rupp)
x-component of the velocity coupling integral \int Y_{l,m} e_r Y_{l',m'} \d \Omega (cf....
y-component of the velocity coupling integral \int Y_{l,m} e_r Y_{l',m'} \d \Omega (cf....
z-component of the velocity coupling integral \int Y_{l,m} e_r Y_{l',m'} \d \Omega (cf....
Provides the SHE coupling matrices and computes higher-order coupling matrices if required....
Implementation of numerical integration routines.
double integrate2D(double a1, double b1, double a2, double b2, T const &func2integrate, IntRuleTag)
Convenience overload for two-dimensional integration.
double factorial(long n)
Compute the factorial.
double integrate(T const &f, double a, double b, IntMidPointRule)
Integration of a function using the mid point rule.
bool fuzzy_equal(double is, double should, double tol=1e-1)
Performs a fuzzy (up to a tolerance) equal. Returns true if is and should are equal within the tolera...
Implementation of spherical harmonics plus helper functions.
Contains common functions, functors and other classes often needed by the tests.