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-2022 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 
8 #include "module.h"
9 #include "transition.h"
10 #include "container_classes.h"
11 
12 class two_photon;
13 class freeBound;
14 
15 extern long int max_num_levels;
16 
19 #define KILL_BELOW_PLASMA(E_) ( (rfield.lgPlasNu && ((E_)<rfield.plsfrq) ) ? 0.:1. )
20 
22 #define N_(A_) (iso_sp[ipISO][nelem].st[A_].n())
23 #define L_(A_) (iso_sp[ipISO][nelem].st[A_].l())
24 #define S_(A_) (iso_sp[ipISO][nelem].st[A_].S())
25 #define J_(A_) (iso_sp[ipISO][nelem].st[A_].j())
26 
29 const int ipH1s = 0;
30 const int ipH2s = 1;
31 const int ipH2p = 2;
32 const int ipH3s = 3;
33 const int ipH3p = 4;
34 const int ipH3d = 5;
35 const int ipH4s = 6;
36 const int ipH4p = 7;
37 const int ipH4d = 8;
38 const int ipH4f = 9;
39 
42 /* level 1 */
43 const int ipHe1s1S = 0;
44 
45 /* level 2 */
46 const int ipHe2s3S = 1;
47 const int ipHe2s1S = 2;
48 const int ipHe2p3P0 = 3;
49 const int ipHe2p3P1 = 4;
50 const int ipHe2p3P2 = 5;
51 const int ipHe2p1P = 6;
52 
53 /* level 3 */
54 const int ipHe3s3S = 7;
55 const int ipHe3s1S = 8;
56 const int ipHe3p3P = 9;
57 const int ipHe3d3D = 10;
58 const int ipHe3d1D = 11;
59 const int ipHe3p1P = 12;
60 
64 const int ipH_LIKE = 0;
65 const int ipHE_LIKE = 1;
66 const int ipLI_LIKE = 2;
67 const int ipBE_LIKE = 3;
68 const int ipB_LIKE = 4;
69 const int ipC_LIKE = 5;
70 const int ipN_LIKE = 6;
71 const int ipO_LIKE = 7;
72 const int ipF_LIKE = 8;
73 const int ipNE_LIKE = 9;
74 const int ipNA_LIKE = 10;
75 const int ipMG_LIKE = 11;
76 const int ipAL_LIKE = 12;
77 const int ipSI_LIKE = 13;
78 const int ipP_LIKE = 14;
79 const int ipS_LIKE = 15;
80 const int ipCL_LIKE = 16;
81 const int ipAR_LIKE = 17;
82 
83 enum {
84  ipSINGLET = 1, ipDOUBLET = 2, ipTRIPLET = 3,
86 };
87 
88 #define IPRAD 0
89 #define IPCOLLIS 1
90 /*define IPENERGY 2*/
91 
92 /* following two macros used to define recombination coef arrays */
93 /* Max n desired in RRCoef file. */
96 /* Hydrogen and helium atoms will have precompiled recombination coefficients up to these maximum n. */
97 #define RREC_MAXN 40
98 
100 #define LIKE_RREC_MAXN( A_ ) ( A_ == ipHELIUM ? 40 : 20 )
101 
102 #define N_ISO_TE_RECOMB 41
103 
106 #define SumUpToThisN 1000
107 
108 #define RECOMBMAGIC (130216)
109 
114 void iso_cascade( long ipISO, long nelem );
115 
118 void iso_charge_transfer_update( long nelem );
119 
124 void iso_collapsed_Aul_update( long ipISO, long nelem );
125 
130 void iso_collapsed_lifetimes_update( long ipISO, long nelem );
131 
136 void iso_collide( long ipISO, long nelem );
137 
142 void iso_collisional_ionization( long ipISO, long nelem );
143 
148 void iso_continuum_lower( long ipISO , long nelem );
149 
154 void iso_cool( long ipISO , long nelem );
155 
162 void iso_setRedisFun (long ipISO, long nelem, long ipLo, long ipHi);
163 
170 void iso_setOpacity (long ipISO, long nelem, long ipLo, long ipHi);
171 
174 void iso_create( void );
175 
185 double iso_cross_section( double ERyd , double EthRyd, long n, long l, long S, long globalZ, long globalISO );
186 
191 void iso_departure_coefficients( long ipISO, long nelem );
192 
198 double iso_dielec_recomb_rate( long ipISO, long nelem, long ipLo );
199 
204 void iso_error_generation( long ipISO, long nelem );
205 
211 long iso_get_total_num_levels( long ipISO, long nmaxResolved, long numCollapsed );
212 
215 void IonHydro( );
216 
221 void iso_ionize_recombine( long ipISO , long nelem );
222 
229 void iso_level( const long ipISO, const long nelem, double& renorm,
230  bool lgPrtMatrix );
231 
236 void iso_photo( long ipISO , long nelem );
237 
243 void iso_prt_pops( long ipISO, long nelem, bool lgPrtDeparCoef );
244 
254 void iso_put_error( long ipISO, long nelem, long ipHi, long ipLo, long whichData, realnum errorOpt, realnum errorPess);
255 
260 void iso_radiative_recomb( long ipISO, long nelem );
261 
266 void iso_radiative_recomb_effective( long ipISO, long nelem );
267 
275 double iso_recomb_check( long ipISO, long nelem, long level, double temperature );
276 
279 void iso_recomb_auxiliary_free( void );
280 
283 void iso_recomb_malloc( void );
284 
288 void iso_recomb_setup( long ipISO );
289 
296 double iso_RRCoef_Te( long ipISO, long nelem, double temp, long n );
297 
300 void iso_satellite_update( long nelem );
301 
302 /* calculate radiative lifetime of an individual iso state
303 \param ipISO
304 \param nelem
305 \param n
306 \param l
307 */
308 double iso_state_lifetime( long ipISO, long nelem, long n, long l );
309 
313 void iso_solve( long ipISO, long nelem, double &maxerr );
314 
319 void iso_suprathermal( long ipISO, long nelem );
320 
325 void iso_update_num_levels( long ipISO, long nelem );
326 
329 void iso_update_rates( void );
330 
331 void iso_collapsed_update( void );
332 
333 void iso_set_ion_rates( long ipISO, long nelem);
334 
335 class t_isoCTRL : public module
336 {
337 public:
338  void zero();
339  void comment(t_warnings&) {}
340 
341  const char *chName() const
342  {
343  return "iso_ctrl";
344  }
345 
347 
348  const char *chISO[NISO];
349 
352  long int nLyman[NISO],
354  nLyman_max[NISO],
357 
360 
363 
366 
368 
372 
376 
377  /* option to disable continuum lowering due to stark broadening, particle packing, etc. */
379 
383 
386 
392 
395 
398 
401 
406 
409  lgCS_None[NISO] ,
410  lgCS_Seaton[NISO],
411  lgCS_B72[NISO],
412  lgCS_PSdeg[NISO],
414  lgCS_PS64[NISO],
416  lgCS_VOS12[NISO],
419  int nCS_new[NISO];//vals are 0, 1, and 2
420 
423 
426  bool lgFSM[NISO];
427 
431 
432 
434 
435  bool lgTopoff[NISO];
436 
439 
441 };
442 
443 extern t_isoCTRL iso_ctrl;
444 
445 class extra_tr
446 {
447 public:
449  double pestrk;
450  double pestrk_up;
451 
452  /* NB NB NB --- Error and ErrorFactor need one more slot than all the rest of these! */
453  /* and the last dimension can just be hardwired to 3 */
454 
456  /* first dimension is upper level,
457  * second is lower level,
458  * third is for radiative, collisional, or energy errors.
459  * MACROS are used for the last dimension: IPRAD, IPCOLLIS, and IPENERGY. */
461 
465 
468 };
469 
470 class t_iso_sp
471 {
472 public:
473  TransitionProxy trans( const long ipHi, const long ipLo )
474  {
475  return (*tr)[ ipTrans[ipHi][ipLo] ];
476  }
481  vector<freeBound> fb;
484 
491  // This is the same as QuantumNumbers2Index, except indexed as if collapsed levels were resolved.
493 
496  double xIonSimple;
497 
500 
503 
506 
510 
511  /* flag that says we must reevaluate everything about this ion */
513 
514  /* set true if "element ionization" forces rescaling of pops */
516 
518  long int nCollapsed_max;
520 
524  long int numLevels_max;
525 
529  long int numLevels_local;
530 
534 
539 
542 
544  double RadRec_caseB;
545 
548  double RadRec_effec;
549 
552 
555 
558 
560  double coll_ion;
561 
563  double cRest_cool;
564 
566  double xLineTotCool;
567 
569  double dLTot;
570 
572  double RadRecCool;
573 
575  double cBal_cool;
576 
578  double cLyrest_cool;
579 
581  double cLya_cool;
582 
585 
587  char chTypeAtomUsed[10];
588 
592 
594  double qTot2S;
595 
597  void Reset();
598  vector<two_photon> TwoNu;
599 
600  vector<double> HighestLevelOpacStack;
601 
604 };
605 
606 extern t_iso_sp iso_sp[NISO][LIMELM];
607 
609 void iso_renorm( long nelem, long ipISO, double& renorm );
610 
612 void iso_multiplet_opacities( void );
613 
614 /* iso_comment_tran_levels - prepare comment string for entry to the line stack.
615  * The comment has the form 'H-like, 1 3, 1^2S - 2^2P', where '1 3' are the energy
616  * level indices, 1 being ground.
617  *
618  * \param ipISO iso-sequence index
619  * \param nelem element index
620  * \param ipLo, ipHi lower and upper level indices
621  * \return comment string
622  */
623 string iso_comment_tran_levels( long ipISO, long nelem, long ipLo, long ipHi );
624 
625 #endif /* ISO_H_ */
double SigmaCascadeProb
Definition: iso.h:467
int modelRank[NISO]
Definition: iso.h:438
Definition: iso.h:335
const int ipAL_LIKE
Definition: iso.h:76
double pestrk_up
Definition: iso.h:450
long int numLevels_malloc
Definition: iso.h:533
const int ipH4d
Definition: iso.h:37
const int ipC_LIKE
Definition: iso.h:69
void Reset()
Definition: iso.cpp:113
bool lgContinuumLoweringEnabled[NISO]
Definition: iso.h:378
void zero()
Definition: iso.cpp:15
qList st
Definition: iso.h:482
bool lgCS_PSClassic[NISO]
Definition: iso.h:408
const int ipHE_LIKE
Definition: iso.h:65
void iso_continuum_lower(long ipISO, long nelem)
bool lgPessimisticErrors
Definition: iso.h:433
multi_arr< realnum, 3 > CachedAs
Definition: iso.h:596
double RadRec_caseB
Definition: iso.h:544
bool lgColl_ionize[NISO]
Definition: iso.h:365
double iso_recomb_check(long ipISO, long nelem, long level, double temperature)
const char * chName() const
Definition: iso.h:341
t_isoCTRL iso_ctrl
Definition: iso.cpp:9
const int NISO
Definition: cddefines.h:311
const int ipHe2p3P1
Definition: iso.h:49
double xLineTotCool
Definition: iso.h:566
const int ipHe3d3D
Definition: iso.h:57
Definition: iso.h:445
bool lgCompileRecomb[NISO]
Definition: iso.h:400
bool lgFSM[NISO]
Definition: iso.h:426
double iso_RRCoef_Te(long ipISO, long nelem, double temp, long n)
const int ipHe2p3P0
Definition: iso.h:48
double RecomInducCool_Rate
Definition: iso.h:584
bool lgCS_therm_ave[NISO]
Definition: iso.h:408
const int ipHe2s3S
Definition: iso.h:46
long int nCollapsed_max
Definition: iso.h:518
long iso_get_total_num_levels(long ipISO, long nmaxResolved, long numCollapsed)
int ipResoRedist[NISO]
Definition: iso.h:394
void iso_suprathermal(long ipISO, long nelem)
const int ipHe2p1P
Definition: iso.h:51
double dLTot
Definition: iso.h:569
string iso_comment_tran_levels(long ipISO, long nelem, long ipLo, long ipHi)
const int ipAR_LIKE
Definition: iso.h:81
bool lgCS_None[NISO]
Definition: iso.h:408
static long int globalISO
const int ipHe3p3P
Definition: iso.h:56
bool lgColl_l_mixing[NISO]
Definition: iso.h:359
void iso_radiative_recomb_effective(long ipISO, long nelem)
multi_arr< long, 2 > ipTrans
Definition: iso.h:477
bool lgRandErrGen[NISO]
Definition: iso.h:430
const int ipHe1s1S
Definition: iso.h:43
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:499
bool lgLTE_levels[NISO]
Definition: iso.h:367
vector< freeBound > fb
Definition: iso.h:481
const int ipP_LIKE
Definition: iso.h:78
bool lgCS_Vrinceanu[NISO]
Definition: iso.h:408
multi_arr< long, 3 > IndexIfAllResolved
Definition: iso.h:492
double RRC_TeUsed[NISO][LIMELM]
Definition: iso.h:440
Definition: iso.h:84
const int ipLI_LIKE
Definition: iso.h:66
realnum Error[3]
Definition: iso.h:460
t_iso_sp iso_sp[NISO][LIMELM]
Definition: iso.cpp:11
bool lgPopLTE_OK
Definition: iso.h:554
realnum SmallA
Definition: iso.h:391
void iso_collapsed_lifetimes_update(long ipISO, long nelem)
long int max_num_levels
Definition: iso.cpp:13
vector< double > HighestLevelOpacStack
Definition: iso.h:600
long int n_HighestResolved_local
Definition: iso.h:538
void iso_multiplet_opacities(void)
Definition: iso_level.cpp:756
multi_arr< double, 2 > BranchRatio
Definition: iso.h:480
const int ipCL_LIKE
Definition: iso.h:80
void iso_collapsed_update(void)
Definition: iso_solve.cpp:26
bool lgColl_excite[NISO]
Definition: iso.h:362
static long int globalZ
vector< two_photon > TwoNu
Definition: iso.h:598
void iso_update_num_levels(long ipISO, long nelem)
long int n_HighestResolved_max
Definition: iso.h:536
const int ipHe2s1S
Definition: iso.h:47
long int nLyman_max[NISO]
Definition: iso.h:352
int nCS_new[NISO]
Definition: iso.h:419
bool lgLevelsLowered
Definition: iso.h:505
void iso_cool(long ipISO, long nelem)
long int nLyman[NISO]
Definition: iso.h:352
const int ipH1s
Definition: iso.h:29
void iso_departure_coefficients(long ipISO, long nelem)
Definition: iso_solve.cpp:401
const int ipB_LIKE
Definition: iso.h:68
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:59
const char * chISO[NISO]
Definition: iso.h:348
double cLyrest_cool
Definition: iso.h:578
void iso_charge_transfer_update(long nelem)
const int ipNA_LIKE
Definition: iso.h:74
double coll_ion
Definition: iso.h:560
TransitionList * tr
Definition: iso.h:483
bool lgCS_PS64[NISO]
Definition: iso.h:408
bool lgDielRecom[NISO]
Definition: iso.h:385
float realnum
Definition: cddefines.h:124
const int ipH4p
Definition: iso.h:36
bool lgPrintNumberOfLevels
Definition: iso.h:346
bool lgLevelsEverLowered
Definition: iso.h:509
bool lgPrtLevelPops
Definition: iso.h:502
const int ipHe3s3S
Definition: iso.h:54
void iso_radiative_recomb(long ipISO, long nelem)
void iso_collisional_ionization(long ipISO, long nelem)
Definition: iso_collide.cpp:44
void iso_collapsed_Aul_update(long ipISO, long nelem)
double RecomCollisFrac
Definition: iso.h:551
const int ipH3s
Definition: iso.h:32
void iso_solve(long ipISO, long nelem, double &maxerr)
Definition: iso_solve.cpp:99
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:75
Definition: iso.h:84
void comment(t_warnings &)
Definition: iso.h:339
const int ipH3d
Definition: iso.h:34
multi_arr< long, 3 > QuantumNumbers2Index
Definition: iso.h:490
void iso_update_rates(void)
Definition: iso_solve.cpp:48
const int ipS_LIKE
Definition: iso.h:79
double cBal_cool
Definition: iso.h:575
bool lgCritDensLMix[NISO]
Definition: iso.h:422
TransitionProxy trans(const long ipHi, const long ipLo)
Definition: iso.h:473
Definition: iso.h:470
int nLyaLevel[NISO]
Definition: iso.h:397
bool lgInd2nu_On
Definition: iso.h:375
bool lgPopsRescaled
Definition: iso.h:515
double FreeBnd_net_Cool_Rate
Definition: iso.h:557
const int ipH2p
Definition: iso.h:31
multi_arr< double, 2 > CascadeProb
Definition: iso.h:479
bool lgCS_Seaton[NISO]
Definition: iso.h:408
multi_arr< extra_tr, 2 > ex
Definition: iso.h:478
double cLya_cool
Definition: iso.h:581
double qTot2S
Definition: iso.h:594
const int ipH2s
Definition: iso.h:30
int ipLyaRedist[NISO]
Definition: iso.h:394
bool lgCS_VOS12[NISO]
Definition: iso.h:408
double RadRec_effec
Definition: iso.h:548
void iso_recomb_setup(long ipISO)
const int ipH_LIKE
Definition: iso.h:64
void iso_recomb_malloc(void)
const int LIMELM
Definition: cddefines.h:308
const int ipHe2p3P2
Definition: iso.h:50
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:111
double pestrk
Definition: iso.h:449
bool lgCS_VOS12QM[NISO]
Definition: iso.h:408
void iso_setRedisFun(long ipISO, long nelem, long ipLo, long ipHi)
Definition: iso_create.cpp:48
Definition: iso.h:84
const int ipSI_LIKE
Definition: iso.h:77
const int ipBE_LIKE
Definition: iso.h:67
int ipSubRedist[NISO]
Definition: iso.h:394
void iso_renorm(long nelem, long ipISO, double &renorm)
Definition: iso_solve.cpp:310
void IonHydro()
Definition: iso_solve.cpp:187
bool lgCollStrenThermAver
Definition: iso.h:371
double xIonSimple
Definition: iso.h:496
bool lgPrtMatrix
Definition: iso.h:603
realnum stat_ion[NISO]
Definition: iso.h:382
const int ipH4s
Definition: iso.h:35
#define S(I_, J_)
double RadRecCool
Definition: iso.h:572
bool lgCS_B72[NISO]
Definition: iso.h:408
long int numLevels_max
Definition: iso.h:524
void iso_prt_pops(long ipISO, long nelem, bool lgPrtDeparCoef)
Definition: iso_solve.cpp:425
const int ipNE_LIKE
Definition: iso.h:73
double cRest_cool
Definition: iso.h:563
bool lgTopoff[NISO]
Definition: iso.h:435
realnum ErrorFactor[3]
Definition: iso.h:464
realnum CaseBCheck
Definition: iso.h:541
void iso_setOpacity(long ipISO, long nelem, long ipLo, long ipHi)
Definition: iso_create.cpp:82
const int ipHe3d1D
Definition: iso.h:58
void iso_ionize_recombine(long ipISO, long nelem)
Definition: module.h:26
void iso_collide(long ipISO, long nelem)
const int ipH3p
Definition: iso.h:33
void iso_set_ion_rates(long ipISO, long nelem)
Definition: iso_level.cpp:811
long int numLevels_local
Definition: iso.h:529
long int nCollapsed_local
Definition: iso.h:519
const int ipF_LIKE
Definition: iso.h:72
const int ipH4f
Definition: iso.h:38
bool lgCS_PSdeg[NISO]
Definition: iso.h:408
const int ipN_LIKE
Definition: iso.h:70
const int ipHe3s1S
Definition: iso.h:55
long int nLyman_malloc[NISO]
Definition: iso.h:352
bool lgMustReeval
Definition: iso.h:512
void iso_level(const long ipISO, const long nelem, double &renorm, bool lgPrtMatrix)
bool lgCS_Vriens[NISO]
Definition: iso.h:408
bool lgErrGenDone
Definition: iso.h:591
double iso_dielec_recomb_rate(long ipISO, long nelem, long ipLo)
char chTypeAtomUsed[10]
Definition: iso.h:587
void iso_recomb_auxiliary_free(void)
const int ipO_LIKE
Definition: iso.h:71
bool lgNoRecombInterp[NISO]
Definition: iso.h:405