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

Thermodynamic relations for the caloric EoS, e=e(T,rho) and T=T(e,rho). More...

#include "pluto.h"

Functions

static double rhoeFunc (double, void *)
 
static double InternalEnergyDeriv (double rho, double T)
 
void MakeInternalEnergyTable ()
 
void MakeEV_TemperatureTable ()
 
double InternalEnergy (double *v, double T)
 
int GetEV_Temperature (double rhoe, double *v, double *T)
 
void SoundSpeed2 (const State *p, int beg, int end, int pos, Grid *grid)
 

Variables

static Table2D rhoe_tab
 
static Table2D Trhoe_tab
 

Detailed Description

Collect various functions involving computations between internal energy, density and temperature,

\[ e = e(T,\vec{X})\,,\qquad T = T(e,\vec{X}) \]

where e is the specific internal energy, T is the temperature and X are the ionization fractions. The first relation is used to retrieve e as a function of T and X by calling InternalEnergy() while the second one computes T from internal energy and fractions and it is handled by the function GetEV_Temperature():

If no chemistry is used (NIONS==0 ), ionization fractions are computed assuming equilibrium conditions and X=X(T,rho). This requires the numerical inversion of the second equation T=(e,X(T,rho)) which can be carried out using either a root finder algorithm (typically Brent's method) or, alternatively, lookup table together with cubic/linear (default) or bilinear interpolation.

For the root-finder version, a 2D table (Trhoe_tab) giving T=T(rhoe,rho) is pre-computed in the function MakeEV_TemperatureTable() and lookup table is used to narrow down the root interval using the values stored inside this table.

In the tabulated EOS version, a different table (rhoe_tab) rhoe=rhoe(T,rho) giving the internal energy at predefined values of temperature and density is pre-calculated in the function MakeInternalEnergyTable() so that internal energy and temperature can be found 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
7 Jan, 2015

Function Documentation

◆ GetEV_Temperature()

int GetEV_Temperature ( double  rhoe,
double *  v,
double *  T 
)

Compute temperature from internal energy, density and fractions by solving either

\[ \begin{array}{ll} \rho e - \rho e(T,\vec{X}) = 0 & \quad{(\rm with\; chemistry)} \\ \noalign{\medskip} \rho e - \rho e(T,\vec{X}(T,\rho)) = 0 & \quad{(\rm without\; chemistry)} \end{array} \]

The previous equations are solved using a root finder algorithm (default is Brent or Ridder) or by lookup table / interpolation methods.

Parameters
[in]rhoeInternal energy of gas in code units.
[in]v1D array of primitive variables (only density and species need to be set).
[out]TTemperature in K
Returns
0 on success, 1 on failure.

◆ InternalEnergy()

double InternalEnergy ( double *  v,
double  T 
)

Compute and return the gas internal energy as a function of temperature and density or fractions: rhoe = rhoe(T,rho) or rhoe = rhoe(T,X) .

Parameters
[in]v1D Array of primitive variables containing density and species. Other variables are ignored.
[in]TGas temperature
Returns
The gas internal energy (rhoe) in code units.

◆ InternalEnergyDeriv()

double InternalEnergyDeriv ( double  rho,
double  T 
)
static

Compute derivative of internal energy using numerical differentiation

◆ MakeEV_TemperatureTable()

void MakeEV_TemperatureTable ( )

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

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

For convenience, the table is constructed using equally spaced bins of x=Log(rhoe) and y=Log(rho) where rhoe and rho are in code units. This function must be called only once to initialize the table Trhoe_tab which is private to this file only.

This table is required only by the root-finder methods and it is useless for the tabulated version (default).

◆ MakeInternalEnergyTable()

void MakeInternalEnergyTable ( )

Compute a 2D table of the internal energy rhoe(T,rho) as function of temperature and density. The grid is equally spaced in log10(T) (=x) and log10(rho) (=y). Values are stored in the static table rhoe_tab.

◆ rhoeFunc()

double rhoeFunc ( double  T,
void *  par 
)
static

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

Parameters
[in]TThe temperature in Kelvin
[in]parA pointer to a func_param structure containing quantities required for the computation.
Returns
f(T)

◆ SoundSpeed2()

void SoundSpeed2 ( const State p,
int  beg,
int  end,
int  pos,
Grid grid 
)

Define the square of the sound speed.

Parameters
[in]v1D array of primitive quantities
[out]cs21D array containing the square of the sound speed
[in]h1D array of enthalpy values
[in]beginitial index of computation
[in]endfinal index of computation
[in]posan integer specifying the spatial position inside the cell (only for spatially-dependent EOS)
[in]gridpointer to an array of Grid structures
Returns
This function has no return value.

Variable Documentation

◆ rhoe_tab

Table2D rhoe_tab
static

A 2D table containing pre-computed values of internal energy stored at equally spaced node values of Log(T) and Log(rho) .

◆ Trhoe_tab

Table2D Trhoe_tab
static

A 2D table containing pre-computed values of temperature by inverting e=e(T,rho) at equally spaced node values of Log(rhoe) and Log(rho). This is used only in conjunction with a root finder to bracket the zero in a narrower interval.