changa 3.5
Loading...
Searching...
No Matches
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
14extern "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
23typedef struct CoolingParametersStruct {
24 double Y_Total;
25 double dCoolingTmin;
26 double dCoolingTmax;
27 double dBetaCooling;
28} COOLPARAM;
29
30typedef struct CoolingParticleStruct {
31 double Y_Total;
32} COOLPARTICLE;
33
34typedef struct {
35 double Total;
36} PERBARYON;
37
38typedef struct CoolingPKDStruct COOL;
39
40/* Per-thread data. Not used for this cooling algorithm */
41typedef struct clDerivsDataStruct {
42} clDerivsData;
43
44/* Heating Cooling Context */
45
46struct 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
72COOL *CoolInit( );
73
75void CoolFinalize( COOL *cl );
76
77clDerivsData *CoolDerivsInit(COOL *cl);
78
79void CoolDerivsFinalize(clDerivsData *cld ) ;
80
81void 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 */
86void CoolInitRatesTable( COOL *cl, COOLPARAM CoolParam);
87
88double clThermalEnergy( double Y_Total, double T );
89
90double clTemperature( double Y_Total, double E );
91
92void CoolAddParams( COOLPARAM *CoolParam, PRM );
93
94// Saves CenterOfMass to cooling struct cl
95void CoolSetStarCM(COOL *cl, double dCenterOfMass[4]);
96
97/* Needed by InOutput.h */
98#define COOL_ARRAY0_EXT "Y_Total"
99double COOL_ARRAY0(COOL *cl_, COOLPARTICLE *cp,double aa);
100#define COOL_ARRAY0( cl_, cp, aa ) ((cp)->Y_Total)
101double 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"
105double COOL_ARRAY1(COOL *cl_, COOLPARTICLE *cp,double aa);
106#define COOL_ARRAY1( cl_, cp, aa ) (0)
107double 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"
111double COOL_ARRAY2(COOL *cl_, COOLPARTICLE *cp,double aa);
112#define COOL_ARRAY2( cl_, cp, aa ) (0)
113double 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"
117double COOL_ARRAY3(COOL *cl, COOLPARTICLE *cp, double ZMetal);
118#define COOL_ARRAY3(cl_, cp, aa ) (0)
119double COOL_SET_ARRAY3(COOL *cl_, COOLPARTICLE *cp,double aa, double bb_val);
120#define COOL_SET_ARRAY3( cl_, cp, aa, bb_val ) (0)
121
123double 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
128double 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
132void 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
138double 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 */
143void CoolSetTime( COOL *Cool, double dTime, double z );
144
145/* Unit conversion routines */
146
147double CoolCodeTimeToSeconds( COOL *Cool, double dCodeTime );
148
149#define CoolCodeTimeToSeconds( Cool, dCodeTime ) ((Cool)->dSecUnit*(dCodeTime))
150
151double CoolSecondsToCodeTime( COOL *Cool, double dTime );
152
153#define CoolSecondsToCodeTime( Cool, dTime ) ((dTime)/(Cool)->dSecUnit)
154
155double CoolCodeEnergyToErgPerGm( COOL *Cool, double dCodeEnergy );
156
157#define CoolCodeEnergyToErgPerGm( Cool, dCodeEnergy ) \
158 ((Cool)->dErgPerGmUnit*(dCodeEnergy))
159
160double CoolErgPerGmToCodeEnergy( COOL *Cool, double dEnergy );
161
162#define CoolErgPerGmToCodeEnergy( Cool, dEnergy ) \
163 ((Cool)->diErgPerGmUnit*(dEnergy))
164
165double CoolCodeWorkToErgPerGmPerSec( COOL *Cool, double dCodeWork );
166
167#define CoolCodeWorkToErgPerGmPerSec( Cool, dCodeWork ) \
168 ((Cool)->dErgPerGmPerSecUnit*(dCodeWork))
169
170double CoolErgPerGmPerSecToCodeWork( COOL *Cool, double dWork );
171
172#define CoolErgPerGmPerSecToCodeWork( Cool, dWork ) \
173 ((dWork)/(Cool)->dErgPerGmPerSecUnit)
174
175double CodeDensityToComovingGmPerCc( COOL *Cool, double dCodeDensity );
176
177#define CodeDensityToComovingGmPerCc( Cool, dCodeDensity ) \
178 ((Cool)->dComovingGmPerCcUnit*(dCodeDensity))
179
180void CoolIntegrateEnergyCode(COOL *cl, clDerivsData *cData, COOLPARTICLE *cp,
181 double *E, double PdV, double rho, double ZMetal,
182 double *r, double tStep );
183
184void CoolDefaultParticleData( COOLPARTICLE *cp );
185
186void 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 */
190double CoolEdotInstantCode(COOL *cl, COOLPARTICLE *cp, double ECode,
191 double rhoCode, double ZMetal, double *posCode );
192
193void 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 */
202void CoolTableReadInfo( COOLPARAM *CoolParam, int cntTable, int *nTableColumns,
203 char *suffix );
204
205/* Place holder function (not implemented but needed */
206void CoolTableRead( COOL *Cool, int nData, void *vData);
207
208#ifdef __cplusplus
209}
210#endif
211
212#endif
213
214
Heating/Cooling context: parameters and tables.
Definition cooling_boley.h:83
Input parameters for cooling.
Definition cooling_boley.h:56
per-particle cooling data
Definition cooling_boley.h:68
abundance of various species in particles/baryon
Definition cooling_boley.h:75
context for calculating cooling derivatives
Definition cooling_boley.h:108