1 | //--------------------------------------------------------------------------
|
---|
2 | // File and Version Information:
|
---|
3 | // $Id: nupower.cc,v 1.7 2000-04-14 07:28:12 ansari Exp $
|
---|
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"
|
---|
18 | #include <iostream.h>
|
---|
19 | #include <math.h>
|
---|
20 |
|
---|
21 | #include "nupower.h"
|
---|
22 |
|
---|
23 |
|
---|
24 | /*!
|
---|
25 | * \class SOPHYA::PowerLawSpectra
|
---|
26 | \ingroup SkyT
|
---|
27 | * This class corresponds to a power law radiation spectrum.
|
---|
28 | */
|
---|
29 | PowerLawSpectra::PowerLawSpectra()
|
---|
30 | {
|
---|
31 | }
|
---|
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)
|
---|
40 | : RadSpectra(numin, numax)
|
---|
41 | {
|
---|
42 | _a = A;
|
---|
43 | _b = B;
|
---|
44 | _nu0 = nu0;
|
---|
45 | _dnu = (dnu > 1.e-19) ? dnu : 1.;
|
---|
46 | }
|
---|
47 |
|
---|
48 |
|
---|
49 | PowerLawSpectra::~PowerLawSpectra()
|
---|
50 | {
|
---|
51 | }
|
---|
52 | /*! Flux function according to the <a href="#psldef"> above </a>
|
---|
53 | equation */
|
---|
54 | double
|
---|
55 | PowerLawSpectra::flux(double nu) const
|
---|
56 | {
|
---|
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) );
|
---|
61 | }
|
---|
62 |
|
---|
63 |
|
---|
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 | /*
|
---|
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 |
|
---|
89 | void
|
---|
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 |
|
---|
102 | */
|
---|