changa  3.5
 All Classes Files Functions Variables Typedefs Enumerations Friends Macros Groups Pages
cooling_planet.h
1 #ifndef COOLING_PLANET_HINCLUDED
2 #define COOLING_PLANET_HINCLUDED
3 /*
4  * Cooling code for planet formation simulations.
5  * Originally written by James Wadsley, McMaster University for
6  * GASOLINE.
7  *
8  * Updated for ChaNGa by Isaac Backus, University of Wasghinton
9  */
10 
11 #include "param.h"
12 
13 #ifdef __cplusplus
14 extern "C" {
15 #endif
16 
17 /* Constants */
18 #define CL_Rgascode 8.2494e7
19 #define CL_Eerg_gm_degK CL_Rgascode
20 #define CL_Eerg_gm_degK3_2 1.5*CL_Eerg_gm_degK
21 #define CL_NMAXBYTETABLE 56000
22 
23 typedef struct CoolingParametersStruct {
24  double Y_Total;
25  double dCoolingTmin;
26  double dCoolingTmax;
27  double dBetaCooling;
28 } COOLPARAM;
29 
30 typedef struct CoolingParticleStruct {
31  double Y_Total;
32 } COOLPARTICLE;
33 
34 typedef struct {
35  double Total;
36 } PERBARYON;
37 
38 typedef struct CoolingPKDStruct COOL;
39 
40 /* Per-thread data. Not used for this cooling algorithm */
41 typedef struct clDerivsDataStruct {
42 } clDerivsData;
43 
44 /* Heating Cooling Context */
45 
46 struct CoolingPKDStruct {
47  /* Cosmology hold-overs */
48  double z; /* Redshift */
49  double dTime;
50  /* Units and conversion constants */
51  double dGmPerCcUnit;
52  double dComovingGmPerCcUnit;
53  double dErgPerGmUnit;
54  double dSecUnit;
55  double dErgPerGmPerSecUnit;
56  double diErgPerGmUnit;
57  double dKpcUnit;
58  /* User parameters (see CoolAddParams) */
59  double Y_Total;
60  double Tmin;
61  double Tmax;
62  double beta;
63  /* Star info */
64  double dStarCenterOfMass[4];
65 
66  clDerivsData *DerivsData;
67 
68  int nTableRead; /* Internal Tables read from Files */
69 
70 };
71 
72 COOL *CoolInit( );
73 
75 void CoolFinalize( COOL *cl );
76 
77 clDerivsData *CoolDerivsInit(COOL *cl);
78 
79 void CoolDerivsFinalize(clDerivsData *cld ) ;
80 
81 void clInitConstants( COOL *cl, double dGMPerCcunit,
82  double dComovingGmPerCcUnit, double dErgPerGmUnit,
83  double dSecUnit, double dKpcUnit, COOLPARAM CoolParam);
84 
85 /* Doesn't do anything, needed by Sph.cpp */
86 void CoolInitRatesTable( COOL *cl, COOLPARAM CoolParam);
87 
88 double clThermalEnergy( double Y_Total, double T );
89 
90 double clTemperature( double Y_Total, double E );
91 
92 void CoolAddParams( COOLPARAM *CoolParam, PRM );
93 
94 // Saves CenterOfMass to cooling struct cl
95 void CoolSetStarCM(COOL *cl, double dCenterOfMass[4]);
96 
97 /* Needed by InOutput.h */
98 #define COOL_ARRAY0_EXT "Y_Total"
99 double COOL_ARRAY0(COOL *cl_, COOLPARTICLE *cp,double aa);
100 #define COOL_ARRAY0( cl_, cp, aa ) ((cp)->Y_Total)
101 double COOL_SET_ARRAY0(COOL *cl_, COOLPARTICLE *cp,double aa, double bb_val);
102 #define COOL_SET_ARRAY0( cl_, cp, aa, bb_val ) ((cp)->Y_Total = (bb_val))
103 
104 #define COOL_ARRAY1_EXT "NA"
105 double COOL_ARRAY1(COOL *cl_, COOLPARTICLE *cp,double aa);
106 #define COOL_ARRAY1( cl_, cp, aa ) (0)
107 double COOL_SET_ARRAY1(COOL *cl_, COOLPARTICLE *cp,double aa, double bb_val);
108 #define COOL_SET_ARRAY1( cl_, cp, aa, bb_val ) (0)
109 
110 #define COOL_ARRAY2_EXT "NA"
111 double COOL_ARRAY2(COOL *cl_, COOLPARTICLE *cp,double aa);
112 #define COOL_ARRAY2( cl_, cp, aa ) (0)
113 double COOL_SET_ARRAY2(COOL *cl_, COOLPARTICLE *cp,double aa, double bb_val);
114 #define COOL_SET_ARRAY2( cl_, cp, aa, bb_val ) (0)
115 
116 #define COOL_ARRAY3_EXT "H2"
117 double COOL_ARRAY3(COOL *cl, COOLPARTICLE *cp, double ZMetal);
118 #define COOL_ARRAY3(cl_, cp, aa ) (0)
119 double COOL_SET_ARRAY3(COOL *cl_, COOLPARTICLE *cp,double aa, double bb_val);
120 #define COOL_SET_ARRAY3( cl_, cp, aa, bb_val ) (0)
121 
123 double COOL_EDOT( COOL *cl_, COOLPARTICLE *cp_, double ECode_, double rhoCode_,
124  double ZMetal_, double *posCode_ );
125 #define COOL_EDOT( cl_, cp_, ECode_, rhoCode_, ZMetal_, posCode_) (0)
126 
128 double COOL_COOLING( COOL *cl_, COOLPARTICLE *cp_, double ECode_,
129  double rhoCode_, double ZMetal_, double *posCode_ );
130 #define COOL_COOLING( cl_, cp_, ECode_, rhoCode_, ZMetal_, posCode_) (0)
131 
132 void CoolPARTICLEtoPERBARYON(COOL *cl_, PERBARYON *Y, COOLPARTICLE *cp,
133  double HTotal, double HeTotal);
134 
135 #define CoolPARTICLEtoPERBARYON(cl_, Y, cp) { \
136  (Y)->Total = (cp)->Y_Total; }
137 
138 double CoolCodeEnergyToTemperature( COOL *Cool, COOLPARTICLE *cp, double E,
139  double fMetal );
140 
141 /* Note: nod to cosmology (z parameter) unavoidable unless we want to access
142  * cosmo.[ch] from here */
143 void CoolSetTime( COOL *Cool, double dTime, double z );
144 
145 /* Unit conversion routines */
146 
147 double CoolCodeTimeToSeconds( COOL *Cool, double dCodeTime );
148 
149 #define CoolCodeTimeToSeconds( Cool, dCodeTime ) ((Cool)->dSecUnit*(dCodeTime))
150 
151 double CoolSecondsToCodeTime( COOL *Cool, double dTime );
152 
153 #define CoolSecondsToCodeTime( Cool, dTime ) ((dTime)/(Cool)->dSecUnit)
154 
155 double CoolCodeEnergyToErgPerGm( COOL *Cool, double dCodeEnergy );
156 
157 #define CoolCodeEnergyToErgPerGm( Cool, dCodeEnergy ) \
158  ((Cool)->dErgPerGmUnit*(dCodeEnergy))
159 
160 double CoolErgPerGmToCodeEnergy( COOL *Cool, double dEnergy );
161 
162 #define CoolErgPerGmToCodeEnergy( Cool, dEnergy ) \
163  ((Cool)->diErgPerGmUnit*(dEnergy))
164 
165 double CoolCodeWorkToErgPerGmPerSec( COOL *Cool, double dCodeWork );
166 
167 #define CoolCodeWorkToErgPerGmPerSec( Cool, dCodeWork ) \
168  ((Cool)->dErgPerGmPerSecUnit*(dCodeWork))
169 
170 double CoolErgPerGmPerSecToCodeWork( COOL *Cool, double dWork );
171 
172 #define CoolErgPerGmPerSecToCodeWork( Cool, dWork ) \
173  ((dWork)/(Cool)->dErgPerGmPerSecUnit)
174 
175 double CodeDensityToComovingGmPerCc( COOL *Cool, double dCodeDensity );
176 
177 #define CodeDensityToComovingGmPerCc( Cool, dCodeDensity ) \
178  ((Cool)->dComovingGmPerCcUnit*(dCodeDensity))
179 
180 void CoolIntegrateEnergyCode(COOL *cl, clDerivsData *cData, COOLPARTICLE *cp,
181  double *E, double PdV, double rho, double ZMetal,
182  double *r, double tStep );
183 
184 void CoolDefaultParticleData( COOLPARTICLE *cp );
185 
186 void CoolInitEnergyAndParticleData( COOL *cl, COOLPARTICLE *cp, double *E,
187  double dDensity, double dTemp, double fMetal);
188 
189 /* Not implemented, but required to keep compiling from crashing */
190 double CoolEdotInstantCode(COOL *cl, COOLPARTICLE *cp, double ECode,
191  double rhoCode, double ZMetal, double *posCode );
192 
193 void CoolCodePressureOnDensitySoundSpeed( COOL *cl, COOLPARTICLE *cp,
194  double uPred, double fDensity, double gamma, double gammam1,
195  double *PoverRho, double *c );
196 #define CoolCodePressureOnDensitySoundSpeed( cl__, cp__, uPred__, fDensity__, \
197  gamma__, gammam1__, PoverRho__, c__ ) { \
198  *(PoverRho__) = ((gammam1__)*(uPred__)); \
199  *(c__) = sqrt((gamma__)*(*(PoverRho__))); }
200 
201 /* Place holder function (not implemented but needed */
202 void CoolTableReadInfo( COOLPARAM *CoolParam, int cntTable, int *nTableColumns,
203  char *suffix );
204 
205 /* Place holder function (not implemented but needed */
206 void CoolTableRead( COOL *Cool, int nData, void *vData);
207 
208 #ifdef __cplusplus
209 }
210 #endif
211 
212 #endif
213 
214 
Input parameters for cooling.
Definition: cooling_boley.h:56
Object containing the parameter information.
Definition: param.h:38
abundance of various species in particles/baryon
Definition: cooling_boley.h:75
Heating/Cooling context: parameters and tables.
Definition: cooling_boley.h:83
per-particle cooling data
Definition: cooling_boley.h:68
context for calculating cooling derivatives
Definition: cooling_boley.h:108