Cloudy
Spectral Synthesis Code for Astrophysics
Loading...
Searching...
No Matches
abund.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
5#ifndef ABUND_H_
6#define ABUND_H_
7
8#include "module.h"
9#include "depth_table.h"
10
14void AbundancesSet(void);
15
19void AbundancesPrt( void );
20
25class Parser;
26void abund_starburst(Parser &p);
27
28
29typedef struct isotope
30{
31private:
32 int Niso; /* Number of isotopes for element */
33 vector<int> Aiso;
34 vector<realnum> abnd, mass, spin, magmom;
35
36 /* Functions to access abundances */
37 int getIsoInd (int Anum)
38 {
39 int j = -1;
40 for( int i = 0; i < Niso; i++ )
41 {
42 if( Aiso[i] == Anum )
43 {
44 j = i;
45 break;
46 }
47 }
48 return j;
49 }
50public:
51 void init ( )
52 {
53 Niso = 0;
54 return;
55 }
56 int getNiso ( )
57 {
58 return Niso;
59 }
60 void setData (int Anum, realnum nmass, realnum nspin, realnum nmagmom)
61 {
62 Aiso.push_back( Anum );
63 abnd.push_back( realnum( 0. ) );
64 mass.push_back( nmass );
65 spin.push_back( nspin );
66 magmom.push_back( nmagmom );
67 Niso++;
68 }
69 int getAiso (int iso)
70 {
71 int Aval = -1;
72 if( iso >= 0 && iso < Niso )
73 Aval = Aiso[iso];
74 return Aval;
75 }
76 realnum getMass (int Anum)
77 {
78 realnum nmass = -1.0;
79 int j = getIsoInd( Anum );
80 if( j != -1 )
81 nmass = mass[j];
82 return nmass;
83 }
84 realnum getSpin (int Anum)
85 {
86 realnum nspin = -1.0;
87 if( spin.size() == 0 )
88 return nspin;
89 int j = getIsoInd( Anum );
90 if( j != -1 )
91 nspin = spin[j];
92 return nspin;
93 }
94 realnum getMagMom (int Anum)
95 {
96 realnum nmagmom = -1.0;
97 if( magmom.size() == 0 )
98 return nmagmom;
99 int j = getIsoInd( Anum );
100 if( j != -1 )
101 nmagmom = magmom[j];
102 return nmagmom;
103 }
104 int setAbn (int Anum, realnum abn)
105 {
106 int j = getIsoInd( Anum );
107 if( j != -1 )
108 abnd[j] = abn;
109 return j;
110 }
111 realnum getAbn (int Anum)
112 {
113 realnum abn = -1.0;
114 int j = getIsoInd( Anum );
115 if( j != -1 )
116 abn = abnd[j];
117 return abn;
118 }
119 /* Express all isotope fractions in terms of the most abundant isotope. */
120 void normAbn ( )
121 {
122 realnum fracsum = 0.;
123 for( int j = 0; j < Niso; j++ )
124 {
125 fracsum += abnd[j];
126 }
127
128 fracsum = 1.0 / fracsum;
129 for( int j = 0; j < Niso; j++ )
130 {
131 abnd[j] *= fracsum;
132 }
133 return;
134 }
135 bool isAnyIllegal (void)
136 {
137 bool isZero = false;
138 for( int j = 0; j < Niso; j++ )
139 {
140 if( abnd[j] < 0.0 )
141 {
142 isZero = true;
143 break;
144 }
145 }
146 return isZero;
147 }
148 void prtIso (FILE *fp)
149 {
150 for( int j = 0; j < Niso; j++ )
151 {
152 fprintf(fp, "%2d", Aiso[j]);
153 if( j != Niso-1 )
154 fprintf(fp, ", ");
155 }
156 fprintf(fp, "\n");
157 return;
158 }
159 void prtIsoPairs (FILE *fp)
160 {
161 for( int j = 0; j < Niso; j++ )
162 {
163 fprintf(fp, " (%2d, %.4e)", Aiso[j], abnd[j]);
164 }
165 fprintf(fp, "\n");
166 return;
167 }
168 void rm_nuc_data ( )
169 {
170 spin.resize( 0 );
171 magmom.resize( 0 );
172 return;
173 }
175
176
177
179struct t_abund : public module {
180 const char *chName() const
181 {
182 return "abund";
183 }
184
185 void zero();
189
192
197
200
203
206
207 /* isotope fractions */
209
213
216
219
222
225
228
230 double SumDepletedAtoms();
231 };
232extern t_abund abund;
233
234
235
236#endif /* ABUND_H_ */
t_abund abund
Definition abund.cpp:5
struct isotope t_isotope
void AbundancesSet(void)
Definition abundances.cpp:163
void AbundancesPrt(void)
Definition abundances.cpp:30
void abund_starburst(Parser &p)
Definition abund_starburst.cpp:11
const int LIMELM
Definition cddefines.h:318
float realnum
Definition cddefines.h:127
int fprintf(const Output &stream, const char *format,...)
Definition service.cpp:1325
Definition depth_table.h:8
Definition parser.h:43
module()
Definition module.h:29
Definition warnings.h:11
Definition abund.h:30
vector< realnum > magmom
Definition abund.h:34
realnum getSpin(int Anum)
Definition abund.h:84
void prtIsoPairs(FILE *fp)
Definition abund.h:159
realnum getMass(int Anum)
Definition abund.h:76
int getNiso()
Definition abund.h:56
vector< int > Aiso
Definition abund.h:33
realnum getMagMom(int Anum)
Definition abund.h:94
void normAbn()
Definition abund.h:120
int getIsoInd(int Anum)
Definition abund.h:37
vector< realnum > spin
Definition abund.h:34
int getAiso(int iso)
Definition abund.h:69
void setData(int Anum, realnum nmass, realnum nspin, realnum nmagmom)
Definition abund.h:60
bool isAnyIllegal(void)
Definition abund.h:135
int Niso
Definition abund.h:32
void init()
Definition abund.h:51
void rm_nuc_data()
Definition abund.h:168
void prtIso(FILE *fp)
Definition abund.h:148
vector< realnum > mass
Definition abund.h:34
int setAbn(int Anum, realnum abn)
Definition abund.h:104
vector< realnum > abnd
Definition abund.h:34
realnum getAbn(int Anum)
Definition abund.h:111
Definition abund.h:179
realnum GasPhase[LIMELM]
Definition abund.h:202
bool lgAGN[LIMELM]
Definition abund.h:188
realnum ReferenceAbun[LIMELM]
Definition abund.h:199
void comment(t_warnings &)
Definition abund.h:186
const char * chName() const
Definition abund.h:180
bool lgDepln
Definition abund.h:224
DepthTable AbunTab[LIMELM]
Definition abund.h:215
bool lgAbnReference
Definition abund.h:191
bool lgAbTaON
Definition abund.h:212
void zero()
Definition abund.cpp:7
realnum ScaleElement[LIMELM]
Definition abund.h:218
t_isotope IsoAbn[LIMELM]
Definition abund.h:208
bool lgAbundancesSet
Definition abund.h:196
double SumDepletedAtoms()
Definition abund.cpp:20
realnum AtomsDepleted
Definition abund.h:205
realnum DepletionScaleFactor[LIMELM]
Definition abund.h:221
realnum ScaleMetals
Definition abund.h:227