1 | //--------------------------------------------------------------------------
|
---|
2 | // File and Version Information:
|
---|
3 | // $Id: nupower.cc,v 1.5 1999-11-29 16:59:10 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 | // Constructor --
|
---|
25 | //----------------
|
---|
26 | PowerLawSpectra::PowerLawSpectra()
|
---|
27 | {
|
---|
28 | }
|
---|
29 |
|
---|
30 | PowerLawSpectra::PowerLawSpectra(double a, double b, double nu0, double dnu, double numin, double numax)
|
---|
31 | : RadSpectra(numin, numax)
|
---|
32 | {
|
---|
33 | _a = a;
|
---|
34 | _b = b;
|
---|
35 | _nu0 = nu0;
|
---|
36 | _dnu = (dnu > 1.e-19) ? dnu : 1.;
|
---|
37 | }
|
---|
38 |
|
---|
39 |
|
---|
40 | PowerLawSpectra::~PowerLawSpectra()
|
---|
41 | {
|
---|
42 | }
|
---|
43 |
|
---|
44 | double
|
---|
45 | PowerLawSpectra::flux(double nu) const
|
---|
46 | {
|
---|
47 | if ((nu< _numin) || (nu > _numax)) return(0.);
|
---|
48 | double tmp = (nu-_nu0)/_dnu;
|
---|
49 | if (tmp <= 0.) return(0.);
|
---|
50 | else return( _a * pow(tmp, _b) );
|
---|
51 | }
|
---|
52 |
|
---|
53 |
|
---|
54 |
|
---|
55 | void
|
---|
56 | PowerLawSpectra::Print(ostream& os) const
|
---|
57 | {
|
---|
58 | os << "PowerLawSpectra::Print f = a ((nu-nu0)/dnu)^b " << _a << "((nu-" << _nu0
|
---|
59 | << ") / " << _dnu << ") ^ " << _b << endl;
|
---|
60 | os << " - Fmin,Fmax= " << minFreq() << "," << maxFreq() << endl;
|
---|
61 | os << "MeanFreq= " << meanFreq() << " Emission= " << flux(meanFreq()) << endl;
|
---|
62 | os << "PeakFreq= " << peakFreq() << " Emission= " << flux(peakFreq()) << endl;
|
---|
63 |
|
---|
64 | }
|
---|
65 |
|
---|
66 |
|
---|
67 | /*
|
---|
68 | void
|
---|
69 | PowerLawSpectra::WriteSelf(POutPersist& s)
|
---|
70 | {
|
---|
71 | s.PutR8(this->giveNorm());
|
---|
72 | s.PutR8(this->giveNu0());
|
---|
73 | s.PutR8(this->giveDNu());
|
---|
74 | s.PutR8(this->giveExp());
|
---|
75 | s.PutR8(this->minFreq());
|
---|
76 | s.PutR8(this->maxFreq());
|
---|
77 | }
|
---|
78 |
|
---|
79 | void
|
---|
80 | PowerLawSpectra::ReadSelf(PInPersist& s)
|
---|
81 | {
|
---|
82 | s.GetR8(_a);
|
---|
83 | s.GetR8(_nu0);
|
---|
84 | s.GetR8(_dnu);
|
---|
85 | s.GetR8(_b);
|
---|
86 | s.GetR8(_numin);
|
---|
87 | s.GetR8(_numax);
|
---|
88 | cout << " Norm - Nu0 - DNu - Exp - minFreq - maxFreq " << endl;
|
---|
89 | cout << _a << "-" << _nu0 << "-" << _dnu << "-" << _b << "-" << _numin << "-" << _numax << endl;
|
---|
90 | }
|
---|
91 |
|
---|
92 | */
|
---|