cphot
0.1
A C++ tool for computing photometry from spectra.
blackbody.hpp
Go to the documentation of this file.
1
/**
2
* @file blackbody.hpp
3
*
4
* @brief Blackbody radiation model
5
* @version 0.1
6
* @date 2021-12-01
7
*
8
* References:
9
*
10
* - Rybicki, G. B.; Lightman, A. P. (1979).
11
* _Radiative Processes in Astrophysics._ John Wiley & Sons.
12
* ISBN 0-471-82759-2.
13
*
14
* Planck's law of black-body radiation states that
15
* \f{eqnarray*}{
16
* f_{\lambda }(T) &=& a\,\cdot\,{\frac {2h\nu ^{3}}{c^{2}}}{\frac {1}{e^{h\nu /kT}-1}}\\
17
* &=& a\,\cdot\,\frac{2hc^2}{\lambda^5}{\frac {1}{e^{hc /\lambda kT}-1}},
18
* \f}
19
* where
20
* - \f$f_\lambda(T)\f$ is the spectral flux density at thermal equilibrium of temperature \f$T\f$.
21
* - \f$h\f$ is the Planck constant (\f$6.6260693\cdot10^{-34}\f$ J/s);
22
* - \f$c\f$ is the speed of light in a vacuum (\f$299792458\cdot 10^6\mu m/s\f$);
23
* - \f$k\f$ is the Boltzmann constant (\f$1.3806505\cdot 10^{-23}\f$ J/K);
24
* - \f$\nu\f$ is the frequency of the electromagnetic radiation;
25
* - \f$\lambda\f$ is the wavelength of the electromagnetic radiation;
26
* - \f$T\f$ is the absolute temperature of the body;
27
* - and \f$a\f$ is a dimensionless normalization factor.
28
*
29
* Note that $a$ can alternatively links to the angular size $\theta$
30
* \f[
31
* \theta = \sqrt{\frac{a}{\pi}} = \frac{R}{d}
32
* \f]
33
* where \f$R\f$ is the radius, and \f$d\f$ is the distance to the star.
34
*
35
*/
36
#pragma once
37
#include "
cphot/rquantities.hpp
"
38
39
/**
40
* Blackbody as a flux distribution as function
41
* of wavelength, temperature and amplitude.
42
*
43
* This function deals with unit conversions
44
*
45
* @param lam: wavelength
46
* @param amp: dimensionless normalization factor
47
* @param teff: temperature
48
* @return evaluation of the blackbody radiation in flam units (erg/s/cm2/AA)
49
*
50
* Note that amp is alternatively represented as the angular size θ = R/d = sqrt(amp/pi)
51
*/
52
QSpectralFluxDensity
bb_flux_function
(QLength lam,
53
Number amp,
54
QTemperature teff){
55
// Natural constants.
56
double
kB = (1.380649e-23 *
joule
/
kelvin
).getValue();
57
double
c
=
speed_of_light
.Convert(
meter
/
second
);
58
double
h = (6.62607015e-34 *
metre2
*
kg
/
second
).getValue();
59
double
lam_nm = lam.Convert(
nanometre
);
60
double
teff_K = teff.Convert(
kelvin
);
61
double
amp_ = amp.getValue();
62
63
double
v = (amp_ * 2 * h * std::pow(
c
, 2) / (std::pow(lam_nm, 5) *
64
(std::exp(h *
c
/ (lam_nm * 1e-9 * kB * teff_K)) - 1)));
65
66
return
v * 1e+38 *
flam
;
67
}
68
69
70
/**
71
* default units blackbody as a flux distribution as function of wavelength,
72
* temperature and amplitude.
73
*
74
* @param lam: wavelength in nm
75
* @param amp: dimensionless normalization factor
76
* @param teff: temperature in Kelvins
77
* @return evaluation of the blackbody radiation in flam units (erg/s/cm2/AA)
78
*
79
*/
80
double
bb_flux_function
(
double
lam_nm,
double
amp,
double
teff_K){
81
// Natural constants.
82
double
kB = 1.380649e-23;
// Unit("J/K")
83
double
c
= 299792458.0;
// Unit("m/s")
84
double
h = 6.62607015e-34;
// Unit('m**2 * kg / s')
85
double
v = (amp * 2 * h * std::pow(
c
, 2) / (std::pow(lam_nm, 5) *
86
(std::exp(h *
c
/ (lam_nm * 1e-9 * kB * teff_K)) - 1)));
87
std::cout << lam_nm <<
" "
<< amp <<
" "
<< teff_K <<
"\n"
;
88
return
v * 1e+38;
// flam = erg/s/cm2/AA
89
}
bb_flux_function
QSpectralFluxDensity bb_flux_function(QLength lam, Number amp, QTemperature teff)
Blackbody as a flux distribution as function of wavelength, temperature and amplitude.
Definition:
blackbody.hpp:52
rquantities.hpp
nanometre
constexpr QLength nanometre
Definition:
rquantities.hpp:271
joule
constexpr QEnergy joule
Definition:
rquantities.hpp:326
c
constexpr QSpeed c
Definition:
rquantities.hpp:351
kelvin
constexpr QTemperature kelvin
Definition:
rquantities.hpp:342
speed_of_light
constexpr QSpeed speed_of_light
Definition:
rquantities.hpp:350
metre2
constexpr QArea metre2
Definition:
rquantities.hpp:282
meter
constexpr QLength meter
Definition:
rquantities.hpp:266
flam
constexpr QSpectralFluxDensity flam
Definition:
rquantities.hpp:361
kg
constexpr QMass kg(1.0)
second
constexpr QTime second(1.0)
include
blackbody.hpp
Generated on Thu Dec 16 2021 14:06:41 for cphot by
1.8.17