PLUTO
radiat.modified_by_Bhargav.c
Go to the documentation of this file.
1 #include "pluto.h"
2 
3 #define X 0.711
4 #define Y 0.2741
5 
6 #define A_Z 30.0 /* mean atomic weight of heavy elements */
7 #define A_He 4.004 /* atomic weight of Helium */
8 #define A_H 1.008 /* atomic weight of Hydrogen */
9 
10 /* ********************************************************************* */
11 void Radiat (double *v, double *rhs)
12 /*!
13  * Cooling for neutral or singly ionized gas: good up to about 35,000 K
14  * in equilibrium or shocks in neutral gas up to about 80 km/s.
15  * Assumed abundances in ab
16  * Uses t : Kelvin
17  * dene : electron density cm*-3
18  * fneut : hydrogen neutral fraction (adimensionale)
19  * ci,cr : H ionization and recombination rate coefficients
20  *
21  *
22  * em(1) = TOTAL EMISSIVITY : (ergs cm**3 s**-1)
23  * em(2) = Ly alpha + two photon continuum: Aggarwal MNRAS 202,
24  * 10**4.3 K
25  * em(3) = H alpha: Aggarwal, Case B
26  * em(4) = He I 584 + two photon + 623 (all n=2 excitations): Berrington
27  * &Kingston,JPB 20
28  * em(5) = C I 9850 + 9823: Mendoza, IAU 103, 5000 K
29  * em(6) = C II, 156 micron: Mendoza, 10,000 K
30  * em(7) = C II] 2325 A: Mendoza, 15,000 K
31  * em(8) = N I 5200 A: Mendoza, 7500 K
32  * em(9) = N II 6584 + 6548 A: Mendoza
33  * em(10) = O I 63 micron: Mendoza,2500 K
34  * em(11) = O I 6300 A + 6363 A: Mendoza, 7500 K
35  * em(12) = O II 3727: Mendoza
36  * em(13) = Mg II 2800: Mendoza
37  * em(14) = Si II 35 micron: Dufton&Kingston, MNRAS 248
38  * em(15) = S II 6717+6727: Mendoza
39  * em(16) = Fe II 25 micron: Nussbaumer&Storey
40  * em(17) = Fe II 1.6 micron
41  * em(18) = thermal energy lost by ionization
42  * em(19) = thermal energy lost by recombination (2/3 kT per
43  * recombination.
44  * The ionization energy lost is not included here.
45  *
46  *********************************************************************** */
47 {
48 
49  int ii, k;
50  double T, mu, st, rho, pr, fn;
51  double N_H, n_el, cr, ci, rlosst, em[20], src_pr;
52 
53  static double t00[18] = {0.0 , 0.0 , 1.18e5, 1.40e5, 2.46e5, 1.46e4,
54  92.1 , 6.18e4, 2.76e4, 2.19e4, 228.0 , 2.28e4,
55  3.86e4, 5.13e4, 410.0 , 2.13e4, 575.0 , 8980.0};
56 
57  static double ep[18] = {0.0 , 0.0 , 10.2 , 1.89, 21.2 , 1.26,
58  0.0079, 5.33, 2.38 , 1.89, 0.0197, 1.96,
59  3.33 , 4.43, 0.0354, 1.85, 0.0495, 0.775};
60 
61  static double critn[18] = {0.0 , 0.0 , 1.e10, 1.e10, 1.e10, 312.0,
62  0.849, 1.93e7, 124.0, 865.0, 1090.0, 3950.0,
63  177.0, 1.e10 , 16.8, 96.0, 580.0, 1130.0};
64 
65  static double om[18] = {0.0 , 0.0 , 0.90, 0.35, 0.15 , 0.067,
66  0.63, 0.52, 0.90, 0.30, 0.0055, 0.19,
67  0.33, 8.0 , 2.85, 1.75, 0.3 ,0.39};
68 
69  static double ab[18] = {0.0 , 0.0 , 1.0 , 1.0 , 0.1 , 0.0003,
70  0.0003, 0.0003 , 0.0001 , 0.0001 , 0.0006 , 0.0006,
71  0.0006, 0.00002, 0.00004, 0.00004, 0.00004, 0.00004};
72 
73  static double fn1[20] = {0.0, 0.0, 0.0, 0.0, 0.0,
74  0.1, 1.0, 1.0, 0.0, 1.0,
75  0.0, 0.0, 1.0, 1.0, 1.0,
76  1.0, 1.0, 1.0, 0.0, 1.0};
77 
78  static double fn2[20] = {0.0, 0.0, 1.0, 1.0, 1.0,
79  0.0, 0.0, 0.0, 1.0,-1.0,
80  1.0, 1.0,-1.0, 0.0, 0.0,
81  0.0, 0.0, 0.0, 1.0,-1.0};
82  static int first_call = 1;
83  static double E_cost, Unit_Time, N_H_rho, frac_Z, frac_He;
84 
85  if (first_call) {
86 
87  E_cost = UNIT_LENGTH/UNIT_DENSITY/pow(UNIT_VELOCITY, 3.0);
88  Unit_Time = UNIT_LENGTH/UNIT_VELOCITY;
89 
90  /* ------------------------------------------------------
91  conversion factor from total density to hydrogen
92  number density, i.e. nH = N_H_rho * rho
93  ------------------------------------------------------ */
94 
95  N_H_rho = (UNIT_DENSITY/CONST_amu)*(X/A_H); /* n(H) */
96  frac_He = (Y/A_He)*(A_H/X);
97  frac_Z = ((1 - X - Y)/A_Z)*(A_H/X);
98 
99  first_call = 0;
100  }
101 
102  rho = v[RHO];
103  pr = v[PRS];
104 
105 /* -----------------------------------
106  Force fneut to stay between [0,1]
107  ----------------------------------- */
108 
109  v[X_HI] = MAX(v[X_HI], 0.0);
110  v[X_HI] = MIN(v[X_HI], 1.0);
111 
112  if (v[PRS] < 0.0) v[PRS] = g_smallPressure;
113 
114  fn = v[X_HI];
115  mu = MeanMolecularWeight(v);
116  T = pr/rho*KELVIN*mu;
117 
118  /* --------------------------------------------------------
119  Set source terms equal to zero when the temperature
120  falls below g_minCoolingTemp
121  -------------------------------------------------------- */
122 
123 /* if (T < g_minCoolingTemp){
124  a = b = src_pr = 0.0;
125  continue;
126  }
127 */
128  if (mu < 0.0){
129  printf ("Negative mu in radiat \n");
130  exit(1);
131  }
132 
133  st = sqrt(T);
134  N_H = N_H_rho*rho; /* -- number density of hydrogen N_H = N(HI) + N(HII) -- */
135 
136  /* ---- coeff di ionizz. e ricomb. della particella fluida i,j ---- */
137 
138  cr = 2.6e-11/st;
139  ci = 1.08e-8*st*exp(-157890.0/T)/(13.6*13.6);
140 
141  n_el = N_H*(1.0 - fn + frac_Z); /* -- electron number density, in cm^{-3} -- */
142  rhs[X_HI] = Unit_Time*n_el*(-(ci + cr)*fn + cr);
143 
144  em[1] = 0.0;
145  for (k = 2; k <= 17; k++){
146  em[k] = 1.6e-12*8.63e-6*om[k]*ep[k]*exp(-t00[k]/T)/st;
147  em[k] = em[k]*critn[k]*st/(n_el + critn[k]*st);
148  em[k] = em[k]*ab[k]*(fn1[k] + fn*fn2[k]);
149  em[1] = em[1] + em[k];
150  }
151 
152  em[18] = ci*13.6*1.6e-12*fn;
153  em[19] = cr*0.67*1.6e-12*(1.0 - fn)*T/11590.0;
154  em[1] = em[1] + em[18] + em[19];
155 
156  /* ---------------------------------------------------
157  rlosst is the energy loss in units of erg/cm^3/s;
158  it must be multiplied by cost_E in order to match
159  non-dimensional units.
160  Source term for the neutral fraction scales with
161  UNIT_TIME
162  --------------------------------------------------- */
163  double g_gamma;
164 #if EOS == IDEAL
165  g_gamma = 1.4;
166 #elif EOS == PVTE_LAW
167  g_gamma = Gamma1(v);
168 #endif
169 
170  rlosst = em[1]*n_el*N_H;
171  rhs[PRS] = -E_cost*rlosst*(g_gamma - 1.0);
172  rhs[PRS] *= 1.0/(1.0 + exp( -(T - g_minCoolingTemp)/100.0)); /* -- cutoff -- */
173 
174 }
175 
176 
177 /* ********************************************************************* */
178 double MeanMolecularWeight (double *V)
179 /*
180  *
181  *
182  * PURPOSE
183  *
184  * Compute the mean molecular weight as function of the
185  * composition of the gas.
186  * The definitiion of the mean molecular weight \mu is
187  * the standard one:
188  *
189  * 1 \sum_k f_k n_k
190  * --- = ---------------- (Clayton, pag 82-83)
191  * \mu \sum_k f_k A_k
192  *
193  * where
194  *
195  * f_k : is the fractional abundance (by number) with
196  * respect to hydrogen, f_k = N_k/N_H
197  *
198  * A_K : is the atomic weight
199  *
200  * n_k : is the number of free particles
201  * contributed to the gas by element k
202  *
203  * The mean molecular weight satifies
204  *
205  * \rho = \mu m_{amu} N_{tot}
206  *
207  * where N_{tot} is the total number of particles
208  *
209  * For the ``Raymond'' cooling module \mu is calculated
210  * as follows:
211  *
212  * A_H + f_He*A_He + f_Z*A_z
213  * \mu = ---------------------------
214  * 2 - fn + f_He + 2*f_Z
215  *
216  *
217  * ARGUMENTS
218  *
219  * V: a set of primitive variables
220  *
221  *********************************************************************** */
222 {
223  int nv;
224 
225  for (nv = NFLX;nv <(NFLX+NIONS);nv++){
226  if (V[nv] < 0.0) V[nv] = 0.0;
227  if (V[nv] > 1.0) V[nv] = 1.0;
228  }
229 
230  double N_H = V[RHO]*(UNIT_DENSITY/CONST_amu)*(X/A_H); /* n(H) */
231  double N_He = V[RHO]*(UNIT_DENSITY/CONST_amu)*(Y/A_He); /* n(He) */
232  double N_Z = V[RHO]*(UNIT_DENSITY/CONST_amu)*((1.0-X-Y)/A_Z); /*/ n(metals) */
233 
234  double fracHe = N_He/N_H;
235  double fracZ = N_Z/N_H;
236 
237  double fn = V[X_HI];
238 
239  double munum = 1.0 + A_He*(fracHe) + A_Z*(fracZ);
240  double muden = 2 - fn + fracHe + fracZ + 0.5*A_Z*(fracZ);
241 
242  return munum/muden;
243 
244 
245  /*
246  return ( (A_H + frac_He*A_He + frac_Z*A_Z) /
247  (2.0 + frac_He + 2.0*frac_Z - V[X_HI]));
248  */
249 }
250 
251 /* /\* ********************************************************************* *\/ */
252 /* double H_MassFrac (void) */
253 /* /\* */
254 /* * */
255 /* * */
256 /* * PURPOSE */
257 /* * */
258 /* * Compute the mass fraction X of Hydrogen as function of the */
259 /* * composition of the gas. */
260 /* * */
261 /* * f_H A_H */
262 /* * X = ---------------- */
263 /* * \sum_k f_k A_k */
264 /* * */
265 /* * where */
266 /* * */
267 /* * f_k : is the fractional abundance (by number), */
268 /* * f_k = N_k/N_tot */
269 /* * of atomic species (no matter ionization degree). */
270 /* * */
271 /* * A_K : is the atomic weight */
272 /* * */
273 /* * Note: In this module, f_H = 1.0 */
274 /* * */
275 /* * where N_{tot} is the total number density of particles */
276 /* * */
277 /* * ARGUMENTS */
278 /* * */
279 /* * none */
280 /* * */
281 /* *********************************************************************** *\/ */
282 /* { */
283 /* return A_H/(A_H + frac_He*A_He + frac_Z*A_Z); */
284 /* } */
285 
286 /* /\* ********************************************************************* *\/ */
287 /* double CompEquil (double N, double T, double *v) */
288 /* /\* */
289 /* * */
290 /* * compute the equilibrium ionization balance for (rho,T) */
291 /* * */
292 /* * */
293 /* *********************************************************************** *\/ */
294 /* { */
295 /* double cr, ci, st, n_e; */
296 /* st = sqrt(T); */
297 /* cr = 2.6e-11/st; /\* recombination / ionization coefficients *\/ */
298 /* ci = 1.08e-8*st*exp(-157890.0/T)/(13.6*13.6); */
299 /* v[X_HI] = cr / (ci + cr); /\* compute fraction of neutrals at equilibrium *\/ */
300 /* n_e = (1.0 - v[X_HI] + frac_Z)*N; */
301 /* return n_e; */
302 /* } */
303 
#define MAX(a, b)
Definition: macros.h:101
tuple T
Definition: Sph_disk.py:33
double g_gamma
Definition: globals.h:112
#define UNIT_DENSITY
Unit density in gr/cm^3.
Definition: pluto.h:369
#define RHO
Definition: mod_defs.h:19
#define CONST_amu
Atomic mass unit.
Definition: pluto.h:253
#define frac_He
Definition: cooling.h:17
#define Y
#define frac_Z
Definition: cooling.h:15
double g_smallPressure
Small value for pressure fix.
Definition: globals.h:110
#define A_H
#define KELVIN
Definition: pluto.h:401
#define MIN(a, b)
Definition: macros.h:104
#define UNIT_VELOCITY
Unit velocity in cm/sec.
Definition: pluto.h:377
#define X
#define NFLX
Definition: mod_defs.h:32
#define UNIT_LENGTH
Unit Length in cm.
Definition: pluto.h:373
#define NIONS
Definition: cooling.h:28
#define A_He
Definition: cooling.h:110
int k
Definition: analysis.c:2
double Gamma1(double *v)
Definition: pvte_law.c:231
double g_minCoolingTemp
The minimum temperature (in K) below which cooling is suppressed.
Definition: globals.h:106
void Radiat(double *v, double *rhs)
PLUTO main header file.
double MeanMolecularWeight(double *V)
#define A_Z