💿🐜 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.

61 lines
1.7 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_PLANCK_HPP
  20. #define ANTKEEPER_PHYSICS_PLANCK_HPP
  21. #include "physics/constants.hpp"
  22. #include <cmath>
  23. namespace physics {
  24. /// Various forms of Planck's law.
  25. namespace planck {
  26. /**
  27. * Wavelength variant of Planck's law.
  28. *
  29. * @param t Temperature of the blackbody, in kelvin.
  30. * @param lambda Wavelength of light, in meters.
  31. * @param c Speed of light in medium.
  32. * @return Spectral radiance, in watt per steradian per square meter per meter.
  33. */
  34. template <class T>
  35. T wavelength(T t, T lambda, T c = constants::speed_of_light<T>);
  36. template <class T>
  37. T wavelength(T t, T lambda, T c)
  38. {
  39. const T hc = constants::planck<T> * c;
  40. const T lambda2 = lambda * lambda;
  41. // First radiation constant (c1L)
  42. const T c1 = T(2) * hc * c;
  43. // Second radiation constant (c2)
  44. const T c2 = hc / constants::boltzmann<T>;
  45. return (c1 / (lambda2 * lambda2 * lambda)) / std::expm1(c2 / (lambda * t));
  46. }
  47. } // namespace planck
  48. } // namespace physics
  49. #endif // ANTKEEPER_PHYSICS_PLANCK_HPP