source: Sophya/trunk/SophyaLib/SkyT/nupower.cc@ 668

Last change on this file since 668 was 668, checked in by ansari, 26 years ago

Ajout de classes deleguees PPersist et correction integration - Sophie 29/11/99

File size: 2.1 KB
Line 
1//--------------------------------------------------------------------------
2// File and Version Information:
3// $Id: nupower.cc,v 1.4 1999-11-29 14:16:05 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//----------------
26PowerLawSpectra::PowerLawSpectra()
27{
28}
29
30PowerLawSpectra::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
40PowerLawSpectra::~PowerLawSpectra()
41{
42}
43
44double
45PowerLawSpectra::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
54void
55PowerLawSpectra::WriteSelf(POutPersist& s)
56{
57 s.PutR8(this->giveNorm());
58 s.PutR8(this->giveNu0());
59 s.PutR8(this->giveDNu());
60 s.PutR8(this->giveExp());
61 s.PutR8(this->minFreq());
62 s.PutR8(this->maxFreq());
63}
64
65void
66PowerLawSpectra::ReadSelf(PInPersist& s)
67{
68 s.GetR8(_a);
69 s.GetR8(_nu0);
70 s.GetR8(_dnu);
71 s.GetR8(_b);
72 s.GetR8(_numin);
73 s.GetR8(_numax);
74 cout << " Norm - Nu0 - DNu - Exp - minFreq - maxFreq " << endl;
75 cout << _a << "-" << _nu0 << "-" << _dnu << "-" << _b << "-" << _numin << "-" << _numax << endl;
76}
77
78
79void
80PowerLawSpectra::Print(ostream& os) const
81{
82 os << "PowerLawSpectra::Print f = a ((nu-nu0)/dnu)^b " << _a << "((nu-" << _nu0
83 << ") / " << _dnu << ") ^ " << _b << endl;
84 os << " - Fmin,Fmax= " << minFreq() << "," << maxFreq() << endl;
85 os << "MeanFreq= " << meanFreq() << " Emission= " << flux(meanFreq()) << endl;
86 os << "PeakFreq= " << peakFreq() << " Emission= " << flux(peakFreq()) << endl;
87
88}
Note: See TracBrowser for help on using the repository browser.