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

Last change on this file since 3589 was 2615, checked in by cmv, 21 years ago

using namespace sophya enleve de machdefs.h, nouveau sopnamsp.h cmv 10/09/2004

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