| [601] | 1 | //--------------------------------------------------------------------------
 | 
|---|
 | 2 | // File and Version Information:
 | 
|---|
| [2615] | 3 | //      $Id: nupower.cc,v 1.9 2004-09-10 09:54:40 cmv Exp $
 | 
|---|
| [601] | 4 | //
 | 
|---|
 | 5 | // Description:
 | 
|---|
 | 6 | //      Aim of the class: To give the energy density for a nupower
 | 
|---|
 | 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 | 
 | 
|---|
 | 22 | #include "nupower.h"
 | 
|---|
 | 23 | 
 | 
|---|
| [909] | 24 | 
 | 
|---|
 | 25 | /*! 
 | 
|---|
| [927] | 26 |  * \class SOPHYA::PowerLawSpectra 
 | 
|---|
 | 27 |  \ingroup SkyT
 | 
|---|
| [909] | 28 |  * This class corresponds to a power law radiation spectrum.
 | 
|---|
 | 29 | */
 | 
|---|
| [668] | 30 | PowerLawSpectra::PowerLawSpectra()
 | 
|---|
 | 31 | {
 | 
|---|
 | 32 | }
 | 
|---|
| [909] | 33 | /*! Constructor: The arguments corresponds to the Power Law Spectrum
 | 
|---|
 | 34 |   equation:
 | 
|---|
 | 35 | <a name="psldef"> </a>
 | 
|---|
 | 36 | \f[
 | 
|---|
 | 37 | \hbox{flux}(\nu) = A ({\nu-\nu_0\over \delta\nu})^B
 | 
|---|
 | 38 | \f]
 | 
|---|
 | 39 | */
 | 
|---|
 | 40 | PowerLawSpectra::PowerLawSpectra(double A, double B, double nu0, double dnu, double numin, double numax)
 | 
|---|
| [601] | 41 |   : RadSpectra(numin, numax)
 | 
|---|
 | 42 | {
 | 
|---|
| [909] | 43 |   _a = A;
 | 
|---|
 | 44 |   _b = B;
 | 
|---|
| [601] | 45 |   _nu0 = nu0;
 | 
|---|
| [610] | 46 |   _dnu = (dnu > 1.e-19) ? dnu : 1.;
 | 
|---|
| [601] | 47 | }
 | 
|---|
 | 48 | 
 | 
|---|
 | 49 | 
 | 
|---|
 | 50 | PowerLawSpectra::~PowerLawSpectra()
 | 
|---|
 | 51 | {
 | 
|---|
 | 52 | }
 | 
|---|
| [909] | 53 | /*! Flux function according to the <a href="#psldef"> above </a>
 | 
|---|
 | 54 |  equation */
 | 
|---|
| [601] | 55 | double
 | 
|---|
 | 56 | PowerLawSpectra::flux(double nu) const
 | 
|---|
 | 57 | {
 | 
|---|
| [610] | 58 |   if ((nu< _numin) || (nu > _numax)) return(0.);
 | 
|---|
 | 59 |   double tmp = (nu-_nu0)/_dnu;
 | 
|---|
 | 60 |   if (tmp <= 0.)  return(0.); 
 | 
|---|
 | 61 |   else return(  _a * pow(tmp, _b) );
 | 
|---|
| [601] | 62 | }
 | 
|---|
 | 63 | 
 | 
|---|
| [668] | 64 | 
 | 
|---|
| [669] | 65 | 
 | 
|---|
 | 66 | void
 | 
|---|
 | 67 | PowerLawSpectra::Print(ostream& os) const
 | 
|---|
 | 68 | {
 | 
|---|
 | 69 |   os << "PowerLawSpectra::Print f = a ((nu-nu0)/dnu)^b " << _a << "((nu-" << _nu0 
 | 
|---|
 | 70 |      << ") / " << _dnu << ") ^ " << _b << endl;
 | 
|---|
 | 71 |   os << " - Fmin,Fmax= " << minFreq() << "," << maxFreq() << endl;
 | 
|---|
 | 72 |   os << "MeanFreq= " << meanFreq() << "  Emission= " << flux(meanFreq()) << endl;
 | 
|---|
 | 73 |   os << "PeakFreq= " << peakFreq() << "  Emission= " << flux(peakFreq()) << endl;
 | 
|---|
 | 74 | 
 | 
|---|
 | 75 | }
 | 
|---|
 | 76 | 
 | 
|---|
 | 77 | 
 | 
|---|
 | 78 | /*
 | 
|---|
| [668] | 79 | void 
 | 
|---|
 | 80 | PowerLawSpectra::WriteSelf(POutPersist& s)  
 | 
|---|
 | 81 | {
 | 
|---|
 | 82 |   s.PutR8(this->giveNorm());
 | 
|---|
 | 83 |   s.PutR8(this->giveNu0());
 | 
|---|
 | 84 |   s.PutR8(this->giveDNu());
 | 
|---|
 | 85 |   s.PutR8(this->giveExp());
 | 
|---|
 | 86 |   s.PutR8(this->minFreq());
 | 
|---|
 | 87 |   s.PutR8(this->maxFreq());
 | 
|---|
 | 88 | }
 | 
|---|
 | 89 | 
 | 
|---|
| [601] | 90 | void
 | 
|---|
| [668] | 91 | PowerLawSpectra::ReadSelf(PInPersist& s)  
 | 
|---|
 | 92 | {
 | 
|---|
 | 93 |   s.GetR8(_a);
 | 
|---|
 | 94 |   s.GetR8(_nu0);
 | 
|---|
 | 95 |   s.GetR8(_dnu);
 | 
|---|
 | 96 |   s.GetR8(_b);
 | 
|---|
 | 97 |   s.GetR8(_numin);
 | 
|---|
 | 98 |   s.GetR8(_numax);
 | 
|---|
 | 99 |   cout << " Norm - Nu0 - DNu - Exp - minFreq - maxFreq " << endl; 
 | 
|---|
 | 100 |   cout << _a << "-" << _nu0  << "-" << _dnu << "-" << _b << "-" << _numin << "-" << _numax << endl;
 | 
|---|
 | 101 | }
 | 
|---|
 | 102 | 
 | 
|---|
| [669] | 103 | */
 | 
|---|