cloudy  trunk
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
abund.h
Go to the documentation of this file.
1 /* This file is part of Cloudy and is copyright (C)1978-2017 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 
13 void AbundancesSet(void);
14 
18 void AbundancesPrt( void );
19 
24 class Parser;
25 void abund_starburst(Parser &p);
26 
33 double AbundancesTable(double r0,
34  double depth,
35  long int iel);
36 
37 
38 
39 typedef struct isotope
40 {
41 private:
42  int Niso; /* Number of isotopes for element */
43  vector<int> Aiso;
44  vector<realnum> abnd, mass, spin, magmom;
45 
46  /* Functions to access abundances */
47  int getIsoInd (int Anum)
48  {
49  int j = -1;
50  for( int i = 0; i < Niso; i++ )
51  {
52  if( Aiso[i] == Anum )
53  {
54  j = i;
55  break;
56  }
57  }
58  return j;
59  }
60 public:
61  void init ( )
62  {
63  Niso = 0;
64  return;
65  }
66  int getNiso ( )
67  {
68  return Niso;
69  }
70  void setData (int Anum, realnum nmass, realnum nspin, realnum nmagmom)
71  {
72  Aiso.push_back( Anum );
73  abnd.push_back( realnum( 0. ) );
74  mass.push_back( nmass );
75  spin.push_back( nspin );
76  magmom.push_back( nmagmom );
77  Niso++;
78  }
79  int getAiso (int iso)
80  {
81  int Aval = -1;
82  if( iso >= 0 && iso < Niso )
83  Aval = Aiso[iso];
84  return Aval;
85  }
86  realnum getMass (int Anum)
87  {
88  realnum nmass = -1.0;
89  int j = getIsoInd( Anum );
90  if( j != -1 )
91  nmass = mass[j];
92  return nmass;
93  }
94  realnum getSpin (int Anum)
95  {
96  realnum nspin = -1.0;
97  if( spin.size() == 0 )
98  return nspin;
99  int j = getIsoInd( Anum );
100  if( j != -1 )
101  nspin = spin[j];
102  return nspin;
103  }
104  realnum getMagMom (int Anum)
105  {
106  realnum nmagmom = -1.0;
107  if( magmom.size() == 0 )
108  return nmagmom;
109  int j = getIsoInd( Anum );
110  if( j != -1 )
111  nmagmom = magmom[j];
112  return nmagmom;
113  }
114  int setAbn (int Anum, realnum abn)
115  {
116  int j = getIsoInd( Anum );
117  if( j != -1 )
118  abnd[j] = abn;
119  return j;
120  }
121  realnum getAbn (int Anum)
122  {
123  realnum abn = -1.0;
124  int j = getIsoInd( Anum );
125  if( j != -1 )
126  abn = abnd[j];
127  return abn;
128  }
129  /* Express all isotope fractions in terms of the most abundant isotope. */
130  void normAbn ( )
131  {
132  realnum fracsum = 0.;
133  for( int j = 0; j < Niso; j++ )
134  {
135  fracsum += abnd[j];
136  }
137 
138  fracsum = 1.0 / fracsum;
139  for( int j = 0; j < Niso; j++ )
140  {
141  abnd[j] *= fracsum;
142  }
143  return;
144  }
145  bool isAnyIllegal (void)
146  {
147  bool isZero = false;
148  for( int j = 0; j < Niso; j++ )
149  {
150  if( abnd[j] < 0.0 )
151  {
152  isZero = true;
153  break;
154  }
155  }
156  return isZero;
157  }
158  void prtIso (FILE *fp)
159  {
160  for( int j = 0; j < Niso; j++ )
161  {
162  fprintf(fp, "%2d", Aiso[j]);
163  if( j != Niso-1 )
164  fprintf(fp, ", ");
165  }
166  fprintf(fp, "\n");
167  return;
168  }
169  void prtIsoPairs (FILE *fp)
170  {
171  for( int j = 0; j < Niso; j++ )
172  {
173  fprintf(fp, " (%2d, %.4e)", Aiso[j], abnd[j]);
174  }
175  fprintf(fp, "\n");
176  return;
177  }
178  void rm_nuc_data ( )
179  {
180  spin.resize( 0 );
181  magmom.resize( 0 );
182  return;
183  }
184 } t_isotope;
185 
186 
187 
189 struct t_abund : public module {
190  const char *chName() const
191  {
192  return "abund";
193  }
194 
195  void zero();
196  void comment(t_warnings&) {}
198  bool lgAGN[LIMELM];
199 
201 
203 
208 
211 
212  /* isotope fractions */
214 
219 
222 
224  lgAbTaON;
225 
226 # define LIMTABD 500
227 
230 
234 
235  long int nAbunTabl;
236 
238  long int ipSolar[LIMELM],
239  npSolar;
240 
243 
246 
248  depset[LIMELM];
249 
251  bool lgDepln;
252 
255 
256  };
257 extern t_abund abund;
258 
259 
260 
261 #endif /* ABUND_H_ */
bool lgAGN[LIMELM]
Definition: abund.h:198
void comment(t_warnings &)
Definition: abund.h:196
realnum getMass(int Anum)
Definition: abund.h:86
long int nAbunTabl
Definition: abund.h:235
realnum depset[LIMELM]
Definition: abund.h:245
realnum AbTabFac[LIMTABD][LIMELM]
Definition: abund.h:229
void AbundancesSet(void)
Definition: abundances.cpp:145
realnum Depletion[LIMELM]
Definition: abund.h:245
bool isAnyIllegal(void)
Definition: abund.h:145
void rm_nuc_data()
Definition: abund.h:178
realnum SolarSave[LIMELM]
Definition: abund.h:200
Definition: parser.h:42
void normAbn()
Definition: abund.h:130
int Niso
Definition: abund.h:42
int getAiso(int iso)
Definition: abund.h:79
bool lgAbnSolar
Definition: abund.h:202
t_abund abund
Definition: abund.cpp:5
t_isotope IsoAbn[LIMELM]
Definition: abund.h:213
realnum ScaleMetals
Definition: abund.h:254
void AbundancesPrt(void)
Definition: abundances.cpp:31
bool lgAbTaDepth[LIMELM]
Definition: abund.h:218
realnum getMagMom(int Anum)
Definition: abund.h:104
realnum getSpin(int Anum)
Definition: abund.h:94
vector< realnum > mass
Definition: abund.h:44
int getNiso()
Definition: abund.h:66
float realnum
Definition: cddefines.h:124
const char * chName() const
Definition: abund.h:190
double AbundancesTable(double r0, double depth, long int iel)
Definition: abundances.cpp:464
realnum AbTabRad[LIMTABD][LIMELM]
Definition: abund.h:229
#define LIMTABD
Definition: abund.h:226
long int ipSolar[LIMELM]
Definition: abund.h:238
void zero()
Definition: abund.cpp:7
realnum getAbn(int Anum)
Definition: abund.h:121
Definition: abund.h:39
bool lgAbTaON
Definition: abund.h:218
const int LIMELM
Definition: cddefines.h:307
vector< realnum > abnd
Definition: abund.h:44
bool lgDepln
Definition: abund.h:251
long int npSolar
Definition: abund.h:238
void init()
Definition: abund.h:61
void prtIso(FILE *fp)
Definition: abund.h:158
vector< realnum > magmom
Definition: abund.h:44
int fprintf(const Output &stream, const char *format,...)
Definition: service.cpp:1217
void abund_starburst(Parser &p)
Definition: abund.h:189
vector< realnum > spin
Definition: abund.h:44
struct isotope t_isotope
void setData(int Anum, realnum nmass, realnum nspin, realnum nmagmom)
Definition: abund.h:70
realnum ScaleElement[LIMELM]
Definition: abund.h:242
int setAbn(int Anum, realnum abn)
Definition: abund.h:114
bool lgAbundancesSet
Definition: abund.h:207
void prtIsoPairs(FILE *fp)
Definition: abund.h:169
Definition: module.h:26
int getIsoInd(int Anum)
Definition: abund.h:47
bool lgAbunTabl[LIMELM]
Definition: abund.h:218
vector< int > Aiso
Definition: abund.h:43
realnum solar[LIMELM]
Definition: abund.h:210