| [601] | 1 | //--------------------------------------------------------------------------
 | 
|---|
 | 2 | // File and Version Information:
 | 
|---|
| [2615] | 3 | //      $Id: blackbody.cc,v 1.9 2004-09-10 09:54:39 cmv 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 | //---------------
 | 
|---|
| [2615] | 17 | #include "sopnamsp.h"
 | 
|---|
| [601] | 18 | #include "machdefs.h"
 | 
|---|
| [2322] | 19 | #include <iostream>
 | 
|---|
| [601] | 20 | #include <math.h>
 | 
|---|
 | 21 | #include "blackbody.h"
 | 
|---|
 | 22 | 
 | 
|---|
| [909] | 23 | /*! 
 | 
|---|
| [927] | 24 |  * \class SOPHYA::BlackBody 
 | 
|---|
 | 25 |  \ingroup SkyT
 | 
|---|
| [909] | 26 |  This class corresponds to the emission spectrum of a
 | 
|---|
 | 27 |  blackbody radiation.
 | 
|---|
 | 28 |  */
 | 
|---|
| [601] | 29 | //----------------
 | 
|---|
 | 30 | // Constructor --
 | 
|---|
 | 31 | //----------------
 | 
|---|
| [909] | 32 | /*! Constructor: needs a temperature. Otherwise set to ConvTools::tcmb */
 | 
|---|
| [601] | 33 | BlackBody::BlackBody(double temperature)
 | 
|---|
| [668] | 34 |   : RadSpectra(10., 10000.)
 | 
|---|
| [601] | 35 | {
 | 
|---|
 | 36 |   _temperature = temperature;
 | 
|---|
 | 37 | }
 | 
|---|
 | 38 | 
 | 
|---|
 | 39 | 
 | 
|---|
 | 40 | BlackBody::~BlackBody()
 | 
|---|
 | 41 | {
 | 
|---|
 | 42 | }
 | 
|---|
| [909] | 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 | */
 | 
|---|
| [601] | 48 | double
 | 
|---|
 | 49 | BlackBody::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;
 | 
|---|
| [2144] | 58 |   double puiss1 = nu*pow(10.,9);
 | 
|---|
| [601] | 59 |   if(puiss1 >  1.e99)   puiss1=1.e99;
 | 
|---|
 | 60 |   if(puiss1 < -1.e99)   puiss1=-1.e99;
 | 
|---|
| [2144] | 61 |   double puiss2 = hpl*nu*pow(10.,9)/(kb*temperature);
 | 
|---|
| [601] | 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 | 
 | 
|---|
| [669] | 70 | 
 | 
|---|
 | 71 | void
 | 
|---|
 | 72 | BlackBody::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 | /*
 | 
|---|
| [668] | 82 | void 
 | 
|---|
 | 83 | BlackBody::WriteSelf(POutPersist& s)  
 | 
|---|
 | 84 | {
 | 
|---|
 | 85 |   s.PutR8(this->getTemperature());
 | 
|---|
 | 86 |   s.PutR8(this->minFreq());
 | 
|---|
 | 87 |   s.PutR8(this->maxFreq());
 | 
|---|
 | 88 | }
 | 
|---|
 | 89 | 
 | 
|---|
| [601] | 90 | void
 | 
|---|
| [668] | 91 | BlackBody::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 | 
 | 
|---|
| [669] | 100 | */
 | 
|---|