cloudy
trunk
Main Page
Related Pages
Data Structures
Files
File List
Globals
All
Data Structures
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Pages
source
opacity_add1element.cpp
Go to the documentation of this file.
1
/* This file is part of Cloudy and is copyright (C)1978-2008 by Gary J. Ferland and
2
* others. For conditions of distribution and use see copyright notice in license.txt */
3
/*OpacityAdd1Element enter total photo cross section for all subshells into opacity array */
4
#include "
cddefines.h
"
5
#include "
iso.h
"
6
#include "
rfield.h
"
7
#include "
dense.h
"
8
#include "
heavy.h
"
9
#include "
opacity.h
"
10
11
void
OpacityAdd1Element
(
12
/* nelem is 0 for H, 1 for He, etc */
13
long
int
nelem)
14
{
15
long
int
ipHi,
16
ipop,
17
limit,
18
low,
19
n,
20
ion,
21
nshell;
22
char
chStat;
23
double
abundance;
24
25
DEBUG_ENTRY
(
"OpacityAdd1Element()"
);
26
27
/* this routine drives OpacityAdd1Subshell to put in total opacities for all shells*/
28
29
/*begin sanity check */
30
ASSERT
( (nelem >=0 ) && (nelem <
LIMELM
) );
31
32
/* first do simple two-level systems -
33
* this is number of species that are not treated on common iso-electronic series */
34
limit = nelem + 1 -
NISO
;
35
/* this can be called with hydrogen itself, in which case nelem is 0, and limit is
36
* -1 - do not do any of the simple ions */
37
limit =
MAX2
( 0 , limit );
38
39
/* do not include the ion stages that have complete atoms,
40
* currently H and He like iso sequences */
41
for
( ion=0; ion < limit; ion++ )
42
{
43
if
(
dense
.
xIonDense
[nelem][ion] > 0. )
44
{
45
/*start with static opacities, then do volatile*/
46
47
chStat =
's'
;
48
/* number of bound electrons */
49
for
( nshell=0; nshell <
Heavy
.
nsShells
[nelem][ion]; nshell++ )
50
{
51
/* highest shell will be volatile*/
52
if
( nshell==
Heavy
.
nsShells
[nelem][ion]-1 )
53
chStat =
'v'
;
54
/* set lower and upper limits to this range */
55
low =
opac
.
ipElement
[nelem][ion][nshell][0];
56
ipHi =
opac
.
ipElement
[nelem][ion][nshell][1];
57
ipop =
opac
.
ipElement
[nelem][ion][nshell][2];
58
/* OpacityAdd1Subshell will not do anything if static opacities do not need to be reset*/
59
OpacityAdd1Subshell
(ipop,low,ipHi,
dense
.
xIonDense
[nelem][ion] , chStat );
60
}
61
}
62
}
63
64
/* now loop over all species done as large multi-level systems */
65
/* >>chng 02 jan 17, add loop over H and He like */
66
/* ion is on the c scale, =0 for HI, =1 for HeII */
67
for
( ion=limit; ion<nelem+1; ++ion )
68
{
69
/* ipISO is 0 for H-like, 1 for He-like */
70
long
int
ipISO = nelem-ion;
71
72
/* do multi level systems, but only if present
73
* test for nelem+1 in case atom present but not ion, test is whether the
74
* abundance of the recombined species is present */
75
/* >>chng 02 jan 17, sec dim had been nelem+1, change to ion+1 */
76
/*if( dense.xIonDense[nelem][nelem] > 0. )*/
77
if
(
dense
.
xIonDense
[nelem][ion] > 0. )
78
{
79
ASSERT
( ipISO < NISO );
80
81
/* do ground first, then all excited states */
82
n = 0;
83
/* abundance of recombined species, which can be zero if no ion present */
84
abundance =
StatesElem
[ipISO][nelem][n].Pop*
dense
.
xIonDense
[nelem][ion+1];
85
86
/* >>chng 02 may 06, add second test, had been just the chck on helium,
87
* with no option to use new soln */
88
if
( abundance == 0. )
89
{
90
/* no ionized species, assume everything in ground */
91
abundance =
dense
.
xIonDense
[nelem][ion];
92
}
93
94
/* >>chng 02 jan 17, to arbitrary iso sequence */
95
/* use computed opacities and departure coef for level */
96
OpacityAdd1SubshellInduc
(
97
iso
.
ipOpac
[ipISO][nelem][n],
98
iso
.
ipIsoLevNIonCon
[ipISO][nelem][n],
99
/* the upper limit to the integration,
100
* ground opacity goes up to the high-energy limit of code*/
101
rfield
.
nflux
,
102
/* the abundance of the ion */
103
abundance,
104
/* departure coef, volatile opac, always reevaluate */
105
iso
.
DepartCoef
[ipISO][nelem][n] ,
'v'
);
106
107
/* do excited levvels,
108
* this loop only if upper levels have finite population*/
109
if
(
StatesElem
[ipISO][nelem][3].Pop*
dense
.
xIonDense
[nelem][ion+1] > 0. )
110
{
111
char
chType =
'v'
;
112
/* always want to evaluate all opacities for n=3, 4, use static opacities for higher levels */
113
/* >>chng 06 aug 17, should go to numLevels_local instead of _max */
114
for
(
long
level =1; level <
iso
.
numLevels_local
[ipISO][nelem]; level++ )
115
{
116
/* above 4 is static */
117
if
(
StatesElem
[ipISO][nelem][level].n >= 5 )
118
chType =
's'
;
119
120
/* include correction for stimulated emission */
121
OpacityAdd1SubshellInduc
(
122
iso
.
ipOpac
[ipISO][nelem][level],
123
iso
.
ipIsoLevNIonCon
[ipISO][nelem][level],
124
/* the high energy bound of excited states is the
125
* edge of the Lyman continuum */
126
iso
.
ipIsoLevNIonCon
[ipISO][nelem][0],
127
StatesElem
[ipISO][nelem][level].Pop*
dense
.
xIonDense
[nelem][ion+1],
128
/* departure coef, volitile opacities */
129
iso
.
DepartCoef
[ipISO][nelem][level] , chType );
130
}
131
}
132
}
133
}
134
return
;
135
}
Generated for cloudy by
1.8.3.1