PLUTO  4.4-patch2
Functions | Variables
thermal_eos.c File Reference

Thermodynamic relations for the thermal EoS, p=nkT and T=p/(nK) . More...

#include "pluto.h"

Functions

static double TFunc (double T, void *par)
 
void MakePV_TemperatureTable ()
 
double Pressure (double *v, double T)
 
int GetPV_Temperature (double *v, double *T)
 

Variables

static Table2D Ttab
 

Detailed Description

Collect miscellaneous functions involving computations with the thermal equation of state,

\[ p = nk_BT \quad {\rm(in\; cgs)} \qquad \Longrightarrow\qquad p = \frac{\rho T}{K\mu(\vec{X})} \quad {\rm(in\; code\quad units)} \]

where, in the second expression, rho and p are density and pressure (in code units), T is the temperature (in Kelvin), K is the KELVIN dimensionalization constant, mu(X) is the mean molecular weight and X is an array containing the ionization fractions of different elements. The previous relation is typically used to compute

Nonlinear equation can be solved with a root finder (typically Brent's method) or a tabulated approach (default). In both case, a 2D table (Ttab) of the temperature T(i,j) is pre-calculated for fixed values of p/rho and rho by MakePV_TemperatureTable() and stored into memory. The table is then used to bracket the root (in the case of a root finder) or to replace the runtime computation with a simpler array indexing operation followed by a combination of lookup table and bilinear (direct or inverse) interpolation.

Author
A. Mignone (migno.nosp@m.ne@p.nosp@m.h.uni.nosp@m.to.i.nosp@m.t)
B. Vaidya
Date
31 Aug, 2014

Function Documentation

◆ GetPV_Temperature()

int GetPV_Temperature ( double *  v,
double *  T 
)

Compute gas temperature (in Kelvin) from density, pressure and fractions:

\[ T = \left\{\begin{array}{ll} \DS \frac{p}{\rho} K \mu(\vec{X}) &\quad{(\rm with\; chemistry)} \\ \noalign{\medskip} \DS \frac{p}{\rho}K\mu(\vec{X}(T,\rho)) & \quad{(\rm without\; chemistry)} \end{array}\right. \]

where K is the KELVIN macro.

The first relation is used when ion fractions are explicitly evolved by the code (NIONS>0) while the second one is inverted numerically using root finder or lookup table when either LTE or CIE is assumed.

Parameters
[in]v1D array of primitive quantities.
[out]TTemperature in K
Returns
0 on success, 1 on failure.

◆ MakePV_TemperatureTable()

void MakePV_TemperatureTable ( )

Pre-calculate a 2D table of temperature T(p,rho) by inverting, at specified values of p and rho, the nonlinear equation (only in LTE or CIE)

\[ f(T) = T - \frac{p}{\rho} K\mu(T,\rho) = 0 \qquad\Longrightarrow\qquad T_{ij} = T(x_i, y_j) \qquad \left(x=\log_{10}\frac{p}{\rho}\,,\quad y=\log_{10}\rho\right) \]

For convenience, the table is constructed using equally spaced bins of x=log10(p/rho) and y=log10(rho) where p and rho are in code units. This function must be called only once to initialize the 2D table Ttab.

◆ Pressure()

double Pressure ( double *  v,
double  T 
)

Return pressure as a function of temperature, density and fractions. If T(p/rho,rho) has been tabulated, this requires inverting the table by calling InverseLookupTable2D().

Parameters
[in]va pointer to a vector of primitive quantities (only density and fractions will be actually used).
[in]TThe temperature (in Kelvin);
Returns
Pressure in code units.

◆ TFunc()

double TFunc ( double  T,
void *  par 
)
static

Return the nonlinear function f(T) = T - T1 mu(T,rho) used by the root finder to find temperature T.

Parameters
[in]TThe temperature in Kelvin
[in]parA pointer to a func_param structure containing density required for computing internal energy.
Returns
f(T)

Variable Documentation

◆ Ttab

Table2D Ttab
static

A 2D table containing pre-computed values of temperature stored at equally spaced node values of Log(p/rho) and Log(rho)