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
cool_punch.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
/*CoolPunch punch coolants */
4
#include "
cddefines.h
"
5
#include "
thermal.h
"
6
#include "
dynamics.h
"
7
#include "
radius.h
"
8
#include "
conv.h
"
9
#include "
phycon.h
"
10
#include "
punch.h
"
11
12
/* this is limit to number of coolants to print out */
13
static
const
int
IPRINT
= 100;
14
15
/*CoolPunch punch coolants */
16
void
CoolPunch
(FILE * io)
17
{
18
long
int
i,
19
ip,
20
is;
21
22
int
nFail;
23
24
double
cset,
25
cool_total,
26
heat_total;
27
28
realnum
29
*csav,
30
*sgnsav;
31
long
int
*index;
32
33
DEBUG_ENTRY
(
"CoolPunch()"
);
34
35
/* cannot do one-time init since thermal.ncltot can change */
36
index = (
long
int
*)
CALLOC
((
size_t
)
thermal
.
ncltot
,
sizeof
(
long
int));
37
csav = (
realnum
*)
CALLOC
((
size_t
)
thermal
.
ncltot
,
sizeof
(
realnum
));
38
sgnsav = (
realnum
*)
CALLOC
((
size_t
)
thermal
.
ncltot
,
sizeof
(
realnum
));
39
40
cool_total =
thermal
.
ctot
;
41
heat_total =
thermal
.
htot
;
42
43
/* >>chng 06 mar 17, comment out following block and replace with this
44
* removing dynamics heating & cooling and report only physical
45
* heating and cooling
46
* NB the heating and cooling as punched no longer need be
47
* equal for a converged model */
48
cool_total -=
dynamics
.
Cool
;
49
heat_total -=
dynamics
.
Heat
;
50
# if 0
51
if
(
dynamics
.
Cool
>
dynamics
.
Heat
)
52
{
53
cool_total -=
dynamics
.
Heat
;
54
heat_total -=
dynamics
.
Heat
;
55
}
56
else
57
{
58
cool_total -=
dynamics
.
Cool
;
59
heat_total -=
dynamics
.
Cool
;
60
}
61
# endif
62
63
/* cset will be weakest cooling to consider
64
* WeakHeatCool set with 'set weakheatcool' command
65
* default is 0.05 */
66
cset = cool_total*
punch
.
WeakHeatCool
;
67
68
/* first find all strong lines, both + and - sign */
69
ip =
thermal
.
ncltot
;
70
71
for
( i=0; i < ip; i++ )
72
{
73
csav[i] = (
realnum
)(
MAX2
(
thermal
.
cooling
[i],
thermal
.
heatnt
[i])/
74
cool_total);
75
76
/* save sign to remember if heating or cooling line */
77
if
(
thermal
.
heatnt
[i] == 0. )
78
{
79
sgnsav[i] = 1.;
80
}
81
else
82
{
83
sgnsav[i] = -1.;
84
}
85
}
86
87
/* order strongest to weakest */
88
/* now sort by decreasing importance */
89
/*spsort netlib routine to sort array returning sorted indices */
90
spsort
(
91
/* input array to be sorted */
92
csav,
93
/* number of values in x */
94
ip,
95
/* permutation output array */
96
index,
97
/* flag saying what to do - 1 sorts into increasing order, not changing
98
* the original routine */
99
-1,
100
/* error condition, should be 0 */
101
&nFail);
102
103
/* warn if tcovergence failure occurred */
104
if
( !
conv
.
lgConvTemp
)
105
{
106
fprintf( io,
"#>>>> Temperature not converged.\n"
);
107
}
108
else
if
( !
conv
.
lgConvEden
)
109
{
110
fprintf( io,
"#>>>> Electron density not converged.\n"
);
111
}
112
else
if
( !
conv
.
lgConvIoniz
)
113
{
114
fprintf( io,
"#>>>> Ionization not converged.\n"
);
115
}
116
else
if
( !
conv
.
lgConvPres
)
117
{
118
fprintf( io,
"#>>>> Pressure not converged.\n"
);
119
}
120
121
/*>>chng 06 jun 06, change start of punch to give same info as heating
122
* as per comment by Yumihiko Tsuzuki */
123
/* begin the print out with zone number, total heating and cooling */
124
fprintf( io,
"%.5e\t%.4e\t%.4e\t%.4e"
,
125
radius
.
depth_mid_zone
,
126
phycon
.
te
,
127
heat_total,
128
cool_total );
129
130
/* print only up to IPRINT, which is defined above */
131
ip =
MIN2
( ip ,
IPRINT
);
132
133
/* now print the coolants
134
* keep sign of coolant, for strong negative cooling
135
* order is ion, wavelength, fraction of total */
136
for
( is=0; is < ip; is++ )
137
{
138
if
(is > 4 && (
thermal
.
cooling
[index[is]] < cset &&
thermal
.
heatnt
[index[is]] < cset))
139
break
;
140
fprintf( io,
"\t%s %.1f\t%.7f"
,
141
thermal
.
chClntLab
[index[is]],
142
thermal
.
collam
[index[is]],
143
sign
(csav[index[is]],sgnsav[index[is]]) );
144
}
145
fprintf( io,
" \n"
);
146
147
/* finished, now free space */
148
free(sgnsav);
149
free(csav);
150
free(index);
151
return
;
152
}
Generated for cloudy by
1.8.1.1