Cloudy
Spectral Synthesis Code for Astrophysics
Loading...
Searching...
No Matches
atmdat.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 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
11The data is available as collision rate coefficients(cm3 s-1) over different temperatures*/
13{
14public:
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
23The data is available as spline fits to the Maxwellian averaged collision strengths */
25{
26public:
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 vector<double> collspline;
33 vector<double> SplineSecDer;
34
35 long nSplinePts = 0L;
36 long intTranType = 0L;
37 double EnergyDiff;
40};
41
42/*This structure is specifically used to hold the collision data in the format given in the STOUT Database
43The data are available as collision strengths and rates over different temperatures*/
45{
46private:
48public:
49 /*Number of temps*/
50 long ntemps()
51 {
52 return m_ntemps;
53 }
54 /*Reset values to safe defaults*/
55 void junk()
56 {
57 m_offset = -1;
58 m_ntemps = -1;
59 lgIsRate = false;
60 }
61 // Set range of tabulated data corresponding to this level & collider
62 void setslice(long offset, long ntemps)
63 {
66 }
67 long offset() const
68 {
69 return m_offset;
70 }
71 /*Is this a deexcitation rate or collision strength*/
73
74};
75
77{
79 vector<double> m_temps,m_collstrs;
80 static long ilev(long ipHi, long ipLo)
81 {
82 // Can use triangular arrangement, as ipHi > ipLo
83 return (ipHi*(ipHi-1))/2+ipLo;
84 }
85public:
86 // Allocates background data structures
87 void alloc(long nHi, long , long nCollider)
88 {
89 // Size of array is first level which *isn't* required
90 m_a.alloc(ilev(nHi+1,0),nCollider);
91 m_temps.resize(0);
92 m_collstrs.resize(0);
93 }
94 // Initializes per-collision data to safe values
95 void junk(long ipHi, long ipLo, long ipCollider)
96 {
97 m_a[ilev(ipHi,ipLo)][ipCollider].junk();
98 }
99 bool& lgIsRate(long ipHi, long ipLo, long ipCollider)
100 {
101 return m_a[ilev(ipHi,ipLo)][ipCollider].lgIsRate;
102 }
103 // Reserves space for the number of table points for this level and
104 // collider
105 void setpoints(long ipHi, long ipLo, long ipCollider,long npoints)
106 {
107 long offset = m_temps.size();
108 long length = offset+npoints;
109 // testing shows that 1200 is a reasonable initial guess for the size
110 m_temps.resize(max(length,1200));
111 m_collstrs.resize(max(length,1200));
112 m_a[ilev(ipHi,ipLo)][ipCollider].setslice(offset,npoints);
113 }
114 // Returns number of table points
115 long ntemps(long ipHi, long ipLo, long ipCollider)
116 {
117 return m_a[ilev(ipHi,ipLo)][ipCollider].ntemps();
118 }
119 // Returns pointer to temperature ordinates
120 double* temps(long ipHi, long ipLo, long ipCollider)
121 {
122 return &m_temps[m_a[ilev(ipHi,ipLo)][ipCollider].offset()];
123 }
124 // Returns pointer to collision data
125 double* collstrs(long ipHi, long ipLo, long ipCollider)
126 {
127 return &m_collstrs[m_a[ilev(ipHi,ipLo)][ipCollider].offset()];
128 }
129};
130
134void LoadIsotopes ( );
135
136
143double atmdat_2phot_shapefunction( double EbyE2nu, long ipISO, long nelem );
144
148void atmdat_readin(void);
149
155void atmdat_STOUT_readin( long intNS, const string& chFileName );
156
162void atmdat_CHIANTI_readin( long intNS, const string& chFileName );
163
169void atmdat_LAMDA_readin( long intNS, const string& chFileName );
170
171
183 long int iz,
184 long int in,
185 long int *imax,
186 long int *ig0,
187 long int *ig1);
188
192void ChargTranEval( void );
193
198double ChargTranSumHeat(void);
199
200/*ChargTranPun save charge transfer rate coefficients */
206void ChargTranPun( FILE* ipPnunit , char* chSave );
207
209double CHIANTI_Upsilon(long, long, long, long,double);
210
216double atmdat_dielrec_fe(long int ion, double t);
217
221
223void atmdat_3body(void);
224
235double atmdat_HS_caseB(
236 long int iHi, long int iLo, long int iZ, double TempIn,
237 double DenIn,
238 char chCase
239 );
240
241// arrays for Hummer & Storey 98 He1 cross sections and energies
244
245// arrays for TOPbase Helike cross sections and energies
249
250/* these are the vectors that store the original Hummer and Storey case B
251 * line data for H and He - the declaration for the interpolator follows */
252#define NHSDIM 15
253#define NLINEHS 300
254#define HS_NZ 8
255#define NHCSTE 8
256#define NUM_HS98_DATA_POINTS 811
257
258struct t_atmdat : public module {
259 const char *chName() const
260 {
261 return "atmdat";
262 }
263 void zero();
278
279 enum {NCX=2};
280
283
290 inline double getIonPot( long int nelem, long int ion )
291 {
292 return EIonPot[nelem][ion];
293 }
294
301 double CharExcIonOf[NCX][LIMELM][LIMELM+1], //(cm3 s-1)
302 CharExcRecTo[NCX][LIMELM][LIMELM+1], //(cm3 s-1)
306
307 /* rate coefficient (cm3 s-1) for N+(3P) + H+ -> N(2D) + H+ charge transfer*/
309
313
315 double HIonFrac;
316
319
322 double HCTAlex;
323
326 bool lgCTOn;
327
330 double Density[2][HS_NZ][NHSDIM],
334
336 long int nDensity[2][HS_NZ] , ntemp[2][HS_NZ];
338 long int ncut[2][HS_NZ];
339
344
346 long int nsbig;
347
351
357
359 vector<t_wavl> CaseBWlHeI;
360
370 // Set the constant member variables to the default values.
371
388
399
416
421
426
433
436 static const double aulThreshold;
437
438 /* type and enum for determining what collisional ionization rate coefficient data to use.
439 * Dima: Cloudy original data from Voronov97
440 * Hybrid: Dima version scaled by the ratio of Dere07 to Dima */
441 typedef enum { DIMA, HYBRID } CollIonRC;
443
445 string chVersion;
446
451
454
457 {
458 //set all sources to blank and false.
459 //Sources will be added from masterlist files in species.cpp
460 for( int nelem=ipHYDROGEN; nelem < LIMELM; ++nelem )
461 {
462 for( int ion=0; ion < nelem+2; ++ion )
463 {
464 strcpy(chdBaseSources[nelem][ion]," ");
465 lgdBaseSourceExists[nelem][ion] = false;
466 }
467 }
468
470 ipSpecIon.alloc(LIMELM,LIMELM);
471 ipSpecIon = -1;
472 }
473};
474
475extern t_atmdat atmdat;
476
477class Funct
478{
479public:
480 virtual void operator()( long&, long&, const char*, long&) = 0;
481 virtual ~Funct() = 0;
482};
483
484inline Funct::~Funct() {}
485
487
488class FunctLAMDA : public Funct
489{
490public:
491 explicit FunctLAMDA(void) { }
492 virtual void operator()( long& ipHi, long& ipLo, const char* chLine, long& i)
493 {
494 DEBUG_ENTRY( "FunctLAMDA()" );
495 bool lgEOL;
496 long index = (long)FFmtRead( chLine, &i, strlen(chLine), &lgEOL );
497 if( index <= 0 )
498 {
499 fprintf( ioQQQ, " PROBLEM with LAMDA readin.\n");
501 }
502 ipHi = (long)FFmtRead( chLine, &i, strlen(chLine), &lgEOL ) - 1;
503 ipLo = (long)FFmtRead( chLine, &i, strlen(chLine), &lgEOL ) - 1;
504 return;
505 }
506private:
507};
508
509#include "h2_priv.h"
510
511class FunctDiatoms : public Funct
512{
513public:
514 explicit FunctDiatoms(const diatomics& diatom) : diatom_(diatom) { }
515 virtual void operator()( long& ipHi, long& ipLo, const char* chLine, long& i)
516 {
517 diatom_.GetIndices( ipHi, ipLo, chLine, i );
518 }
519private:
521};
522
523void ReadCollisionRateTable( CollRateCoeffArray& coll_rate_table, FILE* io, FunctPtr GetIndices, long nMolLevs, long nTemps = -1, long nTrans = -1 );
524
525double InterpCollRate( const CollRateCoeffArray& rate_table, const long& ipHi, const long& ipLo, const double& ftemp);
526
527
528/* Form a comment for a transition obtained from an external database.
529 * The comment is the configuration of the lower and upper level */
530inline string db_comment_tran_levels(const string& clo = "", const string& chi = "")
531{
532 stringstream Comment;
533 if( clo.length() > 0 && chi.length() > 0 )
534 Comment << clo << " -- " << chi;
535 return Comment.str();
536}
537
538#endif /* ATMDAT_H_ */
multi_arr< long, 4 > OP_Helike_NumPts
Definition atmdat.cpp:65
multi_arr< vector< double >, 4 > OP_Helike_Xsectn
Definition atmdat.cpp:63
multi_arr< double, 4 > HS_He1_Xsectn
Definition atmdat.cpp:61
t_atmdat atmdat
Definition atmdat.cpp:7
multi_arr< vector< double >, 4 > OP_Helike_Energy
Definition atmdat.cpp:64
multi_arr< double, 4 > HS_He1_Energy
Definition atmdat.cpp:62
void atmdat_readin(void)
Definition atmdat_readin.cpp:80
void atmdat_outer_shell(long int iz, long int in, long int *imax, long int *ig0, long int *ig1)
Definition atmdat_outer_shell.cpp:8
double InterpCollRate(const CollRateCoeffArray &rate_table, const long &ipHi, const long &ipLo, const double &ftemp)
Definition atmdat.cpp:188
double ChargTranSumHeat(void)
Definition atmdat_char_tran.cpp:569
void ReadCollisionRateTable(CollRateCoeffArray &coll_rate_table, FILE *io, FunctPtr GetIndices, long nMolLevs, long nTemps=-1, long nTrans=-1)
Definition atmdat.cpp:67
#define NLINEHS
Definition atmdat.h:253
void atmdat_STOUT_readin(long intNS, const string &chFileName)
Definition atmdat_chianti.cpp:107
double atmdat_dielrec_fe(long int ion, double t)
Definition atmdat_dielrec_fe.cpp:8
void ChargTranPun(FILE *ipPnunit, char *chSave)
Definition atmdat_char_tran.cpp:945
void ChargTranEval(void)
Definition atmdat_char_tran.cpp:44
double atmdat_2phot_shapefunction(double EbyE2nu, long ipISO, long nelem)
Definition atmdat_2photon.cpp:230
string db_comment_tran_levels(const string &clo="", const string &chi="")
Definition atmdat.h:530
#define NHSDIM
Definition atmdat.h:252
double atmdat_HS_caseB(long int iHi, long int iLo, long int iZ, double TempIn, double DenIn, char chCase)
Definition atmdat_HS_caseb.cpp:7
void atmdat_3body(void)
Definition atmdat_3body.cpp:52
#define HS_NZ
Definition atmdat.h:254
void atmdat_CHIANTI_readin(long intNS, const string &chFileName)
Definition atmdat_chianti.cpp:669
Funct * FunctPtr
Definition atmdat.h:486
double CHIANTI_Upsilon(long, long, long, long, double)
Definition species2.cpp:869
void atmdat_H_phot_cs(void)
void LoadIsotopes()
Definition isotopes.cpp:9
void atmdat_LAMDA_readin(long intNS, const string &chFileName)
Definition atmdat_lamda.cpp:28
FILE * ioQQQ
Definition cddefines.cpp:9
const int FILENAME_PATH_LENGTH
Definition cddefines.h:303
const int LIMELM
Definition cddefines.h:318
#define EXIT_FAILURE
Definition cddefines.h:175
double FFmtRead(const char *chCard, long int *ipnt, long int last, bool *lgEOL)
Definition service.cpp:393
#define cdEXIT(FAIL)
Definition cddefines.h:480
int fprintf(const Output &stream, const char *format,...)
Definition service.cpp:1325
long max(int a, long b)
Definition cddefines.h:821
const int ipHYDROGEN
Definition cddefines.h:359
#define DEBUG_ENTRY(funcname)
Definition cddefines.h:730
Definition atmdat.h:13
multi_arr< double, 3 > collrates
Definition atmdat.h:18
vector< double > temps
Definition atmdat.h:16
CollSplinesArray()
Definition atmdat.h:39
vector< double > SplineSecDer
Definition atmdat.h:33
long intTranType
Definition atmdat.h:36
double EnergyDiff
Definition atmdat.h:37
double ScalingParam
Definition atmdat.h:38
long nSplinePts
Definition atmdat.h:35
vector< double > collspline
Definition atmdat.h:32
const diatomics & diatom_
Definition atmdat.h:520
virtual void operator()(long &ipHi, long &ipLo, const char *chLine, long &i)
Definition atmdat.h:515
FunctDiatoms(const diatomics &diatom)
Definition atmdat.h:514
Definition atmdat.h:478
virtual ~Funct()=0
Definition atmdat.h:484
virtual void operator()(long &, long &, const char *, long &)=0
virtual void operator()(long &ipHi, long &ipLo, const char *chLine, long &i)
Definition atmdat.h:492
FunctLAMDA(void)
Definition atmdat.h:491
Definition atmdat.h:77
void alloc(long nHi, long, long nCollider)
Definition atmdat.h:87
void junk(long ipHi, long ipLo, long ipCollider)
Definition atmdat.h:95
void setpoints(long ipHi, long ipLo, long ipCollider, long npoints)
Definition atmdat.h:105
multi_arr< StoutColls, 2 > m_a
Definition atmdat.h:78
bool & lgIsRate(long ipHi, long ipLo, long ipCollider)
Definition atmdat.h:99
vector< double > m_temps
Definition atmdat.h:79
long ntemps(long ipHi, long ipLo, long ipCollider)
Definition atmdat.h:115
static long ilev(long ipHi, long ipLo)
Definition atmdat.h:80
vector< double > m_collstrs
Definition atmdat.h:79
double * temps(long ipHi, long ipLo, long ipCollider)
Definition atmdat.h:120
double * collstrs(long ipHi, long ipLo, long ipCollider)
Definition atmdat.h:125
Definition h2_priv.h:74
module()
Definition module.h:29
Definition container_classes.h:916
Definition warnings.h:11
Definition cddefines.h:1299
Definition atmdat.h:45
long offset() const
Definition atmdat.h:67
long ntemps()
Definition atmdat.h:50
bool lgIsRate
Definition atmdat.h:72
void setslice(long offset, long ntemps)
Definition atmdat.h:62
long m_ntemps
Definition atmdat.h:47
long m_offset
Definition atmdat.h:47
void junk()
Definition atmdat.h:55
Definition atmdat.h:258
const long nDefaultCollLevels
Definition atmdat.h:367
const long nDefaultCollLevelsFe
Definition atmdat.h:365
const char * chName() const
Definition atmdat.h:259
const long nDefaultPhotoLevels
Definition atmdat.h:363
bool lgCTOn
Definition atmdat.h:326
char chLamdaFile[FILENAME_PATH_LENGTH]
Definition atmdat.h:394
long nChiantiMaxLevels
Definition atmdat.h:385
bool lgHCaseBOK[2][HS_NZ]
Definition atmdat.h:343
vector< t_wavl > CaseBWlHeI
Definition atmdat.h:359
bool lgLamdaPrint
Definition atmdat.h:392
long nLamdaMaxLevels
Definition atmdat.h:396
double ElecTemp[2][HS_NZ][NHSDIM]
Definition atmdat.h:331
bool lgStoutLvl2Hybrid
Definition atmdat.h:403
double CharExcRecTo[NCX][LIMELM][LIMELM+1]
Definition atmdat.h:302
double getIonPot(long int nelem, long int ion)
Definition atmdat.h:290
long nChiantiMaxLevelsFe
Definition atmdat.h:383
long int nDensity[2][HS_NZ]
Definition atmdat.h:336
const long nDefaultMolLevels
Definition atmdat.h:369
bool lgLamdaOn
Definition atmdat.h:390
string chVersion
Definition atmdat.h:445
double CharExcIonOf[NCX][LIMELM][LIMELM+1]
Definition atmdat.h:301
char chStoutFile[FILENAME_PATH_LENGTH]
Definition atmdat.h:407
double HCharHeatMax
Definition atmdat.h:303
CollIonRC
Definition atmdat.h:441
@ HYBRID
Definition atmdat.h:441
@ DIMA
Definition atmdat.h:441
bool lgGbarOn
Definition atmdat.h:420
void comment(t_warnings &)
Definition atmdat.h:264
double HCharCoolMax
Definition atmdat.h:304
double CharExcRecTotal[NCX]
Definition atmdat.h:312
bool lgUTAprint
Definition atmdat.h:432
long int nsbig
Definition atmdat.h:346
bool lgLamdaLevelsSet
Definition atmdat.h:398
double HCharExcRecTo_N0_2D
Definition atmdat.h:308
@ NCX
Definition atmdat.h:279
double HIonFracMax
Definition atmdat.h:318
char chCloudyChiantiFile[FILENAME_PATH_LENGTH]
Definition atmdat.h:381
double CharExcIonTotal[NCX]
Definition atmdat.h:311
bool lgdBaseSourceExists[LIMELM][LIMELM+1]
Definition atmdat.h:450
bool lgStoutOn
Definition atmdat.h:401
t_atmdat()
Definition atmdat.h:455
void zero()
Definition atmdat.cpp:9
const long nDefaultPhotoLevelsFe
Definition atmdat.h:361
bool lgChiantiLvl2Hybrid
Definition atmdat.h:375
double Emiss[2][HS_NZ][NHSDIM][NHSDIM][NLINEHS]
Definition atmdat.h:333
long int ntemp[2][HS_NZ]
Definition atmdat.h:336
bool lgChiantiExp
Definition atmdat.h:379
bool lgCollIonOn
Definition atmdat.h:350
double EIonPot[LIMELM][LIMELM]
Definition atmdat.h:282
bool lgChiantiOn
Definition atmdat.h:373
static const double aulThreshold
Definition atmdat.h:436
double collstrDefault
Definition atmdat.h:425
double HCTAlex
Definition atmdat.h:322
long nStoutMaxLevelsFe
Definition atmdat.h:409
long int ncut[2][HS_NZ]
Definition atmdat.h:338
bool lgCalpgmOn
Definition atmdat.h:418
double HIonFrac
Definition atmdat.h:315
char chdBaseSources[LIMELM][LIMELM+1][10]
Definition atmdat.h:448
bool lgInnerShell_Kisielius
Definition atmdat.h:430
multi_arr< long, 2 > ipSpecIon
Definition atmdat.h:453
CollIonRC CIRCData
Definition atmdat.h:442
long nStoutMaxLevels
Definition atmdat.h:412
double Density[2][HS_NZ][NHSDIM]
Definition atmdat.h:330
bool lgChiantiLevelsSet
Definition atmdat.h:387
bool lgChiantiPrint
Definition atmdat.h:377
bool lgStoutPrint
Definition atmdat.h:405
bool lgStoutLevelsSet
Definition atmdat.h:414
t_wavl WaveLengthCaseB[8][25][24]
Definition atmdat.h:356
double HCharHeatOn
Definition atmdat.h:305
bool lgInnerShellLine_on
Definition atmdat.h:428