Cloudy
Spectral Synthesis Code for Astrophysics
Loading...
Searching...
No Matches
energy.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 ENERGY_H_
5#define ENERGY_H_
6
7#include "physconst.h"
8
9class Energy
10{
11 double m_energy;
12public:
13 // CONSTRUCTORS
14 Energy () : m_energy(0.0) {}
16 Energy (double energy, const char *unit) : m_energy(0.0)
17 {
18 set(energy, unit);
19 }
20 // OPERATORS
21 bool operator< (const Energy& e) const
22 {
23 return ( m_energy < e.m_energy );
24 }
25 // MUTATORS
26 void set(double energy)
27 {
29 }
30 void set(double energy, const char *unit);
31 // ACCESSORS
32 double get(const char * unit) const;
33 double Ryd() const
34 {
35 return m_energy;
36 }
37 double K() const
38 {
39 return m_energy*TE1RYD;
40 }
41 double Erg() const
42 {
43 return m_energy*EN1RYD;
44 }
45 double WN() const
46 {
47 return m_energy*RYD_INF;
48 }
49 double eV() const
50 {
51 return m_energy*EVRYD;
52 }
53 double keV() const
54 {
55 return 1e-3*eV();
56 }
57 double MeV() const
58 {
59 return 1e-6*eV();
60 }
61 double Hz() const
62 {
63 return m_energy*FR1RYD;
64 }
65 double kHz() const
66 {
67 return Hz()*1e-3;
68 }
69 double MHz() const
70 {
71 return Hz()*1e-6;
72 }
73 double GHz() const
74 {
75 return Hz()*1e-9;
76 }
77 // all remaining methods return vacuum wavelengths
78 double angstromVac() const
79 {
80 return RYDLAM/m_energy;
81 }
82 double nmVac() const
83 {
84 return angstromVac()*1e-1;
85 }
86 double micronVac() const
87 {
88 return angstromVac()*1e-4;
89 }
90 double mmVac() const
91 {
92 return angstromVac()*1e-7;
93 }
94 double cmVac() const
95 {
96 return angstromVac()*1e-8;
97 }
98};
99
100//
105//
106class EnergyEntry : public Energy
107{
108 long p_ip;
109 void p_set_ip();
110public:
112 {
113 p_ip = -1;
114 }
116 {
117 p_ip = -1;
118 }
119 EnergyEntry(double energy, const char *unit) : Energy(energy,unit)
120 {
121 p_ip = -1;
122 }
123 void set(double energy, const char *unit)
124 {
125 Energy::set(energy,unit);
126 p_set_ip();
127 }
128 void set(double energy)
129 {
131 p_set_ip();
132 }
133 // pointer on C scale
134 long ip_C()
135 {
136 // doing it this way assures that we can create an EnergyEntry before
137 // the mesh is set up; ipoint() will check that mesh is actually set up
138 if( p_ip < 0 )
139 p_set_ip();
140 return p_ip;
141 }
142 // pointer on fortran scale
144 {
145 return ip_C() + 1;
146 }
147};
148
149const char *StandardEnergyUnitNoAbort(const char *chCard);
150
151inline const char *StandardEnergyUnit(const char *chCard)
152{
153 const char *unit = StandardEnergyUnitNoAbort(chCard);
154 if( unit == nullptr )
155 {
156 fprintf( ioQQQ, " No energy / wavelength unit was recognized on this line:\n %s\n\n", chCard );
157 fprintf( ioQQQ, " See Hazy for details.\n" );
159 }
160 return unit;
161}
162
163void ConserveEnergy();
164
165#endif /* ENERGY_H_ */
166
FILE * ioQQQ
Definition cddefines.cpp:9
#define EXIT_FAILURE
Definition cddefines.h:175
#define cdEXIT(FAIL)
Definition cddefines.h:480
int fprintf(const Output &stream, const char *format,...)
Definition service.cpp:1325
long ip_fortran()
Definition energy.h:143
void set(double energy)
Definition energy.h:128
long ip_C()
Definition energy.h:134
void set(double energy, const char *unit)
Definition energy.h:123
void p_set_ip()
Definition energy.cpp:289
EnergyEntry(double energy, const char *unit)
Definition energy.h:119
EnergyEntry()
Definition energy.h:111
EnergyEntry(double energy)
Definition energy.h:115
long p_ip
Definition energy.h:108
double micronVac() const
Definition energy.h:86
double GHz() const
Definition energy.h:73
double MHz() const
Definition energy.h:69
double MeV() const
Definition energy.h:57
double get(const char *unit) const
Definition energy.cpp:137
double Ryd() const
Definition energy.h:33
double mmVac() const
Definition energy.h:90
double WN() const
Definition energy.h:45
double nmVac() const
Definition energy.h:82
double Hz() const
Definition energy.h:61
double kHz() const
Definition energy.h:65
double keV() const
Definition energy.h:53
double angstromVac() const
Definition energy.h:78
double cmVac() const
Definition energy.h:94
bool operator<(const Energy &e) const
Definition energy.h:21
Energy(double energy, const char *unit)
Definition energy.h:16
Energy(double energy)
Definition energy.h:15
double K() const
Definition energy.h:37
Energy()
Definition energy.h:14
double Erg() const
Definition energy.h:41
void set(double energy)
Definition energy.h:26
double eV() const
Definition energy.h:49
double m_energy
Definition energy.h:11
const char * StandardEnergyUnitNoAbort(const char *chCard)
Definition energy.cpp:44
const char * StandardEnergyUnit(const char *chCard)
Definition energy.h:151
void ConserveEnergy()
Definition energy.cpp:310
double energy(const genericState &gs)
Definition generic_state.cpp:51