PLUTO
|
Thermodynamic relations for the caloric EoS, e=e(T,rho)
and T=T(e,rho)
.
More...
#include "pluto.h"
Go to the source code of this file.
Macros | |
#define | TV_ENERGY_TABLE_NX 1024 |
#define | TV_ENERGY_TABLE_NY 512 |
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 (double **v, double *cs2, double *h, int beg, int end, int pos, Grid *grid) |
Variables | |
static Table2D | rhoe_tab |
A 2D table containing pre-computed values of internal energy stored at equally spaced node values of Log(T) and Log(rho) . More... | |
static Table2D | Trhoe_tab |
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) . More... | |
Thermodynamic relations for the caloric EoS, e=e(T,rho)
and T=T(e,rho)
.
Collect various functions involving computations between internal energy, density and temperature,
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.
Definition in file internal_energy.c.
#define TV_ENERGY_TABLE_NX 1024 |
Definition at line 47 of file internal_energy.c.
#define TV_ENERGY_TABLE_NY 512 |
Definition at line 50 of file internal_energy.c.
int GetEV_Temperature | ( | double | rhoe, |
double * | v, | ||
double * | T | ||
) |
Compute temperature from internal energy, density and fractions by solving either
The previous equations are solved using a root finder algorithm (default is Brent or Ridder) or by lookup table / interpolation methods.
[in] | rhoe | Internal energy of gas in code units. |
[in] | v | 1D array of primitive variables (only density and species need to be set). |
[out] | T | Temperature in K |
Definition at line 290 of file internal_energy.c.
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)
.
[in] | v | 1D Array of primitive variables containing density and species. Other variables are ignored. |
[in] | T | Gas temperature |
Definition at line 255 of file internal_energy.c.
|
static |
Compute derivative of internal energy using numerical differentiation
Definition at line 147 of file internal_energy.c.
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
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).
Definition at line 178 of file internal_energy.c.
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.
Definition at line 62 of file internal_energy.c.
|
static |
Return the nonlinear function f(T)=rhoe(T,rho)-rhoe
used by the root finder to find temperature T
.
[in] | T | The temperature in Kelvin |
[in] | par | A pointer to a func_param structure containing quantities required for the computation. |
Definition at line 390 of file internal_energy.c.
void SoundSpeed2 | ( | double ** | v, |
double * | cs2, | ||
double * | h, | ||
int | beg, | ||
int | end, | ||
int | pos, | ||
Grid * | grid | ||
) |
Define the square of the sound speed.
[in] | v | 1D array of primitive quantities |
[out] | cs2 | 1D array containing the square of the sound speed |
[in] | h | 1D array of enthalpy values |
[in] | beg | initial index of computation |
[in] | end | final index of computation |
[in] | pos | an integer specifying the spatial position inside the cell (only for spatially-dependent EOS) |
[in] | grid | pointer to an array of Grid structures |
Definition at line 414 of file internal_energy.c.
|
static |
A 2D table containing pre-computed values of internal energy stored at equally spaced node values of Log(T)
and Log(rho)
.
Definition at line 57 of file internal_energy.c.
|
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.
Definition at line 171 of file internal_energy.c.