TBTK
Need a break? Support the development by playing
Polarity Puzzles
Functions.h
Go to the documentation of this file.
1
/* Copyright 2016 Kristofer Björnson
2
*
3
* Licensed under the Apache License, Version 2.0 (the "License");
4
* you may not use this file except in compliance with the License.
5
* You may obtain a copy of the License at
6
*
7
* http://www.apache.org/licenses/LICENSE-2.0
8
*
9
* Unless required by applicable law or agreed to in writing, software
10
* distributed under the License is distributed on an "AS IS" BASIS,
11
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
* See the License for the specific language governing permissions and
13
* limitations under the License.
14
*/
15
23
#ifndef COM_DAFER45_TBTK_FUNCTIONS
24
#define COM_DAFER45_TBTK_FUNCTIONS
25
26
#include "
TBTK/UnitHandler.h
"
27
#include "
TBTK/Streams.h
"
28
#include "
TBTK/TBTKMacros.h
"
29
30
#include <cmath>
31
32
namespace
TBTK{
33
34
class
Functions
{
35
public
:
37
static
double
fermiDiracDistribution
(
38
double
energy,
39
double
mu,
40
double
temperature
41
);
42
44
static
double
boseEinsteinDistribution
(
45
double
energy,
46
double
mu,
47
double
temperature
48
);
49
private
:
50
};
51
52
inline
double
Functions::fermiDiracDistribution
(
53
double
energy,
54
double
mu,
55
double
temperature
56
){
57
double
e = UnitHandler::convertNaturalToBase<Quantity::Energy>(
58
energy - mu
59
);
60
double
t = UnitHandler::convertNaturalToBase<Quantity::Temperature>(
61
temperature
62
);
63
if
(t != 0.){
64
return
1./(
65
exp(
66
e/(
UnitHandler::getConstantInBaseUnits
(
"k_B"
)*t)
67
) + 1.
68
);
69
}
70
else
{
71
if
(e < 0.)
72
return
1.;
73
else
if
(e == 0.)
74
return
0.5;
75
else
76
return
0.;
77
}
78
}
79
80
inline
double
Functions::boseEinsteinDistribution
(
81
double
energy,
82
double
mu,
83
double
temperature
84
){
85
double
e = UnitHandler::convertNaturalToBase<Quantity::Energy>(
86
energy - mu
87
);
88
double
t = UnitHandler::convertNaturalToBase<Quantity::Temperature>(
89
temperature
90
);
91
92
if
(t != 0.){
93
return
1./(
94
exp(
95
e/(
UnitHandler::getConstantInBaseUnits
(
"k_B"
)*t)
96
) - 1.
97
);
98
}
99
else
{
100
TBTKExit(
101
"Functions::boseEinsteinDistribution()"
,
102
"Bose-Einstein distribution not well behaved at T=0."
,
103
"Use Model::setTemperature() to set a non-zero temperature."
104
);
105
}
106
}
107
108
};
//End of namespace TBTK
109
110
#endif
UnitHandler.h
Handles conversions between different units.
TBTK::Functions::boseEinsteinDistribution
static double boseEinsteinDistribution(double energy, double mu, double temperature)
Definition:
Functions.h:80
TBTK::UnitHandler::getConstantInBaseUnits
static double getConstantInBaseUnits(const std::string &name)
Streams.h
Streams for TBTK output.
TBTK::Functions::fermiDiracDistribution
static double fermiDiracDistribution(double energy, double mu, double temperature)
Definition:
Functions.h:52
TBTKMacros.h
Precompiler macros.
TBTK::Functions
Definition:
Functions.h:34
TBTK
Lib
include
Utilities
TBTK
Functions.h
Generated on Sat Jul 27 2024 12:03:36 for TBTK by
1.8.17