# Documentation

## Energy Flows in Thermal Liquid Networks

### Upwind Energy Scheme

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}=\left\{\begin{array}{cc}{\stackrel{˙}{m}}_{A}{u}_{A},& {\stackrel{˙}{m}}_{A}>0\\ {\stackrel{˙}{m}}_{A}{u}_{I},& {\stackrel{˙}{m}}_{A}\le 0\end{array},$`
where:

• ΦAAd is the thermal energy flow rate due to advection through port A.

• ${\stackrel{˙}{m}}_{A}$ is the mass flow rate through port A.

• uA is the specific internal energy upwind of port A.

• uI 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

### Numerical 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}=\left\{\begin{array}{cc}{\stackrel{˙}{m}}_{A}{u}_{A}+G\left({u}_{A}-{u}_{I}\right),& {\stackrel{˙}{m}}_{A}>0\\ {\stackrel{˙}{m}}_{A}{u}_{I}+G\left({u}_{A}-{u}_{I}\right),& {\stackrel{˙}{m}}_{A}\le 0\end{array},$`
where:

• ΦATh 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}=\left\{\begin{array}{cc}\left({\stackrel{˙}{m}}_{A}+G\right){u}_{A}-G{u}_{I},& {\stackrel{˙}{m}}_{A}>0\\ G{u}_{A}+\left({\stackrel{˙}{m}}_{A}-G\right){u}_{I},& {\stackrel{˙}{m}}_{A}\le 0\end{array}$`
Using `min` and `max` functions to collapse the conditional expression:
`${\Phi }_{A}^{Th}=\left[\mathrm{max}\left({\stackrel{˙}{m}}_{A},0\right)+G\right]{u}_{A}+\left[\mathrm{min}\left({\stackrel{˙}{m}}_{A},0\right)-G\right]{u}_{I}$`
Approximating the collapsed expression as a numerically smooth expression:
`${\Phi }_{A}^{Th}\approx \frac{{\stackrel{˙}{m}}_{A}+\sqrt{{\stackrel{˙}{m}}_{A}^{2}+4{G}^{2}}}{2}{u}_{A}+\frac{{\stackrel{˙}{m}}_{A}-\sqrt{{\stackrel{˙}{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.

• cv 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

### Total Energy Flow Rate

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.

• ΦATh 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.