## Block Equations and the Simscape Numerical Scheme

### System Equations

Simscape™ Fluids™ blocks are a combination of differential equations, which represent the one-dimensional component dynamics, and algebraic equations, which represent the mass and energy continuity over the component. The system of equations, which comprises all blocks over all Simscape domains in the model, are assembled into an exact square matrix that is solved iteratively at each time step until convergence. The number of equations being solved and any zero-crossing events influence the speed and quality of model convergence. For more information on how Simscape software assembles and solves the governing equations of a model, see How Simscape Simulation Works.

### Solving the Network: The Simscape Numerical Scheme

Calculations are computed at each node of your fluid network, such as at block ports, connector intersections, and at internal points in dynamic components. To solve a network, the fluid properties at each node propagate according to the upwind numerical scheme. This means that the fluid properties at a given node are calculated based on the fluid properties at that node at the previous solver iteration and the current value of the fluid properties that precede it in space. Flow into an element is considered positive.

The following diagram shows two representations of blocks. Each block has a port A and B and an internal node I. The specific total enthalpy hA2 at port A in block 2 is calculated according to the flow direction and is based on the specific total enthalpy, hB1, at port B of block 1:

In the same configuration, flow in the reverse direction would mean that the specific total enthalpy at port A of block 2 is calculated based on the specific total enthalpy of the internal node, I, of the same component:

This means that you may observe differences in measured variable values depending on the flow direction and interrogated node.

### Smoothing in the Simscape Numerical Scheme

In a flow reversal region, as defined by the total energy flow rate and block thresholds, an energy flow rate without smoothing results in a jump discontinuity of the specific total enthalpy:

Upwind Scheme Without Smoothing

This can result in differences in measured variables between adjacent nodes and may influence the solver performance.

To avoid these discontinuities, smoothing is applied to the calculations and fluid values are calculated in terms of energy flows. For example, in the thermal liquid domain, the smoothed energy flux at A is the sum of the energy flow rate and the specific total enthalpy conduction between port A and internal node I. Conduction contributes to numerical smoothing while contributing a negligible quantity to the energy flow rate under nominal block conditions.

Quasi-steady components also account for smoothing to the energy flow rate. Although the block itself does not have an internal volume, the difference between internal enthalpy and enthalpy at the block ports is still calculated. The total energy flow rate at each node is determined by the fluid flow direction:

`${\Phi }_{A}=G\left({h}_{A}-{h}_{I}\right)+\left\{\begin{array}{cc}{\stackrel{˙}{m}}_{A}{h}_{A}& {\stackrel{˙}{m}}_{A}>0\\ {\stackrel{˙}{m}}_{A}{h}_{I}& {\stackrel{˙}{m}}_{A}\le 0\end{array},$`

where:

• ΦA is the energy flow rate through port A and conduction between port A and the internal node I.

• G is the thermal conductance coefficient, which for thermal liquid and moist air domains is calculated as:

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

where:

• k is the thermal conductivity.

• S is the port cross-sectional area.

• cv is the fluid specific heat.

• L is the characteristic length between the port and internal node.

For two-phase and gas domains, G is a general tuning parameter and is set by the threshold parameters defined for the block. For example, increasing the value of the Mach number for flow reversal parameter in a Two-Phase library block increases the amount of smoothing applied to the energy flow. Similarly, increasing the value of the Dynamic pressure threshold for flow reversal parameter in a Gas library block increases the region of smoothing applied.

In a flow reversal region, as defined by the total energy flow rate and block thresholds, the specific total enthalpy changes according to a gradual hyperbolic tangential:

Upwind Energy Scheme with Smoothing