cloudy  trunk
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
eden_change.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 /*EdenChange - update electron density and its dependent quantities */
4 #include "cddefines.h"
5 #include "dense.h"
6 #include "rfield.h"
7 #include "phycon.h"
8 #include "conv.h"
9 #include "rt.h"
10 
11 void EdenChange( double EdenNew )
12 {
13  static double EdenOld=-1;
14 
15  DEBUG_ENTRY( "EdenChange()" );
16 
17  // don't let electron density be zero - logs are taken
18  ASSERT( EdenNew > 0. );
19 
20  // init EdenOld on first sweep through this sim
21  if( conv.nTotalIoniz==0 )
22  EdenOld = dense.eden;
23 
24  // this confirms that eden is only changed in this routine
25  if( !fp_equal( dense.eden, EdenOld ) )
26  TotalInsanity();
27 
28  dense.eden = EdenNew;
29  EdenOld = EdenNew;
30 
32  /* dense.HCorrFac is unity by default and changed with the set HCOR command */
36  dense.cdsqte = dense.edensqte*COLL_CONST;
37  dense.SqrtEden = sqrt(dense.eden);
38 
39  /* evaluate the plasma frequency one time per zone to avoid PF moving across
40  * a line during convergence loops */
42  {
44  rfield.plsfrq = (realnum)((ELEM_CHARGE_ESU/sqrt(PI*ELECTRON_MASS)/FR1RYD)*sqrt(dense.eden));
45 
46  if( rfield.ipPlasma > 0 )
47  {
48  /* increase index for plasma frequency until within proper cell */
50  ++rfield.ipPlasma;
51 
52  /* decrease index for plasma frequency until within proper cell */
54  --rfield.ipPlasma;
55  }
56 
57  /* also remember the largest plasma frequency we encounter */
59 
60  /* is plasma frequency within energy grid? */
61  if( rfield.plsfrq > rfield.anu(0) )
62  {
63  rfield.lgPlasNu = true;
64  }
65  }
66 
67  // if plasma frequency has changed we need to update transitions - those
68  // below plasma frequency do not exist - emission rate set to smallfloat
69  // only do this in search phase since plasma frequency moving across transition
70  // would create discontinuous changes in cooling that would present noise
71  // to the solver. The electron density should not change by much during the
72  // solution for a zone
73  static double EdenEval=-1;
74  if( conv.lgSearch && !fp_equal(EdenEval,dense.eden) )
75  {
76  EdenEval = dense.eden;
77  RT_line_all_escape ( NULL );
78  }
79 
80  return;
81 }
NORETURN void TotalInsanity(void)
Definition: service.cpp:971
double EdenHCorr
Definition: dense.h:227
double cdsqte
Definition: dense.h:246
realnum HCorrFac
Definition: dense.h:121
t_conv conv
Definition: conv.cpp:5
t_phycon phycon
Definition: phycon.cpp:6
long int nZonePlsFrqEval
Definition: rfield.h:434
long int nzone
Definition: cddefines.cpp:14
void RT_line_all_escape(realnum *error)
Definition: rt_line_all.cpp:21
double anu(size_t i) const
Definition: mesh.h:120
t_dense dense
Definition: global.cpp:15
double edensqte
Definition: dense.h:241
double xIonDense[LIMELM][LIMELM+1]
Definition: dense.h:135
bool lgSearch
Definition: conv.h:168
bool fp_equal(sys_float x, sys_float y, int n=3)
Definition: cddefines.h:854
long int ipPlasma
Definition: rfield.h:436
t_rfield rfield
Definition: rfield.cpp:9
float realnum
Definition: cddefines.h:124
double anumin(size_t i) const
Definition: mesh.h:148
long int nTotalIoniz
Definition: conv.h:159
#define ASSERT(exp)
Definition: cddefines.h:613
#define DEBUG_ENTRY(funcname)
Definition: cddefines.h:723
realnum EdenHCorr_f
Definition: dense.h:229
double eden
Definition: dense.h:201
#define MAX2(a, b)
Definition: cddefines.h:824
double SqrtEden
Definition: dense.h:223
double anumax(size_t i) const
Definition: mesh.h:152
void EdenChange(double EdenNew)
Definition: eden_change.cpp:11
double sqrte
Definition: phycon.h:58
realnum plsfrqmax
Definition: rfield.h:430
const int ipHYDROGEN
Definition: cddefines.h:349
realnum plsfrq
Definition: rfield.h:430
bool lgPlasNu
Definition: rfield.h:428