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