forked from elizakempton/Exo_Transmit
-
Notifications
You must be signed in to change notification settings - Fork 0
/
planck.c
45 lines (30 loc) · 1.22 KB
/
planck.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
/* ------- file: -------------------------- planck.c ----------------
Author: Han Uitenbroek ([email protected])
Modified by Eliza Miller-Ricci
Last modified: Aug 23, 2007 --
-------------------------- -------------- */
/* --- Evaluate the Planck function and its derivative
at temperature T and wavelength lambda.
Input: T -- temperature [K].
lambda -- wavelength [m].
Output: Bnu -- Planck function value
[J m^-2 s^-1 Hz^-1 sr^-1].
* -- -------------- */
#include <stdio.h>
#include <math.h>
#include "constant.h"
#include "include.h"
#define MAX_EXPONENT 400.0
/* ------- begin -------------------------- Planck.c ---------------- */
double Planck(double T, double lambda)
{
double Bnu, twohnu3_c2, hc_Tkla;
hc_Tkla = (HPLANCK * CLIGHT) / (T * KBOLTZMANN * lambda);
twohnu3_c2 = (2.0*HPLANCK*CLIGHT) / CUBE(lambda);
if (hc_Tkla <= MAX_EXPONENT)
Bnu = twohnu3_c2 / (exp(hc_Tkla) - 1.0);
else
Bnu = 0.0;
return Bnu;
}
/* ------- end ---------------------------- Planck.c ---------------- */