cloudy  trunk
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
TestGaunt.cpp
Go to the documentation of this file.
1 #include "cdstd.h"
2 #include <UnitTest++.h>
3 #include "cddefines.h"
4 #include "physconst.h"
5 #include "atmdat_gaunt.h"
6 
7 namespace {
8 
9  struct GauntFixture
10  {
11  double SanityCheckGaunt(long Z, double loggam2, double logu, double refval, double relerr)
12  {
13  double gam2 = exp10(loggam2);
14  double u = exp10(logu);
15  double ZZ = double(Z);
16  double Te = TE1RYD*pow2(ZZ)/gam2;
17  double anu = pow2(ZZ)*u/gam2;
18  double val = t_gaunt::Inst().gauntff( Z, Te, anu );
19  return fabs(val/refval-1.)/relerr;
20  }
21  };
22 
23  TEST_FIXTURE(GauntFixture,TestGaunt)
24  {
25  // our Gaunt factors are merged relativistic and non-relativistic data
26  // for high gamma^2 we have non-relativistic data, these are compared to Sutherland (1998)
27  // for low gamma^2 we have relativistic data, these are compared to Nozawa+ (1998)
28 
29  // these data were taken from
30  // >>refer HI gff Sutherland R.S., 1998, MNRAS, 300, 321
31  CHECK( SanityCheckGaunt( 1, 4., -4., 2.7008, 0.0004 ) <= 1. );
32  CHECK( SanityCheckGaunt( 1, 4., 4., 1.1040, 0.0004 ) <= 1. );
33  CHECK( SanityCheckGaunt( 30, 4., 0., 1.0237, 0.0004 ) <= 1. );
34  CHECK( SanityCheckGaunt( 12, 3., -3., 2.2126, 0.0004 ) <= 1. );
35  CHECK( SanityCheckGaunt( 17, 1., -1., 1.5088, 0.0004 ) <= 1. );
36  // these data were taken from
37  // >>refer gff Nozawa S., Itoh N., Kohyama Y., 1998, ApJ, 507, 530
38  CHECK( SanityCheckGaunt( 1, -4., -4., 6.120, 0.005 ) <= 1. );
39  CHECK( SanityCheckGaunt( 2, -4., -4., 8.934, 0.005 ) <= 1. );
40  CHECK( SanityCheckGaunt( 6, -4., -4., 28.92, 0.005 ) <= 1. );
41  CHECK( SanityCheckGaunt( 7, -4., -4., 34.50, 0.005 ) <= 1. );
42  CHECK( SanityCheckGaunt( 8, -4., -4., 40.18, 0.005 ) <= 1. );
43  CHECK( SanityCheckGaunt( 1, -3., -1., 1.852, 0.005 ) <= 1. );
44  CHECK( SanityCheckGaunt( 2, -3., -1., 1.921, 0.005 ) <= 1. );
45  CHECK( SanityCheckGaunt( 6, -3., -1., 3.399, 0.005 ) <= 1. );
46  CHECK( SanityCheckGaunt( 7, -3., -1., 4.050, 0.005 ) <= 1. );
47  CHECK( SanityCheckGaunt( 8, -3., -1., 4.772, 0.005 ) <= 1. );
48  CHECK( SanityCheckGaunt( 6, -2.5, 2., 107.7, 0.005 ) <= 1. );
49  CHECK( SanityCheckGaunt( 7, -2.5, 2., 199.0, 0.005 ) <= 1. );
50  CHECK( SanityCheckGaunt( 8, -2.5, 2., 330.8, 0.005 ) <= 1. );
51  CHECK( SanityCheckGaunt( 1, 0., 3., 0.2001, 0.005 ) <= 1. );
52  CHECK( SanityCheckGaunt( 2, 0., 3., 0.2041, 0.005 ) <= 1. );
53  CHECK( SanityCheckGaunt( 6, 0., 3., 0.3340, 0.005 ) <= 1. );
54  CHECK( SanityCheckGaunt( 7, 0., 3., 0.4358, 0.005 ) <= 1. );
55  CHECK( SanityCheckGaunt( 8, 0., 3., 0.5909, 0.005 ) <= 1. );
56  CHECK( SanityCheckGaunt( 10, -3., 2., 3925., 0.005 ) <= 1. );
57  CHECK( SanityCheckGaunt( 12, -3., 2., 6118., 0.005 ) <= 1. );
58  CHECK( SanityCheckGaunt( 14, -3., 2., 8653., 0.005 ) <= 1. );
59  CHECK( SanityCheckGaunt( 16, -3., 2., 11470., 0.005 ) <= 1. );
60  CHECK( SanityCheckGaunt( 26, -3., 2., 28710., 0.005 ) <= 1. );
61  CHECK( SanityCheckGaunt( 10, 1., 3., 0.5375, 0.005 ) <= 1. );
62  CHECK( SanityCheckGaunt( 12, 1., 3., 0.5603, 0.005 ) <= 1. );
63  CHECK( SanityCheckGaunt( 14, 1., 3., 0.5962, 0.005 ) <= 1. );
64  CHECK( SanityCheckGaunt( 16, 1., 3., 0.6497, 0.005 ) <= 1. );
65  CHECK( SanityCheckGaunt( 26, 1., 3., 1.370, 0.005 ) <= 1. );
66  }
67 }
double exp10(double x)
Definition: cddefines.h:1383
static t_gaunt & Inst()
Definition: cddefines.h:209
double gauntff(long Z, double Te, double anu)
T pow2(T a)
Definition: cddefines.h:985
STATIC void SanityCheckGaunt(long Z, double loggam2, double logu, double refval, double relerr)