cloudy trunk
Loading...
Searching...
No Matches
eden_change.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/*EdenChange - update electron density and its dependent quantities */
4#include "cddefines.h"
5#include "dense.h"
6#include "rfield.h"
7#include "thermal.h"
8#include "phycon.h"
9#include "conv.h"
10#include "rt.h"
11
12void EdenChange( double EdenNew )
13{
14 static double EdenOld=-1;
15
16 DEBUG_ENTRY( "EdenChange()" );
17
18 // init EdenOld on first sweep through this sim
19 if( conv.nTotalIoniz==0 )
20 EdenOld = dense.eden;
21
22 // this confirms that eden is only changed in this routine
23 ASSERT( fp_equal(dense.eden , EdenOld ) );
24
25 dense.eden = EdenNew;
26 EdenOld = EdenNew;
27
28 dense.EdenHCorr = dense.eden +
29 /* dense.HCorrFac is unity by default and changed with the set HCOR command */
30 dense.xIonDense[ipHYDROGEN][0]*1.7e-4 * dense.HCorrFac;
31 dense.EdenHCorr_f = (realnum)dense.EdenHCorr;
32 dense.edensqte = dense.EdenHCorr/phycon.sqrte;
33 dense.cdsqte = dense.edensqte*COLL_CONST;
34 dense.SqrtEden = sqrt(dense.eden);
35
36 /* evaluate the plasma frequency one time per zone to avoid PF moving across
37 * a line during convergence loops */
38 if( nzone != rfield.nZonePlsFrqEval || conv.lgSearch )
39 {
40 rfield.nZonePlsFrqEval = nzone;
41 rfield.plsfrq = (realnum)((ELEM_CHARGE_ESU/sqrt(PI*ELECTRON_MASS)/FR1RYD)*sqrt(dense.eden));
42
43 if( rfield.ipPlasma > 0 )
44 {
45 /* increase index for plasma frequency until within proper cell */
46 while( rfield.plsfrq > rfield.anu[rfield.ipPlasma]+rfield.widflx[rfield.ipPlasma]/2. )
47 ++rfield.ipPlasma;
48
49 /* decrease index for plasma frequency until within proper cell */
50 while( rfield.ipPlasma>2 && rfield.plsfrq < rfield.anu[rfield.ipPlasma]-rfield.widflx[rfield.ipPlasma]/2. )
51 --rfield.ipPlasma;
52 }
53
54 /* also remember the largest plasma frequency we encounter */
55 rfield.plsfrqmax = MAX2(rfield.plsfrqmax, rfield.plsfrq);
56
57 /* is plasma frequency within energy grid? */
58 if( rfield.plsfrq > rfield.anu[0] )
59 {
60 rfield.lgPlasNu = true;
61 }
62 }
63
64 // if plasma frequency has changed we need to update transitions - those
65 // below plasma frequency do not exist - emission rate set to smallfloat
66 // only do this in search phase since plasma frequency moving across transition
67 // would create discontinuous changes in cooling that would present noise
68 // to the solver. The electron density should not change by much during the
69 // solution for a zone
70 static double EdenEval=-1;
71 if( conv.lgSearch && !fp_equal(EdenEval,dense.eden) )
72 {
73 EdenEval = dense.eden;
75 }
76
77 return;
78}
long int nzone
Definition cddefines.cpp:14
#define ASSERT(exp)
Definition cddefines.h:578
float realnum
Definition cddefines.h:103
#define MAX2
Definition cddefines.h:782
bool fp_equal(sys_float x, sys_float y, int n=3)
Definition cddefines.h:812
const int ipHYDROGEN
Definition cddefines.h:305
#define DEBUG_ENTRY(funcname)
Definition cddefines.h:684
t_conv conv
Definition conv.cpp:5
t_dense dense
Definition dense.cpp:24
void EdenChange(double EdenNew)
t_phycon phycon
Definition phycon.cpp:6
UNUSED const double FR1RYD
Definition physconst.h:195
UNUSED const double PI
Definition physconst.h:29
UNUSED const double ELECTRON_MASS
Definition physconst.h:91
UNUSED const double COLL_CONST
Definition physconst.h:229
UNUSED const double ELEM_CHARGE_ESU
Definition physconst.h:147
t_rfield rfield
Definition rfield.cpp:8
void RT_line_all(void)