cloudy  trunk
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
energy.h
Go to the documentation of this file.
1 /* This file is part of Cloudy and is copyright (C)1978-2022 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 
9 class Energy
10 {
11  double m_energy;
12 public:
13  // CONSTRUCTORS
14  Energy () : m_energy(0.0) {}
15  Energy (double energy) : m_energy(energy) {}
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  {
28  m_energy = energy;
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  double Angstrom() const
78  {
79  return RYDLAM/m_energy;
80  }
81  double nm() const
82  {
83  return Angstrom()*1e-1;
84  }
85  double micron() const
86  {
87  return Angstrom()*1e-4;
88  }
89  double mm() const
90  {
91  return Angstrom()*1e-7;
92  }
93  double cm() const
94  {
95  return Angstrom()*1e-8;
96  }
97 };
98 
99 //
104 //
105 class EnergyEntry : public Energy
106 {
107  long p_ip;
108  void p_set_ip();
109 public:
111  {
112  p_ip = -1;
113  }
114  EnergyEntry(double energy) : Energy(energy)
115  {
116  p_ip = -1;
117  }
118  EnergyEntry(double energy, const char *unit) : Energy(energy,unit)
119  {
120  p_ip = -1;
121  }
122  void set(double energy, const char *unit)
123  {
124  Energy::set(energy,unit);
125  p_set_ip();
126  }
127  void set(double energy)
128  {
129  Energy::set(energy);
130  p_set_ip();
131  }
132  // pointer on C scale
133  long ip_C()
134  {
135  // doing it this way assures that we can create an EnergyEntry before
136  // the mesh is set up; ipoint() will check that mesh is actually set up
137  if( p_ip < 0 )
138  p_set_ip();
139  return p_ip;
140  }
141  // pointer on fortran scale
142  long ip_fortran()
143  {
144  return ip_C() + 1;
145  }
146 };
147 
148 const char *StandardEnergyUnit(const char *);
149 
150 bool lgConserveEnergy( void );
151 
152 #endif /* ENERGY_H_ */
153 
double Hz() const
Definition: energy.h:61
double Angstrom() const
Definition: energy.h:77
long p_ip
Definition: energy.h:107
Energy()
Definition: energy.h:14
double GHz() const
Definition: energy.h:73
void set(double energy)
Definition: energy.h:26
double keV() const
Definition: energy.h:53
EnergyEntry(double energy, const char *unit)
Definition: energy.h:118
Definition: energy.h:105
EnergyEntry()
Definition: energy.h:110
double cm() const
Definition: energy.h:93
double WN() const
Definition: energy.h:45
double Erg() const
Definition: energy.h:41
double energy(const genericState &gs)
void set(double energy, const char *unit)
Definition: energy.h:122
bool lgConserveEnergy()
Definition: energy.cpp:311
Energy(double energy)
Definition: energy.h:15
long ip_fortran()
Definition: energy.h:142
double MeV() const
Definition: energy.h:57
void set(double energy)
Definition: energy.h:127
Energy(double energy, const char *unit)
Definition: energy.h:16
double m_energy
Definition: energy.h:11
void p_set_ip()
Definition: energy.cpp:290
double nm() const
Definition: energy.h:81
double K() const
Definition: energy.h:37
bool operator<(const Energy &e) const
Definition: energy.h:21
double eV() const
Definition: energy.h:49
EnergyEntry(double energy)
Definition: energy.h:114
double kHz() const
Definition: energy.h:65
const char * StandardEnergyUnit(const char *chCard)
Definition: energy.cpp:44
double Ryd() const
Definition: energy.h:33
Definition: energy.h:9
double mm() const
Definition: energy.h:89
double micron() const
Definition: energy.h:85
long ip_C()
Definition: energy.h:133
double MHz() const
Definition: energy.h:69