Cloudy
Spectral Synthesis Code for Astrophysics
Loading...
Searching...
No Matches
flux.h
Go to the documentation of this file.
1/* This file is part of Cloudy and is copyright (C)1978-2025 by Gary J. Ferland and
2 * others. For conditions of distribution and use see copyright notice in license.txt */
3
4#ifndef FLUX_H_
5#define FLUX_H_
6
7#include "energy.h"
8
9class Flux
10{
15 typedef bitset<FU_TOP> fu_bits;
16
18 double p_flux;
20
21 fu_bits p_InternalFluxUnitNoCheck(const string& unit, size_t& len) const;
22 fu_bits p_InternalFluxUnit(const string& unit) const;
23 bool p_ValidFluxUnit(fu_bits) const;
24 void p_set(Energy e, double value, fu_bits bits);
25 double p_get(fu_bits bits) const;
26public:
27 // CONSTRUCTORS
29 {
30 set(0., 0.);
31 p_userunits.reset();
32 }
33 Flux(Energy e, double flux)
34 {
35 set(e, flux);
36 }
37 Flux(Energy e, double flux, const string& unit)
38 {
39 set(e, flux, unit);
40 }
41 // MUTATORS
42 void set(Energy e, double flux)
43 {
44 set( e, flux, "erg/s/cm2" );
45 }
46 void set(Energy e, double flux, const string& unit)
47 {
48 p_set( e, flux, p_InternalFluxUnit(unit) );
49 }
50 // ACCESSORS
51 double get() const
52 {
53 return p_flux;
54 }
55 double get(const string& unit) const
56 {
57 return p_get( p_InternalFluxUnit(unit) );
58 }
59 Energy E() const
60 {
61 return p_energy;
62 }
63 string uu() const;
64 friend inline bool ValidFluxUnit(const string& unit);
65};
66
67// parse standard flux unit from Cloudy input line
68string StandardFluxUnit(const char*);
69
70// check if standard unit is valid
71inline bool ValidFluxUnit(const string& unit)
72{
73 Flux f;
74 size_t p;
76 return ( p == unit.length() && f.p_ValidFluxUnit(bits) );
77}
78
79#endif /* FLUX_H_ */
Definition energy.h:10
fu_bits p_InternalFluxUnitNoCheck(const string &unit, size_t &len) const
Definition flux.cpp:8
Flux()
Definition flux.h:28
friend bool ValidFluxUnit(const string &unit)
Definition flux.h:71
fu_bits p_userunits
Definition flux.h:19
Flux(Energy e, double flux)
Definition flux.h:33
fu_flag
Definition flux.h:11
@ FU_M2
Definition flux.h:13
@ FU_MJY_SR
Definition flux.h:12
@ FU_W
Definition flux.h:12
@ FU_MU
Definition flux.h:13
@ FU_JY
Definition flux.h:12
@ FU_A
Definition flux.h:13
@ FU_NM
Definition flux.h:13
@ FU_SQAS
Definition flux.h:13
@ FU_NONE
Definition flux.h:12
@ FU_SR
Definition flux.h:13
@ FU_TOP
Definition flux.h:13
@ FU_MJY
Definition flux.h:12
@ FU_HZ
Definition flux.h:13
@ FU_CM2
Definition flux.h:12
@ FU_ERG_S
Definition flux.h:12
Energy E() const
Definition flux.h:59
Energy p_energy
Definition flux.h:17
string uu() const
Definition flux.cpp:255
double get(const string &unit) const
Definition flux.h:55
void set(Energy e, double flux)
Definition flux.h:42
Flux(Energy e, double flux, const string &unit)
Definition flux.h:37
void p_set(Energy e, double value, fu_bits bits)
Definition flux.cpp:173
double p_get(fu_bits bits) const
Definition flux.cpp:142
fu_bits p_InternalFluxUnit(const string &unit) const
Definition flux.cpp:85
void set(Energy e, double flux, const string &unit)
Definition flux.h:46
double p_flux
Definition flux.h:18
bool p_ValidFluxUnit(fu_bits) const
Definition flux.cpp:99
double get() const
Definition flux.h:51
bitset< FU_TOP > fu_bits
Definition flux.h:15
bool ValidFluxUnit(const string &unit)
Definition flux.h:71
string StandardFluxUnit(const char *)
Definition flux.cpp:205