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

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

Sophie: adding documentation for Doxygen in the .cc files:wq

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