TBTK
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 <math.h>
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 
53  double energy,
54  double mu,
55  double temperature
56 ){
57  double e = UnitHandler::convertEnergyNtB(energy - mu);
58  double t = UnitHandler::convertTemperatureNtB(temperature);
59  if(t != 0.){
60  return 1./(exp(e/(UnitHandler::getK_BB()*t)) + 1.);
61  }
62  else{
63  if(e < 0.)
64  return 1.;
65  else if(e == 0.)
66  return 0.5;
67  else
68  return 0.;
69  }
70 }
71 
73  double energy,
74  double mu,
75  double temperature
76 ){
77  double e = UnitHandler::convertEnergyNtB(energy - mu);
78  double t = UnitHandler::convertTemperatureNtB(temperature);
79 
80  if(t != 0.){
81  return 1./(exp(e/(UnitHandler::getK_BB()*t)) - 1.);
82  }
83  else{
84  TBTKExit(
85  "Functions::boseEinsteinDistribution()",
86  "Bose-Einstein distribution not well behaved at T=0.",
87  "Use Model::setTemperature() to set a non-zero temperature."
88  );
89  }
90 }
91 
92 }; //End of namespace TBTK
93 
94 #endif
Handles conversions between different units.
Precompiler macros.
static double convertEnergyNtB(double energy)
Definition: UnitHandler.h:884
static double getK_BB()
Definition: UnitHandler.h:746
static double convertTemperatureNtB(double temperature)
Definition: UnitHandler.h:872
static double fermiDiracDistribution(double energy, double mu, double temperature)
Definition: Functions.h:52
Definition: ModelFactory.h:35
static double boseEinsteinDistribution(double energy, double mu, double temperature)
Definition: Functions.h:72
Streams for TBTK output.
Definition: Functions.h:34