💿🐜 Antkeeper source code https://antkeeper.com
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

90 lines
2.5 KiB

  1. /*
  2. * Copyright (C) 2021 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. #ifndef ANTKEEPER_PHYSICS_LIGHT_BLACKBODY_HPP
  20. #define ANTKEEPER_PHYSICS_LIGHT_BLACKBODY_HPP
  21. #include "math/constants.hpp"
  22. #include "physics/constants.hpp"
  23. #include "physics/planck.hpp"
  24. namespace physics {
  25. namespace light {
  26. /**
  27. * Blackbody radiation functions.
  28. */
  29. namespace blackbody {
  30. /**
  31. * Calculates the radiant exitance of a blackbody.
  32. *
  33. * @param t Temperature of the blackbody, in kelvin.
  34. * @return Radiant exitance of the blackbody, in watt per square meter.
  35. *
  36. * @see https://en.wikipedia.org/wiki/Stefan%E2%80%93Boltzmann_law
  37. * @see https://en.wikipedia.org/wiki/Radiant_exitance
  38. */
  39. template <class T>
  40. T radiant_exitance(T t);
  41. /**
  42. * Calculates the radiant flux of a blackbody.
  43. *
  44. * @param t Temperature of the blackbody, in kelvin.
  45. * @param a Surface area of the blackbody, in square meters.
  46. * @return Radiant power of the blackbody, in watts.
  47. *
  48. * @see https://en.wikipedia.org/wiki/Stefan%E2%80%93Boltzmann_law
  49. */
  50. template <class T>
  51. T radiant_flux(T t, T a);
  52. /**
  53. * Calculates the spectral radiance of a blackbody at a given wavelength.
  54. *
  55. * @param t Temperature of the blackbody, in kelvin.
  56. * @param lambda Wavelength of light, in meters.
  57. * @param c Speed of light in medium.
  58. * @return Spectral radiance, in watt per steradian per square meter per meter.
  59. *
  60. * @see physics::planck::wavelength
  61. */
  62. template <class T>
  63. constexpr auto spectral_radiance = planck::wavelength<T>;
  64. template <class T>
  65. T radiant_exitance(T t)
  66. {
  67. const T tt = t * t;
  68. return constants::stefan_boltzmann<T> * (tt * tt);
  69. }
  70. template <class T>
  71. T radiant_flux(T t, T a)
  72. {
  73. return a * radiant_exitance(t);
  74. }
  75. } // namespace blackbody
  76. } // namespace light
  77. } // namespace physics
  78. #endif // ANTKEEPER_PHYSICS_LIGHT_BLACKBODY_HPP