Newer
Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
#ifndef MANTID_KERNEL_BOSEEINSTEINDISTRIBUTIONTEST_H_
#define MANTID_KERNEL_BOSEEINSTEINDISTRIBUTIONTEST_H_
#include "MantidKernel/Math/Distributions/BoseEinsteinDistribution.h"
#include "MantidKernel/PhysicalConstants.h"
#include <cxxtest/TestSuite.h>
#include <iostream>
#include <iomanip>
class BoseEinsteinDistributionTest : public CxxTest::TestSuite
{
public:
void test_Standard_Distribution_Gives_Correct_Value_Away_From_Edge()
{
using namespace Mantid::Kernel::Math;
const double energy = 30.0;
const double temperature = 35.0;
TS_ASSERT_DELTA(BoseEinsteinDistribution::n(energy, temperature), 0.000047886213, 1e-12);
}
void test_Standard_Distribution_Throws_When_Energy_Or_Temperature_Is_Zero()
{
using namespace Mantid::Kernel::Math;
const double energy = 0.0;
const double temperature = 35.0;
TS_ASSERT_THROWS(BoseEinsteinDistribution::n(energy, temperature), std::domain_error);
TS_ASSERT_THROWS(BoseEinsteinDistribution::n(temperature, energy), std::domain_error);
}
void test_np1Eps_Is_Returns_Energy_When_Temp_Is_Negative_And_Energy_Positive()
{
using namespace Mantid::Kernel::Math;
const double energy = 200;
const double temperature = -35.0;
const double expected = energy;
TS_ASSERT_DELTA(BoseEinsteinDistribution::np1Eps(energy, temperature), expected, 1e-12);
}
void test_np1Eps_Returns_kbT_When_Answer_When_Exponent_Is_Zero()
{
using namespace Mantid::Kernel::Math;
const double energy = 0.0;
const double temperature = 35.0;
const double expected = Mantid::PhysicalConstants::BoltzmannConstant*temperature;
TS_ASSERT_DELTA(BoseEinsteinDistribution::np1Eps(energy, temperature), expected, 1e-12);
}
void test_np1Eps_Is_Returns_Zero_When_Temp_Is_Negative_And_Energy_Negative()
{
using namespace Mantid::Kernel::Math;
const double energy = -200;
const double temperature = -35.0;
const double expected = 0.0;
TS_ASSERT_DELTA(BoseEinsteinDistribution::np1Eps(energy, temperature), expected, 1e-12);
}
void test_np1Eps_Is_Well_Behaved_When_Exponent_Is_Larger_Than_Point1()
{
using namespace Mantid::Kernel::Math;
const double energy = 20;
const double temperature = 29.0;
const double expected = 20.006690611537;
TS_ASSERT_DELTA(BoseEinsteinDistribution::np1Eps(energy, temperature), expected, 1e-12);
}
void test_np1Eps_Is_Well_Behaved_When_Abs_Exponent_Is_Larger_Than_Point1_But_Large_And_Negative()
{
using namespace Mantid::Kernel::Math;
const double energy = -20;
const double temperature = 35.0;
const double expected = 0.026407635389;
TS_ASSERT_DELTA(BoseEinsteinDistribution::np1Eps(energy, temperature), expected, 1e-12);
}
};
#endif /* MANTID_KERNEL_BOSEEINSTEINDISTRIBUTIONTEST_H_ */