1 | //--------------------------------------------------------------------------
|
---|
2 | // File and Version Information:
|
---|
3 | // $Id: nupower.cc,v 1.3 1999-11-21 23:25:45 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(double a, double b, double nu0, double dnu, double numin, double numax)
|
---|
27 | : RadSpectra(numin, numax)
|
---|
28 | {
|
---|
29 | _a = a;
|
---|
30 | _b = b;
|
---|
31 | _nu0 = nu0;
|
---|
32 | _dnu = (dnu > 1.e-19) ? dnu : 1.;
|
---|
33 | }
|
---|
34 |
|
---|
35 |
|
---|
36 | PowerLawSpectra::~PowerLawSpectra()
|
---|
37 | {
|
---|
38 | }
|
---|
39 |
|
---|
40 | double
|
---|
41 | PowerLawSpectra::flux(double nu) const
|
---|
42 | {
|
---|
43 | if ((nu< _numin) || (nu > _numax)) return(0.);
|
---|
44 | double tmp = (nu-_nu0)/_dnu;
|
---|
45 | if (tmp <= 0.) return(0.);
|
---|
46 | else return( _a * pow(tmp, _b) );
|
---|
47 | }
|
---|
48 |
|
---|
49 | void
|
---|
50 | PowerLawSpectra::Print(ostream& os) const
|
---|
51 | {
|
---|
52 | os << "PowerLawSpectra::Print f = a ((nu-nu0)/dnu)^b " << _a << "((nu-" << _nu0
|
---|
53 | << ") / " << _dnu << ") ^ " << _b << endl;
|
---|
54 | os << " - Fmin,Fmax= " << minFreq() << "," << maxFreq() << endl;
|
---|
55 | os << "MeanFreq= " << meanFreq() << " Emission= " << flux(meanFreq()) << endl;
|
---|
56 | os << "PeakFreq= " << peakFreq() << " Emission= " << flux(peakFreq()) << endl;
|
---|
57 |
|
---|
58 | }
|
---|