Antkeeper  0.0.1
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
blackbody.hpp
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2023 Christopher J. Howard
3  *
4  * This file is part of Antkeeper source code.
5  *
6  * Antkeeper source code is free software: you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation, either version 3 of the License, or
9  * (at your option) any later version.
10  *
11  * Antkeeper source code is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with Antkeeper source code. If not, see <http://www.gnu.org/licenses/>.
18  */
19 
20 #ifndef ANTKEEPER_PHYSICS_LIGHT_BLACKBODY_HPP
21 #define ANTKEEPER_PHYSICS_LIGHT_BLACKBODY_HPP
22 
23 #include <engine/math/numbers.hpp>
25 
26 namespace physics {
27 namespace light {
28 
34 namespace blackbody {
35 
42 template <class T>
43 T radiant_exitance(T t);
44 
52 template <class T>
53 T radiant_flux(T t, T a);
54 
63 template <class T>
64 T radiant_intensity(T t, T a, T omega);
65 
75 template <class T>
76 T spectral_flux(T t, T a, T lambda, T c = constants::speed_of_light<T>);
77 
88 template <class T>
89 T spectral_intensity(T t, T a, T lambda, T omega, T c = constants::speed_of_light<T>);
90 
99 template <class T>
100 T spectral_radiance(T t, T lambda, T c = constants::speed_of_light<T>);
101 
102 template <class T>
104 {
105  const T tt = t * t;
106  return constants::stefan_boltzmann<T> * (tt * tt);
107 }
108 
109 template <class T>
110 T radiant_flux(T t, T a)
111 {
112  return a * radiant_exitance(t);
113 }
114 
115 template <class T>
116 T radiant_intensity(T t, T a, T omega)
117 {
118  return radiant_flux(t, a) / omega;
119 }
120 
121 template <class T>
122 T spectral_exitance(T t, T lambda, T c)
123 {
124  const T hc = constants::planck<T> * c;
125  const T lambda2 = lambda * lambda;
126 
127  // First radiation constant (c1)
128  const T c1 = math::two_pi<T> * hc * c;
129 
130  // Second radiation constant (c2)
131  const T c2 = hc / constants::boltzmann<T>;
132 
133  return (c1 / (lambda2 * lambda2 * lambda)) / std::expm1(c2 / (lambda * t));
134 }
135 
136 template <class T>
137 T spectral_flux(T t, T a, T lambda, T c)
138 {
139  return a * spectral_exitance(t, lambda, c);
140 }
141 
142 template <class T>
143 T spectral_intensity(T t, T a, T lambda, T omega, T c)
144 {
145  return spectral_flux(t, a, lambda, c) / omega;
146 }
147 
148 template <class T>
149 T spectral_radiance(T t, T lambda, T c)
150 {
151  const T hc = constants::planck<T> * c;
152  const T lambda2 = lambda * lambda;
153 
154  // First radiation constant (c1L)
155  const T c1l = T{2} * hc * c;
156 
157  // Second radiation constant (c2)
158  const T c2 = hc / constants::boltzmann<T>;
159 
160  return (c1l / (lambda2 * lambda2 * lambda)) / std::expm1(c2 / (lambda * t));
161 }
162 
163 } // namespace blackbody
164 
165 } // namespace light
166 } // namespace physics
167 
168 #endif // ANTKEEPER_PHYSICS_LIGHT_BLACKBODY_HPP
T radiant_exitance(T t)
Calculates the radiant exitance of a blackbody.
Definition: blackbody.hpp:103
T spectral_radiance(T t, T lambda, T c=constants::speed_of_light< T >)
Calculates the spectral radiance of a blackbody for the given wavelength.
Definition: blackbody.hpp:149
T radiant_flux(T t, T a)
Calculates the radiant flux of a blackbody.
Definition: blackbody.hpp:110
T spectral_exitance(T t, T lambda, T c)
Definition: blackbody.hpp:122
T spectral_flux(T t, T a, T lambda, T c=constants::speed_of_light< T >)
Calculates the spectral flux of a blackbody for the given wavelength.
Definition: blackbody.hpp:137
T spectral_intensity(T t, T a, T lambda, T omega, T c=constants::speed_of_light< T >)
Calculates the spectral intensity of a blackbody for the given wavelength.
Definition: blackbody.hpp:143
T radiant_intensity(T t, T a, T omega)
Calculates the radiant intensity of a blackbody.
Definition: blackbody.hpp:116
Physics.
Definition: constants.hpp:23