cloudy  trunk
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
atmdat.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 ATMDAT_H_
5 #define ATMDAT_H_
6 
7 #include "container_classes.h"
8 #include "module.h"
9 
10 /*This structure is specifically used to hold the collision data in the format given in the LEIDEN Database
11 The data is available as collision rate coefficients(cm3 s-1) over different temperatures*/
13 {
14 public:
15  /*Array of temps*/
16  vector<double> temps;
17  /*Matrix of collision rates(temp,up,lo)*/
19 
20 } ;
21 
22 /*This structure is specifically used to hold the collision data in the format given in the CHIANTI Database
23 The data is available as spline fits to the Maxwellian averaged collision strengths */
25 {
26 public:
27  /*Matrix of spline fits(hi,lo,spline index)*
28  *The first five columns gives the no of spline pts,transition type,gf value,delta E
29  *& Scaling parameter ,in the specified order*/
30  /*The transition type basically tells how the temperature and collision
31  strengths have been scaled*/
32  double *collspline;
33  double *SplineSecDer;
34 
35  long nSplinePts;
37  double EnergyDiff;
38  double ScalingParam;
40  collspline(NULL), SplineSecDer(NULL), EnergyDiff(0.), ScalingParam(0.) {}
42  {
43  if (collspline)
44  {
45  free(collspline);
46  collspline=NULL;
47  }
48  if (SplineSecDer)
49  {
50  free(SplineSecDer);
51  SplineSecDer=NULL;
52  }
53  }
54 };
55 
56 /*This structure is specifically used to hold the collision data in the format given in the STOUT Database
57 The data are available as collision strengths and rates over different temperatures*/
58 struct StoutColls
59 {
60 private:
62 public:
63  /*Number of temps*/
64  long ntemps()
65  {
66  return m_ntemps;
67  }
68  /*Reset values to safe defaults*/
69  void junk()
70  {
71  m_offset = -1;
72  m_ntemps = -1;
73  lgIsRate = false;
74  }
75  // Set range of tabulated data corresponding to this level & collider
76  void setslice(long offset, long ntemps)
77  {
78  m_offset = offset;
79  m_ntemps = ntemps;
80  }
81  long offset() const
82  {
83  return m_offset;
84  }
85  /*Is this a deexcitation rate or collision strength*/
86  bool lgIsRate;
87 
88 };
89 
91 {
93  vector<double> m_temps,m_collstrs;
94  static long ilev(long ipHi, long ipLo)
95  {
96  // Can use triangular arrangement, as ipHi > ipLo
97  return (ipHi*(ipHi-1))/2+ipLo;
98  }
99 public:
100  // Allocates background data structures
101  void alloc(long nHi, long , long nCollider)
102  {
103  // Size of array is first level which *isn't* required
104  m_a.alloc(ilev(nHi+1,0),nCollider);
105  m_temps.resize(0);
106  m_collstrs.resize(0);
107  }
108  // Initializes per-collision data to safe values
109  void junk(long ipHi, long ipLo, long ipCollider)
110  {
111  m_a[ilev(ipHi,ipLo)][ipCollider].junk();
112  }
113  bool& lgIsRate(long ipHi, long ipLo, long ipCollider)
114  {
115  return m_a[ilev(ipHi,ipLo)][ipCollider].lgIsRate;
116  }
117  // Reserves space for the number of table points for this level and
118  // collider
119  void setpoints(long ipHi, long ipLo, long ipCollider,long npoints)
120  {
121  long offset = m_temps.size();
122  long length = offset+npoints;
123  m_temps.resize(length);
124  m_collstrs.resize(length);
125  m_a[ilev(ipHi,ipLo)][ipCollider].setslice(offset,npoints);
126  }
127  // Returns number of table points
128  long ntemps(long ipHi, long ipLo, long ipCollider)
129  {
130  return m_a[ilev(ipHi,ipLo)][ipCollider].ntemps();
131  }
132  // Returns pointer to temperature ordinates
133  double* temps(long ipHi, long ipLo, long ipCollider)
134  {
135  return &m_temps[m_a[ilev(ipHi,ipLo)][ipCollider].offset()];
136  }
137  // Returns pointer to collision data
138  double* collstrs(long ipHi, long ipLo, long ipCollider)
139  {
140  return &m_collstrs[m_a[ilev(ipHi,ipLo)][ipCollider].offset()];
141  }
142 };
143 
147 void LoadIsotopes ( );
148 
149 
156 double atmdat_2phot_shapefunction( double EbyE2nu, long ipISO, long nelem );
157 
161 void atmdat_readin(void);
162 
168 void atmdat_STOUT_readin( long intNS, char *chFileName );
169 
175 void atmdat_CHIANTI_readin( long intNS, char *chFileName );
176 
182 void atmdat_LAMDA_readin( long intNS, char *chFileName );
183 
184 
195 void atmdat_outer_shell(
196  long int iz,
197  long int in,
198  long int *imax,
199  long int *ig0,
200  long int *ig1);
201 
205 void ChargTranEval( void );
206 
211 double ChargTranSumHeat(void);
212 
213 /*ChargTranPun save charge transfer rate coefficients */
219 void ChargTranPun( FILE* ipPnunit , char* chSave );
220 
222 double CHIANTI_Upsilon(long, long, long, long,double);
223 
229 double atmdat_dielrec_fe(long int ion, double t);
230 
233 void atmdat_H_phot_cs(void);
234 
236 void atmdat_3body(void);
237 
248 double atmdat_HS_caseB(
249  long int iHi, long int iLo, long int iZ, double TempIn,
250  double DenIn,
251  char chCase
252  );
253 
254 // arrays for Hummer & Storey 98 He1 cross sections and energies
255 extern double ****HS_He1_Xsectn;
256 extern double ****HS_He1_Energy;
257 
258 // arrays for TOPbase Helike cross sections and energies
259 extern double *****OP_Helike_Xsectn;
260 extern double *****OP_Helike_Energy;
261 extern long ****OP_Helike_NumPts;
262 
263 /* these are the vectors that store the original Hummer and Storey case B
264  * line data for H and He - the declaration for the interpolator follows */
265 #define NHSDIM 15
266 #define NLINEHS 300
267 #define HS_NZ 8
268 #define NHCSTE 8
269 #define NUM_HS98_DATA_POINTS 811
270 
271 struct t_atmdat : public module {
272  const char *chName() const
273  {
274  return "atmdat";
275  }
276  void zero();
277  void comment(t_warnings&) {}
292  enum {NCX=2};
293 
300  double CharExcIonOf[NCX][LIMELM][LIMELM+1], //(cm3 s-1)
301  CharExcRecTo[NCX][LIMELM][LIMELM+1], //(cm3 s-1)
302  HCharHeatMax,
303  HCharCoolMax,
304  HCharHeatOn;
305 
306  /* rate coefficient (cm3 s-1) for N+(3P) + H+ -> N(2D) + H+ charge transfer*/
308 
312 
314  double HIonFrac;
315 
317  double HIonFracMax;
318 
321  double HCTAlex;
322 
325  bool lgCTOn;
326 
329  double Density[2][HS_NZ][NHSDIM],
330  ElecTemp[2][HS_NZ][NHSDIM],
333 
335  long int nDensity[2][HS_NZ] , ntemp[2][HS_NZ];
337  long int ncut[2][HS_NZ];
338 
342  bool lgHCaseBOK[2][HS_NZ];
343 
345  long int nsbig;
346 
350 
356 
358  vector<realnum> CaseBWlHeI;
359 
366  const long nDefaultCollLevels;
368  const long nDefaultMolLevels;
369  // Set the constant member variables to the default values.
372 
389 
391  bool lgLamdaOn;
400 
402  bool lgStoutOn;
421  bool lgGbarOn;
422 
427 
434 
437  static const double aulThreshold;
438 
439  /* type and enum for determining what collisional ionization rate coefficient data to use.
440  * Dima: Cloudy original data from Voronov97
441  * Hybrid: Dima version scaled by the ratio of Dere07 to Dima */
442  typedef enum { DIMA, HYBRID } CollIonRC;
444 
446  static const int iVersionLength = 10;
449 
453 
455  vector<vector<long> > ipSpecIon;
456 
457  };
458 
459 extern t_atmdat atmdat;
460 
461 class Funct
462 {
463 public:
464  virtual void operator()( long&, long&, const char*, long&) = 0;
465  virtual ~Funct() = 0;
466 };
467 
468 inline Funct::~Funct() {}
469 
470 typedef Funct* FunctPtr;
471 
472 class FunctLAMDA : public Funct
473 {
474 public:
475  explicit FunctLAMDA(void) { }
476  virtual void operator()( long& ipHi, long& ipLo, const char* chLine, long& i)
477  {
478  DEBUG_ENTRY( "FunctLAMDA()" );
479  bool lgEOL;
480  long index = (long)FFmtRead( chLine, &i, strlen(chLine), &lgEOL );
481  if( index <= 0 )
482  {
483  fprintf( ioQQQ, " PROBLEM with LAMDA readin.\n");
484  cdEXIT( EXIT_FAILURE );
485  }
486  ipHi = (long)FFmtRead( chLine, &i, strlen(chLine), &lgEOL ) - 1;
487  ipLo = (long)FFmtRead( chLine, &i, strlen(chLine), &lgEOL ) - 1;
488  return;
489  }
490 private:
491 };
492 
493 #include "h2_priv.h"
494 
495 class FunctDiatoms : public Funct
496 {
497 public:
498  explicit FunctDiatoms(const diatomics& diatom) : diatom_(diatom) { }
499  virtual void operator()( long& ipHi, long& ipLo, const char* chLine, long& i)
500  {
501  diatom_.GetIndices( ipHi, ipLo, chLine, i );
502  }
503 private:
505 };
506 
507 void ReadCollisionRateTable( CollRateCoeffArray& coll_rate_table, FILE* io, FunctPtr GetIndices, long nMolLevs, long nTemps = -1, long nTrans = -1 );
508 
509 double InterpCollRate( const CollRateCoeffArray& rate_table, const long& ipHi, const long& ipLo, const double& ftemp);
510 
511 
512 /* Form a comment for a transition obtained from an external database.
513  * The comment is a sequence of the lower and upper energy level indices
514  * of the transition, as listed in the data file. */
515 inline string db_comment_tran_levels( long ipLoFile, long ipHiFile )
516 {
517  stringstream Comment;
518  Comment << ipLoFile << " " << ipHiFile;
519  return Comment.str();
520 }
521 
522 #endif /* ATMDAT_H_ */
virtual void operator()(long &ipHi, long &ipLo, const char *chLine, long &i)
Definition: atmdat.h:499
void comment(t_warnings &)
Definition: atmdat.h:277
bool lgStoutLevelsSet
Definition: atmdat.h:415
const char * chName() const
Definition: atmdat.h:272
char chLamdaFile[FILENAME_PATH_LENGTH]
Definition: atmdat.h:395
realnum WaveLengthCaseB[8][25][24]
Definition: atmdat.h:355
t_atmdat atmdat
Definition: atmdat.cpp:6
void junk()
Definition: atmdat.h:69
multi_arr< double, 3 > collrates
Definition: atmdat.h:18
double HCharHeatMax
Definition: atmdat.h:300
long ntemps(long ipHi, long ipLo, long ipCollider)
Definition: atmdat.h:128
bool lgStoutHybrid
Definition: atmdat.h:404
bool lgChiantiLevelsSet
Definition: atmdat.h:388
double HCharHeatOn
Definition: atmdat.h:300
char chStoutFile[FILENAME_PATH_LENGTH]
Definition: atmdat.h:408
#define NHSDIM
Definition: atmdat.h:265
const long nDefaultCollLevelsFe
Definition: atmdat.h:364
vector< double > m_collstrs
Definition: atmdat.h:93
double ScalingParam
Definition: atmdat.h:38
bool lgStoutOn
Definition: atmdat.h:402
double CHIANTI_Upsilon(long, long, long, long, double)
Definition: species2.cpp:884
long nStoutMaxLevelsFe
Definition: atmdat.h:410
double ChargTranSumHeat(void)
long nLamdaMaxLevels
Definition: atmdat.h:397
double HCharCoolMax
Definition: atmdat.h:300
long int ncut[2][HS_NZ]
Definition: atmdat.h:337
bool lgIsRate
Definition: atmdat.h:86
long m_ntemps
Definition: atmdat.h:61
void atmdat_STOUT_readin(long intNS, char *chFileName)
CollIonRC CIRCData
Definition: atmdat.h:443
Funct * FunctPtr
Definition: atmdat.h:470
bool lgChiantiPrint
Definition: atmdat.h:378
bool lgCollIonOn
Definition: atmdat.h:349
bool lgHCaseBOK[2][HS_NZ]
Definition: atmdat.h:342
FILE * ioQQQ
Definition: cddefines.cpp:7
long int nsbig
Definition: atmdat.h:345
bool lgGbarOn
Definition: atmdat.h:421
double HIonFracMax
Definition: atmdat.h:317
void GetIndices(long &ipHi, long &ipLo, const char *chLine, long &i) const
const diatomics & diatom_
Definition: atmdat.h:504
FunctDiatoms(const diatomics &diatom)
Definition: atmdat.h:498
char chVersion[iVersionLength]
Definition: atmdat.h:448
long int ntemp[2][HS_NZ]
Definition: atmdat.h:335
long intTranType
Definition: atmdat.h:36
#define NLINEHS
Definition: atmdat.h:266
CollIonRC
Definition: atmdat.h:442
~CollSplinesArray()
Definition: atmdat.h:41
double CharExcRecTotal[NCX]
Definition: atmdat.h:310
double CharExcIonTotal[NCX]
Definition: atmdat.h:310
virtual ~Funct()=0
Definition: atmdat.h:468
Definition: atmdat.h:461
double * SplineSecDer
Definition: atmdat.h:33
virtual void operator()(long &, long &, const char *, long &)=0
bool lgdBaseSourceExists[LIMELM][LIMELM+1]
Definition: atmdat.h:452
bool lgChiantiHybrid
Definition: atmdat.h:376
vector< double > m_temps
Definition: atmdat.h:93
long offset() const
Definition: atmdat.h:81
long int nDensity[2][HS_NZ]
Definition: atmdat.h:335
void setpoints(long ipHi, long ipLo, long ipCollider, long npoints)
Definition: atmdat.h:119
void setslice(long offset, long ntemps)
Definition: atmdat.h:76
double EnergyDiff
Definition: atmdat.h:37
bool lgLamdaPrint
Definition: atmdat.h:393
static const double aulThreshold
Definition: atmdat.h:437
bool lgChiantiOn
Definition: atmdat.h:374
char chdBaseSources[LIMELM][LIMELM+1][10]
Definition: atmdat.h:451
double * temps(long ipHi, long ipLo, long ipCollider)
Definition: atmdat.h:133
bool lgCalpgmOn
Definition: atmdat.h:419
static long ilev(long ipHi, long ipLo)
Definition: atmdat.h:94
void atmdat_H_phot_cs(void)
double **** HS_He1_Xsectn
Definition: atmdat.cpp:60
double atmdat_dielrec_fe(long int ion, double t)
char chCloudyChiantiFile[FILENAME_PATH_LENGTH]
Definition: atmdat.h:382
const long nDefaultMolLevels
Definition: atmdat.h:368
long nSplinePts
Definition: atmdat.h:35
virtual void operator()(long &ipHi, long &ipLo, const char *chLine, long &i)
Definition: atmdat.h:476
const long nDefaultPhotoLevels
Definition: atmdat.h:362
double HCharExcRecTo_N0_2D
Definition: atmdat.h:307
double InterpCollRate(const CollRateCoeffArray &rate_table, const long &ipHi, const long &ipLo, const double &ftemp)
Definition: atmdat.cpp:187
double collstrDefault
Definition: atmdat.h:426
long nStoutMaxLevels
Definition: atmdat.h:413
float realnum
Definition: cddefines.h:124
#define EXIT_FAILURE
Definition: cddefines.h:168
double ***** OP_Helike_Xsectn
Definition: atmdat.cpp:62
void zero()
Definition: atmdat.cpp:8
#define cdEXIT(FAIL)
Definition: cddefines.h:482
double Density[2][HS_NZ][NHSDIM]
Definition: atmdat.h:329
double Emiss[2][HS_NZ][NHSDIM][NHSDIM][NLINEHS]
Definition: atmdat.h:329
double atmdat_HS_caseB(long int iHi, long int iLo, long int iZ, double TempIn, double DenIn, char chCase)
long nChiantiMaxLevels
Definition: atmdat.h:386
void atmdat_outer_shell(long int iz, long int in, long int *imax, long int *ig0, long int *ig1)
bool lgUTAprint
Definition: atmdat.h:433
bool & lgIsRate(long ipHi, long ipLo, long ipCollider)
Definition: atmdat.h:113
#define HS_NZ
Definition: atmdat.h:267
CollSplinesArray(void)
Definition: atmdat.h:39
long m_offset
Definition: atmdat.h:61
const long nDefaultPhotoLevelsFe
Definition: atmdat.h:360
void ChargTranPun(FILE *ipPnunit, char *chSave)
bool lgInnerShell_Kisielius
Definition: atmdat.h:431
const int LIMELM
Definition: cddefines.h:308
string db_comment_tran_levels(long ipLoFile, long ipHiFile)
Definition: atmdat.h:515
vector< double > temps
Definition: atmdat.h:16
const long nDefaultCollLevels
Definition: atmdat.h:366
double **** HS_He1_Energy
Definition: atmdat.cpp:61
t_atmdat()
Definition: atmdat.h:370
vector< vector< long > > ipSpecIon
Definition: atmdat.h:455
void atmdat_LAMDA_readin(long intNS, char *chFileName)
#define DEBUG_ENTRY(funcname)
Definition: cddefines.h:723
double ***** OP_Helike_Energy
Definition: atmdat.cpp:63
void junk(long ipHi, long ipLo, long ipCollider)
Definition: atmdat.h:109
long **** OP_Helike_NumPts
Definition: atmdat.cpp:64
bool lgInnerShellLine_on
Definition: atmdat.h:429
double HIonFrac
Definition: atmdat.h:314
multi_arr< StoutColls, 2 > m_a
Definition: atmdat.h:92
double * collstrs(long ipHi, long ipLo, long ipCollider)
Definition: atmdat.h:138
const int FILENAME_PATH_LENGTH
Definition: cddefines.h:293
bool lgStoutPrint
Definition: atmdat.h:406
void atmdat_readin(void)
int fprintf(const Output &stream, const char *format,...)
Definition: service.cpp:1121
void atmdat_CHIANTI_readin(long intNS, char *chFileName)
bool lgCTOn
Definition: atmdat.h:325
vector< realnum > CaseBWlHeI
Definition: atmdat.h:358
double * collspline
Definition: atmdat.h:32
long ntemps()
Definition: atmdat.h:64
double HCTAlex
Definition: atmdat.h:321
void alloc(long nHi, long, long nCollider)
Definition: atmdat.h:101
bool lgLamdaOn
Definition: atmdat.h:391
void LoadIsotopes()
Definition: isotopes.cpp:9
void ChargTranEval(void)
double CharExcIonOf[NCX][LIMELM][LIMELM+1]
Definition: atmdat.h:300
void ReadCollisionRateTable(CollRateCoeffArray &coll_rate_table, FILE *io, FunctPtr GetIndices, long nMolLevs, long nTemps, long nTrans)
Definition: atmdat.cpp:66
long nChiantiMaxLevelsFe
Definition: atmdat.h:384
void atmdat_3body(void)
bool lgChiantiExp
Definition: atmdat.h:380
double CharExcRecTo[NCX][LIMELM][LIMELM+1]
Definition: atmdat.h:300
Definition: module.h:26
double atmdat_2phot_shapefunction(double EbyE2nu, long ipISO, long nelem)
FunctLAMDA(void)
Definition: atmdat.h:475
static const int iVersionLength
Definition: atmdat.h:446
bool lgLamdaLevelsSet
Definition: atmdat.h:399
double ElecTemp[2][HS_NZ][NHSDIM]
Definition: atmdat.h:329
double FFmtRead(const char *chCard, long int *ipnt, long int last, bool *lgEOL)
Definition: service.cpp:381