-
Notifications
You must be signed in to change notification settings - Fork 17
/
planck.c
55 lines (36 loc) · 1.54 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
44
45
46
47
48
49
50
51
52
53
54
55
/* ------- file: -------------------------- planck.c ----------------
Version: rh2.0
Author: Han Uitenbroek ([email protected])
Last modified: Thu Nov 11 15:12:13 2010 --
-------------------------- ----------RH-- */
/* --- Evaluate the Planck function at wavelength lambda.
Input: Nspace -- dimension of temperature array.
T[Nspace] -- array of temperatures [K].
lambda -- wavelength [nm].
Output: Bnu[Nspace] -- array of Planck function values
[J m^-2 s^-1 Hz^-1 sr^-1].
* -- -------------- */
#include <math.h>
#include "rh.h"
#include "atom.h"
#include "spectrum.h"
#include "constant.h"
#define MAX_EXPONENT 150.0
/* --- Function prototypes -- -------------- */
/* --- Global variables -- -------------- */
/* ------- begin -------------------------- Planck.c ---------------- */
void Planck(long Nspace, double *T, double lambda, double *Bnu)
{
register int k;
double hc_kla, twohnu3_c2, hc_Tkla;
hc_kla = (HPLANCK * CLIGHT) / (KBOLTZMANN * NM_TO_M * lambda);
twohnu3_c2 = (2.0*HPLANCK*CLIGHT) / CUBE(NM_TO_M * lambda);
for (k = 0; k < Nspace; k++) {
hc_Tkla = hc_kla/T[k];
if (hc_Tkla <= MAX_EXPONENT)
Bnu[k] = twohnu3_c2 / (exp(hc_Tkla) - 1.0);
else
Bnu[k] = 0.0;
}
}
/* ------- end ---------------------------- Planck.c ---------------- */