cloudy  trunk
iso_continuum_lower.cpp
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 /*iso_continuum_lower - limit max prin. quan. no. due to continuum lowering processes */
4 #include "cddefines.h"
5 #include "phycon.h"
6 #include "dense.h"
7 #include "conv.h"
8 #include "iso.h"
9 #include "hydrogenic.h"
10 #include "trace.h"
11 
12 void iso_continuum_lower( long ipISO, long nelem )
13 {
14  double a;
15  long int np, nd, ns, nc;
16  long eff_charge;
17 
18  t_iso_sp* sp = &iso_sp[ipISO][nelem];
19 
20  /* size of rate matrices will be defined according to the n calculated here */
21 
23  ASSERT( nelem < LIMELM );
24  /* this may change at a future date. */
25  ASSERT( ipISO <= 1 );
26 
27  eff_charge = nelem + 1 - ipISO;
28 
29  /* Particle packing - the density here should be density of all nuclei in the plasma */
30  /* This one is just nuclear charge, which is independent of iso, and always nelem+1. */
31  a = sqrt( 1.8887E8 * (nelem+1.) / pow((double)dense.xNucleiTotal, 0.333) );
32  ASSERT( a > 0. );
33  np = (long)( MIN2((double)INT16_MAX,floor(a)) );
34 
35  /* Debye shielding - the density here is electron density */
36  /* This one depends on effective charge. */
37  a = 2.6E7 * eff_charge * eff_charge * pow( phycon.te/dense.eden, 0.25);
38  ASSERT( a > 0. );
39  nd = (long)( MIN2((double)INT16_MAX,floor(a)) );
40 
41  /* Stark broadening - this should be the density of singly charged ions,
42  * both positive and negative. The sum of protons, electrons, and HeII should be
43  * good enough. */
44  /* This one depends on effective charge. */
45  a = 3171. * pow( (double)eff_charge, 0.8 ) * pow( dense.eden + (double)dense.xIonDense[ipHYDROGEN][1]
46  + (double)dense.xIonDense[ipHELIUM][1], -0.1333);
47  ASSERT( a > 0. );
48  ns = (long)( MIN2((double)INT16_MAX,floor(a)) );
49 
50  nc = MIN3(np, nd, ns);
51  /* Don't allow continuum to be lowered below n=3. */
52  nc = MAX2( nc, 3 );
53 
54  if( nc <= sp->n_HighestResolved_max)
55  {
56  sp->lgLevelsLowered = true;
57  sp->lgLevelsEverLowered = true;
58  sp->lgMustReeval = true;
59  sp->n_HighestResolved_local = nc;
60  sp->nCollapsed_local = 0;
61  sp->numLevels_local = iso_get_total_num_levels( ipISO, nc, 0 );
62  }
63  /* Here is the case where the critical n lies among the one or more collapsed levels */
64  /* we just get rid of any that are too high. */
65  else if( nc <= sp->n_HighestResolved_max + sp->nCollapsed_max )
66  {
67  sp->lgLevelsLowered = true;
68  sp->lgLevelsEverLowered = true;
69  sp->lgMustReeval = true;
72  sp->numLevels_local =
74  }
75  /* This is usually where control will flow, because in most conditions the continuum will not be lowered.
76  * Nothing changes in this case. */
77  else
78  {
82 
83  /* if levels were lowered on last pass but are not now, must reeval */
84  if( sp->lgLevelsLowered )
85  {
86  sp->lgMustReeval = true;
87  }
88  else
89  {
90  sp->lgMustReeval = false;
91  }
92 
93  sp->lgLevelsLowered = false;
94  }
95 
96  if( !conv.nTotalIoniz )
97  sp->lgMustReeval = true;
98 
99  /* None of these can be greater than that which was originally malloc'd. */
100  ASSERT( sp->numLevels_local <= sp->numLevels_max );
101  ASSERT( sp->nCollapsed_local <= sp->nCollapsed_max );
103 
104  /* Lyman lines can not be greater than original malloc or critical pqn. */
105  iso_ctrl.nLyman[ipISO] = MIN2( nc, iso_ctrl.nLyman_malloc[ipISO]);
106 
107  // zero out cooling and heating terms involving unused levels
108  for( long ipHi=sp->numLevels_local; ipHi < sp->numLevels_max; ++ipHi )
109  {
110  for( long ipLo=0; ipLo < ipHi; ++ipLo )
111  CollisionZero( sp->trans(ipHi,ipLo).Coll() );
112  }
113 
114  if( trace.lgTrace && (trace.lgHBug||trace.lgHeBug) )
115  {
116  fprintf( ioQQQ," iso_continuum_lower: ipISO %li nelem %li nc %li (np:%li,nd:%li,ns:%li) numLevels %li nCollapsed %li n_HighestResolved %li \n",
117  ipISO,
118  nelem,
119  nc,
120  np, nd, ns,
121  sp->numLevels_local,
122  sp->nCollapsed_local,
124  );
125  }
126 
127  return;
128 }
iso_continuum_lower
void iso_continuum_lower(long ipISO, long nelem)
Definition: iso_continuum_lower.cpp:12
t_trace::lgHeBug
bool lgHeBug
Definition: trace.h:82
t_dense::eden
double eden
Definition: dense.h:190
dense
t_dense dense
Definition: dense.cpp:24
t_iso_sp::n_HighestResolved_max
long int n_HighestResolved_max
Definition: iso.h:505
ioQQQ
FILE * ioQQQ
Definition: cddefines.cpp:7
conv.h
MIN3
#define MIN3(a, b, c)
Definition: cddefines.h:766
t_iso_sp::numLevels_local
long int numLevels_local
Definition: iso.h:498
phycon
t_phycon phycon
Definition: phycon.cpp:6
trace.h
t_isoCTRL::nLyman_malloc
long int nLyman_malloc[NISO]
Definition: iso.h:336
t_iso_sp
Definition: iso.h:441
ASSERT
#define ASSERT(exp)
Definition: cddefines.h:578
iso.h
t_iso_sp::lgLevelsLowered
bool lgLevelsLowered
Definition: iso.h:474
ipHYDROGEN
const int ipHYDROGEN
Definition: cddefines.h:305
TransitionProxy::Coll
CollisionProxy Coll() const
Definition: transition.h:424
MIN2
#define MIN2
Definition: cddefines.h:761
t_iso_sp::nCollapsed_local
long int nCollapsed_local
Definition: iso.h:488
t_iso_sp::lgLevelsEverLowered
bool lgLevelsEverLowered
Definition: iso.h:478
INT16_MAX
#define INT16_MAX
Definition: cpu.h:22
dense.h
CollisionZero
void CollisionZero(const CollisionProxy &t)
Definition: collision.cpp:81
trace
t_trace trace
Definition: trace.cpp:5
cddefines.h
t_iso_sp::numLevels_max
long int numLevels_max
Definition: iso.h:493
MAX_DENSITY
const double MAX_DENSITY
Definition: cddefines.h:269
MAX2
#define MAX2
Definition: cddefines.h:782
LIMELM
const int LIMELM
Definition: cddefines.h:258
t_iso_sp::nCollapsed_max
long int nCollapsed_max
Definition: iso.h:487
t_isoCTRL::nLyman
long int nLyman[NISO]
Definition: iso.h:334
t_dense::xIonDense
double xIonDense[LIMELM][LIMELM+1]
Definition: dense.h:125
hydrogenic.h
t_conv::nTotalIoniz
long int nTotalIoniz
Definition: conv.h:166
t_iso_sp::lgMustReeval
bool lgMustReeval
Definition: iso.h:481
t_dense::xNucleiTotal
realnum xNucleiTotal
Definition: dense.h:104
conv
t_conv conv
Definition: conv.cpp:5
iso_ctrl
t_isoCTRL iso_ctrl
Definition: iso.cpp:6
ipHELIUM
const int ipHELIUM
Definition: cddefines.h:306
t_iso_sp::trans
TransitionProxy trans(const long ipHi, const long ipLo)
Definition: iso.h:444
phycon.h
t_iso_sp::n_HighestResolved_local
long int n_HighestResolved_local
Definition: iso.h:507
t_trace::lgHBug
bool lgHBug
Definition: trace.h:85
iso_sp
t_iso_sp iso_sp[NISO][LIMELM]
Definition: iso.cpp:8
t_phycon::te
double te
Definition: phycon.h:11
iso_get_total_num_levels
long iso_get_total_num_levels(long ipISO, long nmaxResolved, long numCollapsed)
Definition: iso_create.cpp:1465
t_trace::lgTrace
bool lgTrace
Definition: trace.h:12