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

Last change on this file since 1594 was 927, checked in by ansari, 25 years ago

SOphie : Adding the ingroup SkyT in each .cc file for DoxyGen Doc

File size: 2.4 KB
RevLine 
[601]1//--------------------------------------------------------------------------
2// File and Version Information:
[927]3// $Id: blackbody.cc,v 1.6 2000-04-14 07:28:11 ansari Exp $
[601]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 "machdefs.h"
18#include <iostream.h>
19#include <math.h>
20#include "blackbody.h"
21
[909]22/*!
[927]23 * \class SOPHYA::BlackBody
24 \ingroup SkyT
[909]25 This class corresponds to the emission spectrum of a
26 blackbody radiation.
27 */
[601]28//----------------
29// Constructor --
30//----------------
[909]31/*! Constructor: needs a temperature. Otherwise set to ConvTools::tcmb */
[601]32BlackBody::BlackBody(double temperature)
[668]33 : RadSpectra(10., 10000.)
[601]34{
35 _temperature = temperature;
36}
37
38
39BlackBody::~BlackBody()
40{
41}
[909]42/*! Black Body Flux Function:
43 \f[
44 I_\nu = {2 h_{pl} (1.10^9*\nu)^3 \over c^2 (e^{{h_{pl}(1.10^9*\nu) \over kT}} -1)}
45 \f]
46*/
[601]47double
48BlackBody::flux(double nu) const
49{
50 if(nu < -1.e99) nu = -1.e99;
51 if(nu > 1.e99) nu = 1.e99;
52 double temperature = getTemperature();
53 if(nu==0.) return 0.;
54 double hpl = ConvTools::hpl;
55 double cel = ConvTools::cel;
56 double kb = ConvTools::kb;
57 double puiss1 = nu*pow(10,9);
58 if(puiss1 > 1.e99) puiss1=1.e99;
59 if(puiss1 < -1.e99) puiss1=-1.e99;
60 double puiss2 = hpl*nu*pow(10,9)/(kb*temperature);
61 if(puiss2 > 1.e99) puiss2=1.e99;
62 if(puiss2 < -1.e99) puiss2=-1.e99;
63
64 double result=
65 (2*hpl* pow( puiss1 ,3))/( pow(cel,2)*(exp(puiss2)-1));
66 return result;
67}
68
[669]69
70void
71BlackBody::Print(ostream& os) const
72{
73 os << "BlackBody::Print Temp= " << getTemperature()
74 << " - Fmin,Fmax= " << minFreq() << "," << maxFreq() << endl;
75 os << "MeanFreq= " << meanFreq() << " Emission= " << flux(meanFreq()) << endl;
76 os << "PeakFreq= " << peakFreq() << " Emission= " << flux(peakFreq()) << endl;
77
78}
79
80/*
[668]81void
82BlackBody::WriteSelf(POutPersist& s)
83{
84 s.PutR8(this->getTemperature());
85 s.PutR8(this->minFreq());
86 s.PutR8(this->maxFreq());
87}
88
[601]89void
[668]90BlackBody::ReadSelf(PInPersist& s)
91{
92 s.GetR8(_temperature);
93 s.GetR8(_numin);
94 s.GetR8(_numax);
95 cout << " Temperature - minFreq - maxFreq " << endl;
96 cout << _temperature << "-" << _numin << "-" << _numax << endl;
97}
98
[669]99*/
Note: See TracBrowser for help on using the repository browser.