source: Sophya/trunk/SophyaLib/SkyT/blackbody.cc@ 3951

Last change on this file since 3951 was 2615, checked in by cmv, 21 years ago

using namespace sophya enleve de machdefs.h, nouveau sopnamsp.h cmv 10/09/2004

File size: 2.4 KB
Line 
1//--------------------------------------------------------------------------
2// File and Version Information:
3// $Id: blackbody.cc,v 1.9 2004-09-10 09:54:39 cmv Exp $
4//
5// Description:
6// Aim of the class: To give the energy density for a blackbody
7// The unity used here is W/m^2/Hz/sr
8//
9// History (add to end):
10// Sophie Oct, 1999 - creation
11//
12//------------------------------------------------------------------------
13
14//---------------
15// C++ Headers --
16//---------------
17#include "sopnamsp.h"
18#include "machdefs.h"
19#include <iostream>
20#include <math.h>
21#include "blackbody.h"
22
23/*!
24 * \class SOPHYA::BlackBody
25 \ingroup SkyT
26 This class corresponds to the emission spectrum of a
27 blackbody radiation.
28 */
29//----------------
30// Constructor --
31//----------------
32/*! Constructor: needs a temperature. Otherwise set to ConvTools::tcmb */
33BlackBody::BlackBody(double temperature)
34 : RadSpectra(10., 10000.)
35{
36 _temperature = temperature;
37}
38
39
40BlackBody::~BlackBody()
41{
42}
43/*! Black Body Flux Function:
44 \f[
45 I_\nu = {2 h_{pl} (1.10^9*\nu)^3 \over c^2 (e^{{h_{pl}(1.10^9*\nu) \over kT}} -1)}
46 \f]
47*/
48double
49BlackBody::flux(double nu) const
50{
51 if(nu < -1.e99) nu = -1.e99;
52 if(nu > 1.e99) nu = 1.e99;
53 double temperature = getTemperature();
54 if(nu==0.) return 0.;
55 double hpl = ConvTools::hpl;
56 double cel = ConvTools::cel;
57 double kb = ConvTools::kb;
58 double puiss1 = nu*pow(10.,9);
59 if(puiss1 > 1.e99) puiss1=1.e99;
60 if(puiss1 < -1.e99) puiss1=-1.e99;
61 double puiss2 = hpl*nu*pow(10.,9)/(kb*temperature);
62 if(puiss2 > 1.e99) puiss2=1.e99;
63 if(puiss2 < -1.e99) puiss2=-1.e99;
64
65 double result=
66 (2*hpl* pow( puiss1 ,3))/( pow(cel,2)*(exp(puiss2)-1));
67 return result;
68}
69
70
71void
72BlackBody::Print(ostream& os) const
73{
74 os << "BlackBody::Print Temp= " << getTemperature()
75 << " - Fmin,Fmax= " << minFreq() << "," << maxFreq() << endl;
76 os << "MeanFreq= " << meanFreq() << " Emission= " << flux(meanFreq()) << endl;
77 os << "PeakFreq= " << peakFreq() << " Emission= " << flux(peakFreq()) << endl;
78
79}
80
81/*
82void
83BlackBody::WriteSelf(POutPersist& s)
84{
85 s.PutR8(this->getTemperature());
86 s.PutR8(this->minFreq());
87 s.PutR8(this->maxFreq());
88}
89
90void
91BlackBody::ReadSelf(PInPersist& s)
92{
93 s.GetR8(_temperature);
94 s.GetR8(_numin);
95 s.GetR8(_numax);
96 cout << " Temperature - minFreq - maxFreq " << endl;
97 cout << _temperature << "-" << _numin << "-" << _numax << endl;
98}
99
100*/
Note: See TracBrowser for help on using the repository browser.