Thermal energy advection should always match the direction of flow. To satisfy this condition, the Thermal Liquid domain employs a modeling framework known as the upwind scheme. This scheme works by matching the specific internal energy at a port to that just upwind of the port:

If the flow at a port is directed into the component, the specific internal energy at that port is equal to that carried by the incoming fluid. In the figure, the specific internal energy at port A of component

**2**is equal to that at port B of component**1**.If the fluid flow at a port is directed out of the component, the specific internal energy at that port is equal to that in the component’s internal fluid volume. In the figure, the specific internal energy at port A of component

**2**is equal to that in the internal fluid volume of the same component.

The upwind scheme describes the advection thermal energy flow rate using a conditional expression that, for port A of some component, reads:

$${\Phi}_{A}^{Ad}=\{\begin{array}{cc}{\dot{m}}_{A}{u}_{A},& {\dot{m}}_{A}>0\\ {\dot{m}}_{A}{u}_{I},& {\dot{m}}_{A}\le 0\end{array},$$

where:

*Φ*_{A}^{Ad}is the thermal energy flow rate due to advection through port A.$${\dot{m}}_{A}$$ is the mass flow rate through port A.

*u*_{A}is the specific internal energy upwind of port A.*u*_{I}is the specific internal energy in the internal fluid volume.

Without numerical smoothing, this expression introduces a number of computational challenges. It adds a slope discontinuity to the thermal energy flux at zero mass flow rates that makes the model more prone to simulation errors. It also adds a jump discontinuity to the specific internal energy and makes its value ill-defined during flow reversals.

**Upwind Energy Scheme without Smoothing**

The Thermal Liquid domain smoothes the numerical discontinuities introduced by the upwind energy scheme by adding to the thermal energy flow rate a thermal conduction term. At port A of some component:

$${\Phi}_{A}^{Th}=\{\begin{array}{cc}{\dot{m}}_{A}{u}_{A}+G\left({u}_{A}-{u}_{I}\right),& {\dot{m}}_{A}>0\\ {\dot{m}}_{A}{u}_{I}+G\left({u}_{A}-{u}_{I}\right),& {\dot{m}}_{A}\le 0\end{array},$$

where:

*Φ*_{A}^{Th}is the thermal energy flow rate due to advection through port A and conduction between port A and the internal fluid volume.*G*is a thermal conductance coefficient computed from the fluid properties and component geometry.

Rewriting the modified expression in a more convenient form:

$${\Phi}_{A}^{Th}=\{\begin{array}{cc}\left({\dot{m}}_{A}+G\right){u}_{A}-G{u}_{I},& {\dot{m}}_{A}>0\\ G{u}_{A}+\left({\dot{m}}_{A}-G\right){u}_{I},& {\dot{m}}_{A}\le 0\end{array}$$

Using `min`

and `max`

functions
to collapse the conditional expression:

$${\Phi}_{A}^{Th}=\left[\mathrm{max}\left({\dot{m}}_{A},0\right)+G\right]{u}_{A}+\left[\mathrm{min}\left({\dot{m}}_{A},0\right)-G\right]{u}_{I}$$

Approximating the collapsed expression as a numerically smooth expression:

$${\Phi}_{A}^{Th}\approx \frac{{\dot{m}}_{A}+\sqrt{{\dot{m}}_{A}^{2}+4{G}^{2}}}{2}{u}_{A}+\frac{{\dot{m}}_{A}-\sqrt{{\dot{m}}_{A}^{2}+4{G}^{2}}}{2}{u}_{I}$$

The end expression removes the slope discontinuity from the thermal energy flow rate curve and the jump discontinuity from the specific internal energy curve. The thermal conductance coefficient determines the amount of smoothing applied in both cases:

$$G=\frac{kS}{{c}_{v}L},$$

where:

*k*is the thermal conductivity defined in the Thermal Liquid Settings (TL) block.*S*is the flow cross-sectional area at the port considered.*c*_{v}is the specific heat defined in the Thermal Liquid Settings (TL) block.*L*is a characteristic distance between the port and the component’s fluid volume.

**Upwind Energy Scheme with Smoothing**

The Through variable of the Thermal Liquid domain is the total energy flow rate. This variable is defined in terms of the smoothed upwind thermal energy flow rate as:

$${\Phi}_{A}={\Phi}_{A}^{Th}+\frac{p}{\rho},$$

where:

*Φ*_{A}is the total energy flow rate through port A.*Φ*_{A}^{Th}is the thermal energy flow rate through port A computed from the smoothed upwind energy scheme.*p*is the absolute pressure at port A.*ρ*is the fluid density at port A.

The kinetic energy contribution to the total energy flow rate is assumed negligible in Thermal Liquid networks and is ignored in this domain.