cloudy  trunk
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
iso.h
Go to the documentation of this file.
1 /* This file is part of Cloudy and is copyright (C)1978-2013 by Gary J. Ferland and
2  * others. For conditions of distribution and use see copyright notice in license.txt */
3 
4 #ifndef ISO_H_
5 #define ISO_H_
6 
7 #include "two_photon.h"
8 
10 #include "transition.h"
11 #include "freebound.h"
12 
13 extern long int max_num_levels;
14 
17 #define KILL_BELOW_PLASMA(E_) ( (rfield.lgPlasNu && ((E_)<rfield.plsfrq) ) ? 0.:1. )
18 
20 #define N_(A_) (iso_sp[ipISO][nelem].st[A_].n())
21 #define L_(A_) (iso_sp[ipISO][nelem].st[A_].l())
22 #define S_(A_) (iso_sp[ipISO][nelem].st[A_].S())
23 #define J_(A_) (iso_sp[ipISO][nelem].st[A_].j())
24 
27 const int ipH1s = 0;
28 const int ipH2s = 1;
29 const int ipH2p = 2;
30 const int ipH3s = 3;
31 const int ipH3p = 4;
32 const int ipH3d = 5;
33 const int ipH4s = 6;
34 const int ipH4p = 7;
35 const int ipH4d = 8;
36 const int ipH4f = 9;
37 
40 /* level 1 */
41 const int ipHe1s1S = 0;
42 
43 /* level 2 */
44 const int ipHe2s3S = 1;
45 const int ipHe2s1S = 2;
46 const int ipHe2p3P0 = 3;
47 const int ipHe2p3P1 = 4;
48 const int ipHe2p3P2 = 5;
49 const int ipHe2p1P = 6;
50 
51 /* level 3 */
52 const int ipHe3s3S = 7;
53 const int ipHe3s1S = 8;
54 const int ipHe3p3P = 9;
55 const int ipHe3d3D = 10;
56 const int ipHe3d1D = 11;
57 const int ipHe3p1P = 12;
58 
62 const int ipH_LIKE = 0;
63 const int ipHE_LIKE = 1;
64 const int ipLI_LIKE = 2;
65 const int ipBE_LIKE = 3;
66 const int ipB_LIKE = 4;
67 const int ipC_LIKE = 5;
68 const int ipN_LIKE = 6;
69 const int ipO_LIKE = 7;
70 const int ipF_LIKE = 8;
71 const int ipNE_LIKE = 9;
72 const int ipNA_LIKE = 10;
73 const int ipMG_LIKE = 11;
74 const int ipAL_LIKE = 12;
75 const int ipSI_LIKE = 13;
76 const int ipP_LIKE = 14;
77 const int ipS_LIKE = 15;
78 const int ipCL_LIKE = 16;
79 const int ipAR_LIKE = 17;
80 
81 enum {
82  ipSINGLET = 1, ipDOUBLET = 2, ipTRIPLET = 3,
84 };
85 
86 #define IPRAD 0
87 #define IPCOLLIS 1
88 /*define IPENERGY 2*/
89 
90 /* following two macros used to define recombination coef arrays */
91 /* Max n desired in RRCoef file. */
94 /* Hydrogen and helium atoms will have precompiled recombination coefficients up to these maximum n. */
95 #define RREC_MAXN 40
96 
98 #define LIKE_RREC_MAXN( A_ ) ( A_ == ipHELIUM ? 40 : 20 )
99 
100 #define N_ISO_TE_RECOMB 41
101 
104 #define SumUpToThisN 1000
105 
106 #define RECOMBMAGIC (130216)
107 
112 void iso_cascade( long ipISO, long nelem );
113 
116 void iso_charge_transfer_update( long nelem );
117 
122 void iso_collapsed_bnl_print( long ipISO, long nelem );
123 
128 void iso_collapsed_bnl_set( long ipISO, long nelem );
129 
134 void iso_collapsed_Aul_update( long ipISO, long nelem );
135 
140 void iso_collapsed_lifetimes_update( long ipISO, long nelem );
141 
146 void iso_collide( long ipISO, long nelem );
147 
152 void iso_collisional_ionization( long ipISO, long nelem );
153 
158 void iso_continuum_lower( long ipISO , long nelem );
159 
164 void iso_cool( long ipISO , long nelem );
165 
168 void iso_create( void );
169 
179 double iso_cross_section( double ERyd , double EthRyd, long n, long l, long S, long globalZ, long globalISO );
180 
185 void iso_departure_coefficients( long ipISO, long nelem );
186 
192 double iso_dielec_recomb_rate( long ipISO, long nelem, long ipLo );
193 
198 void iso_error_generation( long ipISO, long nelem );
199 
205 long iso_get_total_num_levels( long ipISO, long nmaxResolved, long numCollapsed );
206 
209 void IonHydro( );
210 
215 void iso_ionize_recombine( long ipISO , long nelem );
216 
221 void iso_level( const long ipISO, const long nelem, double& renorm);
222 
227 void iso_photo( long ipISO , long nelem );
228 
234 void iso_prt_pops( long ipISO, long nelem, bool lgPrtDeparCoef );
235 
245 void iso_put_error( long ipISO, long nelem, long ipHi, long ipLo, long whichData, realnum errorOpt, realnum errorPess);
246 
251 void iso_radiative_recomb( long ipISO, long nelem );
252 
257 void iso_radiative_recomb_effective( long ipISO, long nelem );
258 
266 double iso_recomb_check( long ipISO, long nelem, long level, double temperature );
267 
270 void iso_recomb_auxiliary_free( void );
271 
274 void iso_recomb_malloc( void );
275 
279 void iso_recomb_setup( long ipISO );
280 
286 double iso_RRCoef_Te( long ipISO, long nelem , long n );
287 
290 void iso_satellite_update( long nelem );
291 
292 /* calculate radiative lifetime of an individual iso state
293 \param ipISO
294 \param nelem
295 \param n
296 \param l
297 */
298 double iso_state_lifetime( long ipISO, long nelem, long n, long l );
299 
303 void iso_solve( long ipISO, long nelem, double &maxerr );
304 
309 void iso_suprathermal( long ipISO, long nelem );
310 
315 void iso_update_num_levels( long ipISO, long nelem );
316 
319 void iso_update_rates( void );
320 
321 void iso_collapsed_update( void );
322 
323 void iso_set_ion_rates( long ipISO, long nelem);
324 
326 {
327 public:
329 
330  const char *chISO[NISO];
331 
334  long int nLyman[NISO],
337 
340 
343 
346 
348 
352 
356 
357  /* option to disable continuum lowering due to stark broadening, particle packing, etc. */
359 
363 
366 
372 
375 
378 
381 
386 
389  lgCS_None[NISO] ,
392  int nCS_new[NISO];//vals are 0, 1, and 2
393 
396 
399  bool lgFSM[NISO];
400 
404 
405 
407 
408  bool lgTopoff[NISO];
409 
412 };
413 
414 extern t_isoCTRL iso_ctrl;
415 
416 class extra_tr
417 {
418 public:
420  double pestrk;
421  double pestrk_up;
422 
423  /* NB NB NB --- Error and ErrorFactor need one more slot than all the rest of these! */
424  /* and the last dimension can just be hardwired to 3 */
425 
427  /* first dimension is upper level,
428  * second is lower level,
429  * third is for radiative, collisional, or energy errors.
430  * MACROS are used for the last dimension: IPRAD, IPCOLLIS, and IPENERGY. */
432 
436 
439 };
440 
441 class t_iso_sp
442 {
443 public:
444  TransitionProxy trans( const long ipHi, const long ipLo )
445  {
446  return (*tr)[ ipTrans[ipHi][ipLo] ];
447  }
452  vector<freeBound> fb;
455 
462 
465  double xIonSimple;
466 
469 
472 
475 
479 
480  /* flag that says we must reevaluate everything about this ion */
482 
483  /* set true if "element ionization" forces rescaling of pops */
485 
487  long int nCollapsed_max;
489 
493  long int numLevels_max;
494 
498  long int numLevels_local;
499 
503 
508 
511 
513  double RadRec_caseB;
514 
517  double RadRec_effec;
518 
521 
524 
527 
529  double coll_ion;
530 
532  double cRest_cool;
533 
535  double xLineTotCool;
536 
538  double dLTot;
539 
541  double RadRecCool;
542 
544  double cBal_cool;
545 
547  double cLyrest_cool;
548 
550  double cLya_cool;
551 
554 
556  char chTypeAtomUsed[10];
557 
561 
563  double qTot2S;
564 
565  /* the departure coefficients of collapsed levels */
568  void Reset()
569  {
570  // this is flag indicating which type of model atom to use
571  strcpy( chTypeAtomUsed , "none" );
572  CaseBCheck = 0.;
573  /* a first guess at the recombination coefficients */
574  RadRec_caseB = 1e-13;
575  lgLevelsLowered = false;
576  lgLevelsEverLowered = false;
577  lgMustReeval = false;
578  lgPopsRescaled = false;
579  /* error generation done yet? false means not done. */
580  lgErrGenDone = false;
581  for( vector<two_photon>::iterator it = TwoNu.begin(); it != TwoNu.end(); ++it )
582  (*it).Reset();
583  for( vector<freeBound>::iterator it = fb.begin(); it != fb.end(); ++it )
584  (*it).Reset();
585  }
586  vector<two_photon> TwoNu;
587 
588  vector<double> HighestLevelOpacStack;
589 };
590 
591 extern t_iso_sp iso_sp[NISO][LIMELM];
592 
594 void iso_renorm( long nelem, long ipISO, double& renorm );
595 
596 #endif /* ISO_H_ */
double SigmaCascadeProb
Definition: iso.h:438
void iso_collapsed_bnl_print(long ipISO, long nelem)
int modelRank[NISO]
Definition: iso.h:411
Definition: iso.h:325
const int ipAL_LIKE
Definition: iso.h:74
double pestrk_up
Definition: iso.h:421
Definition: iso.h:82
long int numLevels_malloc
Definition: iso.h:502
const int ipH4d
Definition: iso.h:35
const int ipC_LIKE
Definition: iso.h:67
void Reset()
Definition: iso.h:568
bool lgContinuumLoweringEnabled[NISO]
Definition: iso.h:358
qList st
Definition: iso.h:453
const int ipHE_LIKE
Definition: iso.h:63
void iso_continuum_lower(long ipISO, long nelem)
bool lgPessimisticErrors
Definition: iso.h:406
multi_arr< realnum, 3 > CachedAs
Definition: iso.h:567
double RadRec_caseB
Definition: iso.h:513
bool lgColl_ionize[NISO]
Definition: iso.h:345
double iso_recomb_check(long ipISO, long nelem, long level, double temperature)
t_isoCTRL iso_ctrl
Definition: iso.cpp:6
const int NISO
Definition: cddefines.h:265
const int ipHe2p3P1
Definition: iso.h:47
double xLineTotCool
Definition: iso.h:535
const int ipHe3d3D
Definition: iso.h:55
Definition: iso.h:416
bool lgCompileRecomb[NISO]
Definition: iso.h:380
bool lgFSM[NISO]
Definition: iso.h:399
const int ipHe2p3P0
Definition: iso.h:46
double RecomInducCool_Rate
Definition: iso.h:553
bool lgCS_therm_ave[NISO]
Definition: iso.h:388
const int ipHe2s3S
Definition: iso.h:44
long int nCollapsed_max
Definition: iso.h:487
long iso_get_total_num_levels(long ipISO, long nmaxResolved, long numCollapsed)
int ipResoRedist[NISO]
Definition: iso.h:374
void iso_suprathermal(long ipISO, long nelem)
Definition: iso_collide.cpp:79
const int ipHe2p1P
Definition: iso.h:49
double dLTot
Definition: iso.h:538
const int ipAR_LIKE
Definition: iso.h:79
bool lgCS_None[NISO]
Definition: iso.h:388
static long int globalISO
const int ipHe3p3P
Definition: iso.h:54
bool lgColl_l_mixing[NISO]
Definition: iso.h:339
void iso_radiative_recomb_effective(long ipISO, long nelem)
multi_arr< long, 2 > ipTrans
Definition: iso.h:448
bool lgRandErrGen[NISO]
Definition: iso.h:403
const int ipHe1s1S
Definition: iso.h:41
void iso_photo(long ipISO, long nelem)
void iso_put_error(long ipISO, long nelem, long ipHi, long ipLo, long whichData, realnum errorOpt, realnum errorPess)
bool lgPrtDepartCoef
Definition: iso.h:468
bool lgLTE_levels[NISO]
Definition: iso.h:347
vector< freeBound > fb
Definition: iso.h:452
Definition: iso.h:82
const int ipP_LIKE
Definition: iso.h:76
bool lgCS_Vrinceanu[NISO]
Definition: iso.h:388
const int ipLI_LIKE
Definition: iso.h:64
realnum Error[3]
Definition: iso.h:431
t_iso_sp iso_sp[NISO][LIMELM]
Definition: iso.cpp:8
bool lgPopLTE_OK
Definition: iso.h:523
realnum SmallA
Definition: iso.h:371
void iso_collapsed_lifetimes_update(long ipISO, long nelem)
long int max_num_levels
Definition: iso.cpp:10
vector< double > HighestLevelOpacStack
Definition: iso.h:588
long int n_HighestResolved_local
Definition: iso.h:507
multi_arr< double, 2 > BranchRatio
Definition: iso.h:451
const int ipCL_LIKE
Definition: iso.h:78
void iso_collapsed_update(void)
Definition: iso_solve.cpp:27
bool lgColl_excite[NISO]
Definition: iso.h:342
static long int globalZ
vector< two_photon > TwoNu
Definition: iso.h:586
void iso_update_num_levels(long ipISO, long nelem)
long int n_HighestResolved_max
Definition: iso.h:505
const int ipHe2s1S
Definition: iso.h:45
int nCS_new[NISO]
Definition: iso.h:392
void iso_collapsed_bnl_set(long ipISO, long nelem)
bool lgLevelsLowered
Definition: iso.h:474
void iso_cool(long ipISO, long nelem)
long int nLyman[NISO]
Definition: iso.h:334
const int ipH1s
Definition: iso.h:27
void iso_departure_coefficients(long ipISO, long nelem)
Definition: iso_solve.cpp:363
const int ipB_LIKE
Definition: iso.h:66
void iso_error_generation(long ipISO, long nelem)
Definition: iso_error.cpp:39
void iso_satellite_update(long nelem)
const int ipHe3p1P
Definition: iso.h:57
const char * chISO[NISO]
Definition: iso.h:330
void iso_level(const long ipISO, const long nelem, double &renorm)
double cLyrest_cool
Definition: iso.h:547
void iso_charge_transfer_update(long nelem)
const int ipNA_LIKE
Definition: iso.h:72
double coll_ion
Definition: iso.h:529
TransitionList * tr
Definition: iso.h:454
bool lgDielRecom[NISO]
Definition: iso.h:365
float realnum
Definition: cddefines.h:107
const int ipH4p
Definition: iso.h:34
bool lgPrintNumberOfLevels
Definition: iso.h:328
bool lgLevelsEverLowered
Definition: iso.h:478
bool lgPrtLevelPops
Definition: iso.h:471
const int ipHe3s3S
Definition: iso.h:52
void iso_radiative_recomb(long ipISO, long nelem)
void iso_collisional_ionization(long ipISO, long nelem)
Definition: iso_collide.cpp:25
void iso_collapsed_Aul_update(long ipISO, long nelem)
double RecomCollisFrac
Definition: iso.h:520
const int ipH3s
Definition: iso.h:30
void iso_solve(long ipISO, long nelem, double &maxerr)
Definition: iso_solve.cpp:102
double iso_cross_section(double ERyd, double EthRyd, long n, long l, long S, long globalZ, long globalISO)
const int ipMG_LIKE
Definition: iso.h:73
const int ipH3d
Definition: iso.h:32
multi_arr< long, 3 > QuantumNumbers2Index
Definition: iso.h:461
void iso_update_rates(void)
Definition: iso_solve.cpp:51
const int ipS_LIKE
Definition: iso.h:77
double cBal_cool
Definition: iso.h:544
bool lgCritDensLMix[NISO]
Definition: iso.h:395
TransitionProxy trans(const long ipHi, const long ipLo)
Definition: iso.h:444
Definition: iso.h:441
int nLyaLevel[NISO]
Definition: iso.h:377
bool lgInd2nu_On
Definition: iso.h:355
bool lgPopsRescaled
Definition: iso.h:484
double FreeBnd_net_Cool_Rate
Definition: iso.h:526
const int ipH2p
Definition: iso.h:29
multi_arr< double, 2 > CascadeProb
Definition: iso.h:450
multi_arr< extra_tr, 2 > ex
Definition: iso.h:449
double cLya_cool
Definition: iso.h:550
double qTot2S
Definition: iso.h:563
const int ipH2s
Definition: iso.h:28
int ipLyaRedist[NISO]
Definition: iso.h:374
double RadRec_effec
Definition: iso.h:517
multi_arr< double, 3 > bnl_effective
Definition: iso.h:566
void iso_recomb_setup(long ipISO)
const int ipH_LIKE
Definition: iso.h:62
void iso_recomb_malloc(void)
const int LIMELM
Definition: cddefines.h:262
const int ipHe2p3P2
Definition: iso.h:48
double iso_state_lifetime(long ipISO, long nelem, long n, long l)
void iso_cascade(long ipISO, long nelem)
void iso_create(void)
Definition: iso_create.cpp:39
double pestrk
Definition: iso.h:420
const int ipSI_LIKE
Definition: iso.h:75
const int ipBE_LIKE
Definition: iso.h:65
int ipSubRedist[NISO]
Definition: iso.h:374
void iso_renorm(long nelem, long ipISO, double &renorm)
Definition: iso_solve.cpp:272
void IonHydro()
Definition: iso_solve.cpp:149
bool lgCollStrenThermAver
Definition: iso.h:351
double xIonSimple
Definition: iso.h:465
realnum stat_ion[NISO]
Definition: iso.h:362
const int ipH4s
Definition: iso.h:33
#define S(I_, J_)
double RadRecCool
Definition: iso.h:541
long int numLevels_max
Definition: iso.h:493
void iso_prt_pops(long ipISO, long nelem, bool lgPrtDeparCoef)
Definition: iso_solve.cpp:386
const int ipNE_LIKE
Definition: iso.h:71
double cRest_cool
Definition: iso.h:532
bool lgTopoff[NISO]
Definition: iso.h:408
realnum ErrorFactor[3]
Definition: iso.h:435
realnum CaseBCheck
Definition: iso.h:510
const int ipHe3d1D
Definition: iso.h:56
void iso_ionize_recombine(long ipISO, long nelem)
void iso_collide(long ipISO, long nelem)
const int ipH3p
Definition: iso.h:31
void iso_set_ion_rates(long ipISO, long nelem)
Definition: iso_level.cpp:685
long int numLevels_local
Definition: iso.h:498
long int nCollapsed_local
Definition: iso.h:488
double iso_RRCoef_Te(long ipISO, long nelem, long n)
const int ipF_LIKE
Definition: iso.h:70
const int ipH4f
Definition: iso.h:36
const int ipN_LIKE
Definition: iso.h:68
const int ipHe3s1S
Definition: iso.h:53
long int nLyman_malloc[NISO]
Definition: iso.h:334
bool lgMustReeval
Definition: iso.h:481
bool lgCS_Vriens[NISO]
Definition: iso.h:388
bool lgErrGenDone
Definition: iso.h:560
double iso_dielec_recomb_rate(long ipISO, long nelem, long ipLo)
char chTypeAtomUsed[10]
Definition: iso.h:556
void iso_recomb_auxiliary_free(void)
const int ipO_LIKE
Definition: iso.h:69
bool lgNoRecombInterp[NISO]
Definition: iso.h:385
Definition: iso.h:82