| 1 | //-------------------------------------------------------------------------- | 
|---|
| 2 | // File and Version Information: | 
|---|
| 3 | //      $Id: derivblackbody.cc,v 1.6 2003-02-11 15:31:07 cmv Exp $ | 
|---|
| 4 | // | 
|---|
| 5 | // Description: | 
|---|
| 6 | //      Aim of the class: To give the derivative spectrum | 
|---|
| 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> | 
|---|
| 19 | #include <math.h> | 
|---|
| 20 | #include "derivblackbody.h" | 
|---|
| 21 |  | 
|---|
| 22 |  | 
|---|
| 23 |  | 
|---|
| 24 | /*! \class SOPHYA::DerivBlackBody | 
|---|
| 25 | \ingroup SkyT | 
|---|
| 26 | * This class corresponds to the emission spectrum of a | 
|---|
| 27 | * dipole (since its emission spectrum is the derivation | 
|---|
| 28 | * of a blackbody spectrum wrt the temperature). | 
|---|
| 29 | */ | 
|---|
| 30 |  | 
|---|
| 31 | /*! Constructor: needs a temperature. Otherwise set to ConvTools::tcmb */ | 
|---|
| 32 | DerivBlackBody::DerivBlackBody(double temperature) | 
|---|
| 33 | : RadSpectra(10., 10000.) | 
|---|
| 34 | { | 
|---|
| 35 | _temperature = temperature; | 
|---|
| 36 | } | 
|---|
| 37 |  | 
|---|
| 38 |  | 
|---|
| 39 | DerivBlackBody::~DerivBlackBody() | 
|---|
| 40 | { | 
|---|
| 41 | } | 
|---|
| 42 |  | 
|---|
| 43 | /*! | 
|---|
| 44 | The flux function is the derivation of the BlackBody | 
|---|
| 45 | flux function wrt the temperature (used e.g. for a Dipole) | 
|---|
| 46 | \f[ | 
|---|
| 47 | I_\nu = {2 h_{pl} (1.10^9*\nu)^3  {h_{pl}1.10^9*\nu \over k T^2} | 
|---|
| 48 | {e^{{h_{pl}(1.10^9*\nu) \over kT}}\over c^2 (e^{{h_{pl}(1.10^9*\nu) \over kT}} -1)^2}} | 
|---|
| 49 | \f] | 
|---|
| 50 | */ | 
|---|
| 51 | double | 
|---|
| 52 | DerivBlackBody::flux(double nu) const | 
|---|
| 53 | { | 
|---|
| 54 | if(nu < -1.e99) nu = -1.e99; | 
|---|
| 55 | if(nu > 1.e99) nu = 1.e99; | 
|---|
| 56 | double temperature = getTemperature(); | 
|---|
| 57 | if(nu==0.) return 0.; | 
|---|
| 58 | double hpl = ConvTools::hpl; | 
|---|
| 59 | double cel = ConvTools::cel; | 
|---|
| 60 | double kb  = ConvTools::kb; | 
|---|
| 61 | double puiss1 = nu*pow(10.,9); | 
|---|
| 62 | if(puiss1 >  1.e99)   puiss1=1.e99; | 
|---|
| 63 | if(puiss1 < -1.e99)   puiss1=-1.e99; | 
|---|
| 64 | double puiss2 = hpl*nu*pow(10.,9)/(kb*temperature); | 
|---|
| 65 | if(puiss2 >  1.e99)   puiss2=1.e99; | 
|---|
| 66 | if(puiss2 < -1.e99)   puiss2=-1.e99; | 
|---|
| 67 |  | 
|---|
| 68 | double result= | 
|---|
| 69 | (2*hpl* pow( puiss1 ,3))*(hpl*puiss1/kb)*(1/(temperature*temperature)) | 
|---|
| 70 | *exp(puiss2) | 
|---|
| 71 | /(pow(cel,2)*pow(( (exp(puiss2)-1)),2)); | 
|---|
| 72 | //  result = 1500e3*result/400e6; | 
|---|
| 73 | return result; | 
|---|
| 74 | } | 
|---|
| 75 |  | 
|---|
| 76 |  | 
|---|
| 77 | void | 
|---|
| 78 | DerivBlackBody::Print(ostream& os) const | 
|---|
| 79 | { | 
|---|
| 80 | os << "DerivBlackBody::Print Temp= " << getTemperature() | 
|---|
| 81 | << " - Fmin,Fmax= " << minFreq() << "," << maxFreq() << endl; | 
|---|
| 82 | os << "MeanFreq= " << meanFreq() << "  Emission= " << flux(meanFreq()) << endl; | 
|---|
| 83 | os << "PeakFreq= " << peakFreq() << "  Emission= " << flux(peakFreq()) << endl; | 
|---|
| 84 |  | 
|---|
| 85 | } | 
|---|
| 86 |  | 
|---|
| 87 | /* | 
|---|
| 88 | void | 
|---|
| 89 | DerivBlackBody::WriteSelf(POutPersist& s) | 
|---|
| 90 | { | 
|---|
| 91 | s.PutR8(this->getTemperature()); | 
|---|
| 92 | s.PutR8(this->minFreq()); | 
|---|
| 93 | s.PutR8(this->maxFreq()); | 
|---|
| 94 | } | 
|---|
| 95 |  | 
|---|
| 96 | void | 
|---|
| 97 | DerivBlackBody::ReadSelf(PInPersist& s) | 
|---|
| 98 | { | 
|---|
| 99 | s.GetR8(_temperature); | 
|---|
| 100 | s.GetR8(_numin); | 
|---|
| 101 | s.GetR8(_numax); | 
|---|
| 102 | cout << " Temperature - minFreq - maxFreq " << endl; | 
|---|
| 103 | cout << _temperature << "-" << _numin << "-" << _numax << endl; | 
|---|
| 104 | } | 
|---|
| 105 |  | 
|---|
| 106 | */ | 
|---|