-
Notifications
You must be signed in to change notification settings - Fork 7
/
cooling_poly.h
220 lines (155 loc) · 6.93 KB
/
cooling_poly.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
#ifndef COOLING_COSMO_HINCLUDED
#define COOLING_COSMO_HINCLUDED
#ifndef LOG_HINCLUDED
#include "log.h"
#endif
/* Global consts */
#if defined(COOLDEBUG) || defined(STARFORM)
#include "mdl.h"
#else
#endif
#include "floattype.h"
#include "param.h"
/* Constants */
#define CL_B_gm (6.022e23*(938.7830/931.494))
#define CL_k_Boltzmann 1.38066e-16
#define CL_eV_erg 1.60219e-12
#define CL_eV_per_K (CL_k_Boltzmann/CL_eV_erg)
/*
* Work around for Dec ev6 flawed
* treatment of sub-normal numbers
*/
#define CL_MAX_NEG_EXP_ARG -500.
#define CL_NMAXBYTETABLE 56000
typedef struct CoolingParametersStruct {
double BaseT;
double dParam2;
double dParam3;
double dParam4;
double Y_Total;
double dCoolingTmin;
double dCoolingTmax;
} COOLPARAM;
/* How to do a dummy? --> can't I guess */
typedef struct CoolingParticleStruct {
FLOAT Y_Total;
} COOLPARTICLE;
/* Heating Cooling Context */
typedef struct CoolingPKDStruct {
double z; /* Redshift */
double dTime;
double dGmPerCcUnit;
double dComovingGmPerCcUnit;
double dErgPerGmUnit;
double dSecUnit;
double dErgPerGmPerSecUnit;
double diErgPerGmUnit;
double dKpcUnit;
double BaseT;
double dParam2;
double dParam3;
double dParam4;
double Y_Total;
double Tmin;
double Tmax;
void *DerivsData;
int nTableRead; /* Internal Tables read from Files */
#if defined(COOLDEBUG) || defined(STARFORM)
MDL mdl; /* For diag/debug outputs */
struct particle *p; /* particle pointer needed for SN feedback */
#endif
} COOL;
typedef struct clDerivsDataStruct {
void *IntegratorContext;
COOL *cl;
double rho,PdV,E,T,Y_Total,rFactor;
double dlnE;
int its; /* Debug */
} clDerivsData;
COOL *CoolInit( );
void CoolFinalize( COOL *cl );
void clInitConstants( COOL *cl, double dGMPerCcunit, double dComovingGmPerCcUnit,
double dErgPerGmUnit, double dSecUnit, double dKpcUnit, COOLPARAM CoolParam);
void clInitUV(COOL *cl, int nTableColumns, int nTableRows, double *dTableData );
void clInitRatesTable( COOL *cl, double TMin, double TMax, int nTable );
void CoolInitRatesTable( COOL *cl, COOLPARAM CoolParam);
double clThermalEnergy( double Y_Total, double T );
double clTemperature( double Y_Total, double E );
double clEdotInstant( COOL *cl, double E, double T, double rho, double r );
void clIntegrateEnergy(COOL *cl, double *E,
double PdV, double rho, double Y_Total, double radius, double tStep );
void clDerivs(void *Data, double x, double *y, double *dydx) ;
void clJacobn(void *Data, double x, double y[], double dfdx[], double **dfdy) ;
void CoolAddParams( COOLPARAM *CoolParam, PRM );
void CoolLogParams( COOLPARAM *CoolParam, LOGGER *lgr);
void CoolOutputArray( COOLPARAM *CoolParam, int, int *, char * );
#define COOL_ARRAY0_EXT "Y"
FLOAT COOL_ARRAY0(COOL *cl,COOLPARTICLE *cp, float *Z);
#define COOL_ARRAY0( cl_, cp, Z_ ) ((cp)->Y_Total)
#define COOL_ARRAY1_EXT "junk"
FLOAT COOL_ARRAY1(COOL *cl,COOLPARTICLE *cp, float *Z);
#define COOL_ARRAY1( cl_, cp, Z_ ) (0)
#define COOL_ARRAY2_EXT "junk2"
FLOAT COOL_ARRAY2(COOL *cl,COOLPARTICLE *cp, float *Z);
#define COOL_ARRAY2( cl_, cp, Z_ ) (0)
FLOAT COOL_EDOT( COOL *cl_, COOLPARTICLE *cp_, double ECode_, double rhoCode_, double ZMetal_, double *posCode_ );
#define COOL_EDOT( cl_, cp_, ECode_, rhoCode_, ZMetal_, posCode_) (CoolCodeWorkToErgPerGmPerSec( cl_, CoolEdotInstantCode( cl_, cp_, ECode_, rhoCode_, ZMetal_, posCode_ )))
FLOAT COOL_COOLING( COOL *cl_, COOLPARTICLE *cp_, double ECode_, double rhoCode_, double ZMetal_, double *posCode_ );
#define COOL_COOLING( cl_, cp_, ECode_, rhoCode_, ZMetal_, posCode_) (CoolCodeWorkToErgPerGmPerSec( cl_, CoolEdotInstantCode( cl_, cp_, ECode_, rhoCode_, ZMetal_, posCode_ )))
FLOAT COOL_HEATING( COOL *cl_, COOLPARTICLE *cp_, double ECode_, double rhoCode_, double ZMetal_, double *posCode_ );
#define COOL_HEATING( cl_, cp_, ECode_, rhoCode_, ZMetal_, posCode_) (0)
double CoolCodeEnergyToTemperature( COOL *Cool, COOLPARTICLE *cp, double E, double, double ZMetal );
/* Note: nod to cosmology (z parameter) unavoidable unless we want to access cosmo.[ch] from here */
void CoolSetTime( COOL *Cool, double dTime, double z );
double CoolCodeTimeToSeconds( COOL *Cool, double dCodeTime );
#define CoolCodeTimeToSeconds( Cool, dCodeTime ) ((Cool)->dSecUnit*(dCodeTime))
double CoolSecondsToCodeTime( COOL *Cool, double dTime );
#define CoolSecondsToCodeTime( Cool, dTime ) ((dTime)/(Cool)->dSecUnit)
double CoolCodeEnergyToErgPerGm( COOL *Cool, double dCodeEnergy );
#define CoolCodeEnergyToErgPerGm( Cool, dCodeEnergy ) ((Cool)->dErgPerGmUnit*(dCodeEnergy))
double CoolErgPerGmToCodeEnergy( COOL *Cool, double dEnergy );
#define CoolErgPerGmToCodeEnergy( Cool, dEnergy ) ((Cool)->diErgPerGmUnit*(dEnergy))
double CoolCodeWorkToErgPerGmPerSec( COOL *Cool, double dCodeWork );
#define CoolCodeWorkToErgPerGmPerSec( Cool, dCodeWork ) ((Cool)->dErgPerGmPerSecUnit*(dCodeWork))
double CoolErgPerGmPerSecToCodeWork( COOL *Cool, double dWork );
#define CoolErgPerGmPerSecToCodeWork( Cool, dWork ) ((dWork)/(Cool)->dErgPerGmPerSecUnit)
double CodeDensityToComovingGmPerCc( COOL *Cool, double dCodeDensity );
#define CodeDensityToComovingGmPerCc( Cool, dCodeDensity ) ((Cool)->dComovingGmPerCcUnit*(dCodeDensity))
void CoolIntegrateEnergy(COOL *cl, COOLPARTICLE *cp, double *E,
double PdV, double rho, double ZMetal, double tStep );
void CoolIntegrateEnergyCode(COOL *cl, COOLPARTICLE *cp, double *E,
double PdV, double rho, double ZMetal, double *r, double tStep );
void CoolDefaultParticleData( COOLPARTICLE *cp );
void CoolInitEnergyAndParticleData( COOL *cl, COOLPARTICLE *cp, double *E, double dDensity, double dTemp, double ZMetal );
/* Deprecated */
double CoolHeatingRate( COOL *cl, COOLPARTICLE *cp, double E, double dDensity );
double CoolEdotInstantCode(COOL *cl, COOLPARTICLE *cp, double ECode,
double rhoCode, double ZMetal, double *posCode );
/* Make sure a default polytrope is defined */
#if !defined(WOLFIRE) && !defined(MODBATEPOLY)
#undef BATEPOLY
#endif
void WolfirePressureEnergySoundSpeed(double rho,double *u,double *PonRho,double *T);
void CoolCodePressureOnDensitySoundSpeed( COOL *cl, COOLPARTICLE *cp, double uPred, double fDensity, double gamma, double gammam1, double *PoverRho, double *c );
/*
double CoolCodePressureOnDensity( COOL *cl, COOLPARTICLE *cp, double uPred, double fDensity, double gammam1 );
#define CoolCodePressureOnDensity( cl, cp, uPred, fDensity, gammam1 ) ((gammam1)*(uPred))
*/
struct inInitCooling {
double dGmPerCcUnit;
double dComovingGmPerCcUnit;
double dErgPerGmUnit;
double dSecUnit;
double dKpcUnit;
double z;
double dTime;
COOLPARAM CoolParam;
};
struct inInitEnergy {
double dTuFac;
double z;
double dTime;
};
void CoolTableReadInfo( COOLPARAM *CoolParam, int cntTable, int *nTableColumns, char *suffix );
void CoolTableRead( COOL *Cool, int nData, void *vData);
#endif