cloudy  trunk
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
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 }
#define MIN2
Definition: cddefines.h:765
void iso_continuum_lower(long ipISO, long nelem)
bool lgHeBug
Definition: trace.h:82
t_isoCTRL iso_ctrl
Definition: iso.cpp:6
#define MAX2
Definition: cddefines.h:786
long int nCollapsed_max
Definition: iso.h:487
t_conv conv
Definition: conv.cpp:5
long iso_get_total_num_levels(long ipISO, long nmaxResolved, long numCollapsed)
t_phycon phycon
Definition: phycon.cpp:6
t_dense dense
Definition: dense.cpp:24
FILE * ioQQQ
Definition: cddefines.cpp:7
double xIonDense[LIMELM][LIMELM+1]
Definition: dense.h:125
const double MAX_DENSITY
Definition: cddefines.h:273
t_iso_sp iso_sp[NISO][LIMELM]
Definition: iso.cpp:8
long int n_HighestResolved_local
Definition: iso.h:507
t_trace trace
Definition: trace.cpp:5
long int n_HighestResolved_max
Definition: iso.h:505
bool lgLevelsLowered
Definition: iso.h:474
long int nLyman[NISO]
Definition: iso.h:334
#define INT16_MAX
Definition: cpu.h:16
bool lgTrace
Definition: trace.h:12
realnum xNucleiTotal
Definition: dense.h:104
bool lgLevelsEverLowered
Definition: iso.h:478
long int nTotalIoniz
Definition: conv.h:166
TransitionProxy trans(const long ipHi, const long ipLo)
Definition: iso.h:444
Definition: iso.h:441
#define ASSERT(exp)
Definition: cddefines.h:582
bool lgHBug
Definition: trace.h:85
const int LIMELM
Definition: cddefines.h:262
CollisionProxy Coll() const
Definition: transition.h:424
const int ipHELIUM
Definition: cddefines.h:310
#define MIN3(a, b, c)
Definition: cddefines.h:770
double eden
Definition: dense.h:190
long int numLevels_max
Definition: iso.h:493
void CollisionZero(const CollisionProxy &t)
Definition: collision.cpp:81
double te
Definition: phycon.h:11
const int ipHYDROGEN
Definition: cddefines.h:309
long int numLevels_local
Definition: iso.h:498
long int nCollapsed_local
Definition: iso.h:488
long int nLyman_malloc[NISO]
Definition: iso.h:334
bool lgMustReeval
Definition: iso.h:481