cloudy  trunk
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
hydroeinsta.cpp
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 /*HydroEinstA calculates Einstein A's from osillator strengths*/
4 #include "cddefines.h"
5 #include "hydroeinsta.h"
6 #include "hydro_bauman.h"
7 #include "hydrooscilstr.h"
8 #include "iso.h"
9 
10 STATIC double hydro_transprob_collapsed_to_collapsed( long nelem, long nHi, long nLo );
11 STATIC double hydro_transprob_collapsed_to_resolved( long nelem, long nHi, long nLo, long lLo );
12 
13 double HydroEinstA(long int n1,
14  long int n2)
15 {
16  long int lower, iupper;
17  double EinstA_v,
18  ryd,
19  xl,
20  xmicron,
21  xu;
22 
23  DEBUG_ENTRY( "HydroEinstA()" );
24  /* (lower,upper) of Johnson 1972. */
25 
26  /* strictly n -> n' transition probabilities
27  * no attempt to distribute according to l,l' */
28 
29  /* sort out the order of upper and lower, so can be called either way */
30  lower = MIN2( n1 , n2 );
31  iupper = MAX2( n1, n2 );
32  if( lower < 1 || lower == iupper )
33  {
34  fprintf(ioQQQ," HydroEinstA called with impossible ns, =%li %li\n", lower, iupper);
36  }
37 
38  xl = (double)lower;
39  xu = (double)iupper;
40  ryd = 1./POW2(xl) - 1./POW2(xu);
41  xmicron = 1.E4/(ryd*RYD_INF);
42  EinstA_v = HydroOscilStr(xl,xu)*TRANS_PROB_CONST*1e8f/(POW2(xmicron))*xl*xl/xu/xu;
43  return( EinstA_v );
44 }
45 
46 realnum hydro_transprob( long nelem, long ipHi, long ipLo )
47 {
48  double Aul;
49  long ipISO = ipH_LIKE;
50  /* charge to 4th power, needed for scaling laws for As*/
51  double z4 = POW4((double)nelem+1.);
52  DEBUG_ENTRY( "hydro_transprob()" );
53 
54  if( ipHi >= iso_sp[ipISO][nelem].numLevels_max-iso_sp[ipISO][nelem].nCollapsed_max )
55  {
56  if( ipLo >= iso_sp[ipISO][nelem].numLevels_max-iso_sp[ipISO][nelem].nCollapsed_max )
57  {
58  Aul = hydro_transprob_collapsed_to_collapsed( nelem, N_(ipHi), N_(ipLo) );
59  iso_put_error(ipISO,nelem,ipHi,ipLo,IPRAD,0.001f,0.001f);
60 
61  ASSERT( Aul > 0.);
62  }
63  else
64  {
65  Aul = hydro_transprob_collapsed_to_resolved( nelem, N_(ipHi), N_(ipLo), L_(ipLo) );
66  iso_put_error(ipISO,nelem,ipHi,ipLo,IPRAD,0.01f,0.01f);
67  }
68  }
69  else
70  {
71  if( N_(ipHi) == N_(ipLo) )
72  {
75  Aul = SMALLFLOAT;
76  iso_put_error(ipISO,nelem,ipHi,ipLo,IPRAD,0.001f,0.001f);
77  }
78  else if( ipLo == 0 && ipHi == 1 )
79  {
80  // >> refer H-like As Marrus, E. \& Mohr, P. J. Advances in Atomic and Molecular Physics, Vol. 14, Academic, New York, 1978, p. 181
81  Aul = 2.46e-6*powi((double)(nelem+1.),10);
82  iso_put_error(ipISO,nelem,ipHi,ipLo,IPRAD,0.001f,0.001f);
83  }
84  else if( ipLo == 0 && ipHi == 2 )
85  {
86  Aul = 6.265e8*z4;
87  iso_put_error(ipISO,nelem,ipHi,ipLo,IPRAD,0.001f,0.001f);
88  }
89  else if( abs( L_(ipLo) - L_(ipHi) )== 1 )
90  {
91  Aul = H_Einstein_A( N_(ipHi), L_(ipHi), N_(ipLo), L_(ipLo), nelem+1 );
92  iso_put_error(ipISO,nelem,ipHi,ipLo,IPRAD,0.001f,0.001f);
93  }
94  else
95  {
96  ASSERT( N_(ipHi) > N_(ipLo) );
97  ASSERT( (L_(ipHi) == L_(ipLo)) ||
98  ( abs(L_(ipHi)-L_(ipLo)) > 1) );
99  Aul = SMALLFLOAT;
100  iso_put_error(ipISO,nelem,ipHi,ipLo,IPRAD,0.001f,0.001f);
101  }
102  }
103 
104  return (realnum)Aul;
105 }
106 
107 STATIC double hydro_transprob_collapsed_to_collapsed( long nelem, long nHi, long nLo )
108 {
109  DEBUG_ENTRY( "hydro_transprob_collapsed_to_collapsed()" );
110 
111  double Aul = 0.;
112  ASSERT( nHi > nLo );
113 
114  for( long lLo=0; lLo < nLo; ++lLo )
115  {
116  double Aul1 = hydro_transprob_collapsed_to_resolved( nelem, nHi, nLo, lLo );
117  Aul += Aul1;
118  }
119 
120  return Aul;
121 }
122 
123 STATIC double hydro_transprob_collapsed_to_resolved( long nelem, long nHi, long nLo, long lLo )
124 {
125  DEBUG_ENTRY( "hydro_transprob_collapsed_to_resolved()" );
126 
127  long ipISO = ipH_LIKE;
128  t_iso_sp *sp = &iso_sp[ipISO][nelem];
129  long nResMax = sp->n_HighestResolved_max;
130  long ipLoRes = sp->IndexIfAllResolved[nLo][lLo][2];
131  ASSERT( nLo > nResMax || ipLoRes <= sp->numLevels_max - sp->nCollapsed_max );
132 
133  /* Lower level resolved, upper not. First calculate Aul
134  * from upper level with ang mom one higher. */
135  double Aul = H_Einstein_A( nHi, lLo+1, nLo, lLo, nelem+1 );
136 
137  sp->CachedAs[ nHi-nResMax-1 ][ ipLoRes ][0] = (realnum)Aul;
138 
139  Aul *= (2.*(lLo+1.)+1.) * 2. / (2.*(double)nHi*(double)nHi);
140 
141  if( lLo != 0 )
142  {
143  /* For all l>0, add in transitions from upper level with ang mom one lower. */
144  double Aul1 = H_Einstein_A( nHi, lLo-1, nLo, lLo, nelem+1 );
145 
146  sp->CachedAs[ nHi-nResMax-1 ][ ipLoRes ][1] = (realnum)Aul1;
147 
148  /* now add in this part after multiplying by stat weight for lHi = lLo-1. */
149  Aul += Aul1*(2.*(lLo-1.)+1.) * 2. / (2.*(double)nHi*(double)nHi);
150  }
151  else
152  sp->CachedAs[ nHi-nResMax-1 ][ ipLoRes ][1] = 0.f;
153 
154  ASSERT( Aul > 0.);
155 
156  return Aul;
157 }
158 
double HydroOscilStr(double xLower, double Upper)
STATIC double hydro_transprob_collapsed_to_collapsed(long nelem, long nHi, long nLo)
multi_arr< realnum, 3 > CachedAs
Definition: iso.h:596
const realnum SMALLFLOAT
Definition: cpu.h:246
long int nCollapsed_max
Definition: iso.h:518
FILE * ioQQQ
Definition: cddefines.cpp:7
void iso_put_error(long ipISO, long nelem, long ipHi, long ipLo, long whichData, realnum errorOpt, realnum errorPess)
#define MIN2(a, b)
Definition: cddefines.h:803
#define IPRAD
Definition: iso.h:88
STATIC double hydro_transprob_collapsed_to_resolved(long nelem, long nHi, long nLo, long lLo)
multi_arr< long, 3 > IndexIfAllResolved
Definition: iso.h:492
t_iso_sp iso_sp[NISO][LIMELM]
Definition: iso.cpp:11
long int n_HighestResolved_max
Definition: iso.h:536
#define L_(A_)
Definition: iso.h:23
#define POW2
Definition: cddefines.h:979
#define STATIC
Definition: cddefines.h:118
#define N_(A_)
Definition: iso.h:22
float realnum
Definition: cddefines.h:124
#define EXIT_FAILURE
Definition: cddefines.h:168
#define cdEXIT(FAIL)
Definition: cddefines.h:482
double powi(double, long int)
Definition: service.cpp:594
Definition: iso.h:470
#define ASSERT(exp)
Definition: cddefines.h:613
double HydroEinstA(long int n1, long int n2)
Definition: hydroeinsta.cpp:13
const int ipH_LIKE
Definition: iso.h:64
#define DEBUG_ENTRY(funcname)
Definition: cddefines.h:723
#define MAX2(a, b)
Definition: cddefines.h:824
int fprintf(const Output &stream, const char *format,...)
Definition: service.cpp:1121
#define POW4
Definition: cddefines.h:993
double H_Einstein_A(long int n, long int l, long int np, long int lp, long int iz)
realnum hydro_transprob(long nelem, long ipHi, long ipLo)
Definition: hydroeinsta.cpp:46