cloudy
trunk
source
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
12
void
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
;
74
RT_line_all
();
75
}
76
77
return
;
78
}
RT_line_all
void RT_line_all(void)
Definition:
rt_line_all.cpp:26
thermal.h
ELEM_CHARGE_ESU
const UNUSED double ELEM_CHARGE_ESU
Definition:
physconst.h:147
FR1RYD
const UNUSED double FR1RYD
Definition:
physconst.h:195
t_rfield::plsfrq
realnum plsfrq
Definition:
rfield.h:447
t_dense::eden
double eden
Definition:
dense.h:190
t_dense::EdenHCorr
double EdenHCorr
Definition:
dense.h:216
dense
t_dense dense
Definition:
dense.cpp:24
t_dense::cdsqte
double cdsqte
Definition:
dense.h:235
rfield
t_rfield rfield
Definition:
rfield.cpp:8
t_dense::edensqte
double edensqte
Definition:
dense.h:230
realnum
float realnum
Definition:
cddefines.h:103
conv.h
rfield.h
t_rfield::ipPlasma
long int ipPlasma
Definition:
rfield.h:453
t_dense::SqrtEden
double SqrtEden
Definition:
dense.h:212
phycon
t_phycon phycon
Definition:
phycon.cpp:6
ASSERT
#define ASSERT(exp)
Definition:
cddefines.h:578
ipHYDROGEN
const int ipHYDROGEN
Definition:
cddefines.h:305
t_rfield::nZonePlsFrqEval
long int nZonePlsFrqEval
Definition:
rfield.h:451
nzone
long int nzone
Definition:
cddefines.cpp:14
t_dense::HCorrFac
realnum HCorrFac
Definition:
dense.h:111
PI
const UNUSED double PI
Definition:
physconst.h:29
dense.h
cddefines.h
ELECTRON_MASS
const UNUSED double ELECTRON_MASS
Definition:
physconst.h:91
MAX2
#define MAX2
Definition:
cddefines.h:782
t_dense::EdenHCorr_f
realnum EdenHCorr_f
Definition:
dense.h:218
t_dense::xIonDense
double xIonDense[LIMELM][LIMELM+1]
Definition:
dense.h:125
t_rfield::lgPlasNu
bool lgPlasNu
Definition:
rfield.h:445
rt.h
t_rfield::anu
double * anu
Definition:
rfield.h:58
t_conv::nTotalIoniz
long int nTotalIoniz
Definition:
conv.h:166
fp_equal
bool fp_equal(sys_float x, sys_float y, int n=3)
Definition:
cddefines.h:812
COLL_CONST
const UNUSED double COLL_CONST
Definition:
physconst.h:229
conv
t_conv conv
Definition:
conv.cpp:5
t_rfield::widflx
realnum * widflx
Definition:
rfield.h:65
EdenChange
void EdenChange(double EdenNew)
Definition:
eden_change.cpp:12
phycon.h
t_phycon::sqrte
double sqrte
Definition:
phycon.h:48
t_conv::lgSearch
bool lgSearch
Definition:
conv.h:175
t_rfield::plsfrqmax
realnum plsfrqmax
Definition:
rfield.h:449
DEBUG_ENTRY
#define DEBUG_ENTRY(funcname)
Definition:
cddefines.h:684
Generated by
1.8.17