PLUTO
cooling.c
Go to the documentation of this file.
1 /* ///////////////////////////////////////////////////////////////////// */
2 /*!
3  \file
4  \brief Take a source step using power-law cooling.
5 
6  Integrate the ODE
7  \f[
8  dp_{\rm cgs}/dt_{\rm cgs}
9  = -(\Gamma - 1) \Lambda(\rho_{\rm cgs}, T_{\rm cgs})
10  \qquad{\rm where}\qquad
11  \Lambda = \frac{a_{br}}{(\mu m_H)^2} \rho_{\rm cgs}^2 \sqrt{T_{\rm cgs}}
12  \,,\qquad
13  a_{br} = 2.e-27 c.g.s
14  \f]
15  which accounts for bremmstrahlung cooling.
16  Here the subscript 'cgs' means that the corresponding quantity is given
17  in c.g.s units.
18  We denote with \c mu the molecular weight, \c mH the hydrogen mass (in c.g.s).
19 
20  The previous integration is carried out analytically since the density
21  does not change during this step.
22  In non-dimensional form:
23  \f[
24  \frac{dp}{dt} = -{\rm cost} \;\rho (\rho p)^{\HALF}
25  \f]
26 
27  [notice that since \c p/rho=T/KELVIN this is equivalent to:
28  \c dp/dt=-cost rho^2 (T/KELVIN)^(1/2) ]
29 
30  The quantity \c cost is determined by transforming the dimensional
31  equation into the non-dimensional one.
32  If p, rho and t are in code (non-dimensional) units and if \c L_0,
33  \c rho_0, and \c V_0 are the unit length, density and velocity,
34  then \c cost is found to be:
35  \verbatim
36  a_br * (gamma - 1) * L_0 * rho_0
37  cost = -------------------------------------------
38  sqrt(kB * mu * mH) * kB * mu * mH * V_0^2
39  \endverbatim
40  where a_{br} = 2.e-27 (in c.g.s), kB is the Boltmann constant
41 
42 
43  \authors A. Mignone (mignone@ph.unito.it)
44  \date July 28, 2014
45 */
46 /* ///////////////////////////////////////////////////////////////////// */
47 #include "pluto.h"
48 
49 /* ********************************************************************* */
50 void PowerLawCooling (Data_Arr VV, double dt, Time_Step *Dts, Grid *grid)
51 /*!
52  * \param [in,out] VV a pointer to the PLUTO 3D data array containing
53  * pimitive variables.
54  * \param [in] dt the current integration time step
55  * \param [in] Dts a pointer to the Time_Step structure
56  * \param [in] grid pointer to an array of Grid structures
57  *
58  *********************************************************************** */
59 {
60  int i, j, k;
61  double cost, dE;
62  double rho, p, T, p_f, T_f;
63 
65  cost *= 2.e-27*(g_gamma-1.0)/ (0.5*CONST_mH*sqrt(0.5*CONST_mH*CONST_kB));
66 
67 /* -------------------------------------------------------------
68  Integrate analytically
69  ------------------------------------------------------------- */
70 
71  dE = 1.e-18;
72  DOM_LOOP(k,j,i){
73 
74 /* ---- Find initial temperature in Kelvin ---- */
75 
76  rho = VV[RHO][k][j][i];
77  p = VV[PRS][k][j][i];
78 
79  T = (p/rho*KELVIN);
80 
81  if (T < g_minCoolingTemp) continue;
82 
83 /* ---- Find final energy ---- */
84 
85  p_f = sqrt(p) - 0.5*cost*rho*sqrt(rho)*dt;
86  p_f = MAX(p_f, 0.0);
87  p_f = p_f*p_f;
88  T_f = p_f/rho*KELVIN;
89  T_f = MAX (T_f, g_minCoolingTemp);
90 
91 /* ---- Update Energy ---- */
92 
93  p_f = T_f*rho/KELVIN;
94 
95  VV[PRS][k][j][i] = p_f;
96  dE = fabs(1.0 - p_f/p) + 1.e-18;
97 
98  Dts->dt_cool = MIN(Dts->dt_cool, dt*g_maxCoolingRate/dE);
99  }
100 
101 }
102 
#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
double **** Data_Arr
Definition: pluto.h:492
DOM_LOOP(k, j, i)
Definition: analysis.c:22
#define RHO
Definition: mod_defs.h:19
#define KELVIN
Definition: pluto.h:401
void PowerLawCooling(Data_Arr VV, double dt, Time_Step *Dts, Grid *grid)
Definition: cooling.c:50
#define MIN(a, b)
Definition: macros.h:104
#define UNIT_VELOCITY
Unit velocity in cm/sec.
Definition: pluto.h:377
double dt_cool
Cooling time step.
Definition: structs.h:219
#define UNIT_LENGTH
Unit Length in cm.
Definition: pluto.h:373
Definition: structs.h:78
#define CONST_kB
Boltzmann constant.
Definition: pluto.h:259
#define CONST_mH
Hydrogen atom mass.
Definition: pluto.h:264
int j
Definition: analysis.c:2
int k
Definition: analysis.c:2
double g_minCoolingTemp
The minimum temperature (in K) below which cooling is suppressed.
Definition: globals.h:106
PLUTO main header file.
int i
Definition: analysis.c:2
double g_maxCoolingRate
The maximum fractional variation due to cooling from one step to the next.
Definition: globals.h:104