7.3
general documentation
Examples of enthalpy-temperature conversion law

Introduction

By default, when not using a specific physical model (which will usually contain a more advanced conversion), a simple

\[ H = C_p T \]

law is used.

This simple law will also be used by default in solid zones even when using a specific fluid model.

When using variable Cp values, an appropriate temperaure to enthalpy conversion should be defined by the user if solving the Enthalpy.

The cs_user_physical_properties_h_to_t and cs_user_physical_properties_t_to_h functions (in cs_user_physical_properties.c) can be used to define an enthalpy-temperature conversion law and its inverse.

If can be defined on a "per-zone" basis if needed in case different zones (both solid and boundary) correspond to different fluids or solid ones.

Example

The following code blocks show an example of enthalpy-temperature conversion law.

Tabulation

The following block is added either outside cs_user_physical_properties_h_to_t and cs_user_physical_properties_t_to_h functions (before all function definitions in cs_user_physical_properties.c), or in both of these functions:

static const int n_tv = 5;
static const cs_real_t ht[5] = {100000.0, 200000.0, 300000.0,
400000.0, 00000.0};
static const cs_real_t th[5] = {100.0, 200.0, 300.0, 400.0, 500.0};

Enthalpy to temperature

The following block is then used in cs_user_physical_properties_h_to_t to convert enthalpy to temperature:

for (cs_lnum_t i_l = 0; i_l < z->n_elts; i_l++) {
cs_lnum_t i = (z_local) ? i_l : z->elt_ids[i_l];
cs_real_t temperature = 0; /* Default initialization */
/* If H is outside the tabulated value range, use range
start or end value. */
if (h[i] < ht[0])
temperature = th[0];
else if (h[i] > ht[n_tv - 1])
temperature = th[n_tv - 1];
/* Otherwise, use piecewise linear interpolation */
else
for (int j = 1; j < n_tv; j++) {
if (h[j] < ht[j]) {
temperature = th[j-1] + (h[i]-ht[j-1])*(th[j]-th[j-1])
/ (ht[j]-ht[j-1]);
break;
}
}
t[i] = temperature;
}

Note that z->name or z->location_id can be used as a filter if "per-zone" properties are needed (such as with solid zones).

Temperature to Enthalpy

The following block must then be added in cs_user_physical_properties_t_to_h for the matching temperature to Enthalpy conversion:

for (cs_lnum_t i_l = 0; i_l < z->n_elts; i_l++) {
cs_lnum_t i = (z_local) ? i_l : z->elt_ids[i_l];
cs_real_t enthalpy = 0; /* Default initialization */
/* If H is outside the tabulated value range, use range
start or end value. */
if (t[i] < th[0])
enthalpy = ht[0];
else if (t[i] > th[n_tv - 1])
enthalpy = ht[n_tv - 1];
/* Otherwise, use piecewise linear interpolation */
else
for (int j = 1; j < n_tv; j++) {
if (t[j] < th[j]) {
enthalpy = ht[j-1] + (t[i]-th[j-1])*(ht[j]-ht[j-1])
/ (th[j]-th[j-1]);
break;
}
}
h[i] = enthalpy;
}

Note that temperature to enthalpy conversion is only needed when solving the Enthalpy and using radiative tranfers or temperature-based boundary conditions.