# Tank

(To be removed) Pressurized fluid container with variable fluid level

**The Hydraulics (Isothermal) library will be removed in a
future release. Use the Isothermal Liquid library instead. (since R2020a)**

**For more information on updating your models, see Upgrading Hydraulic Models to Use Isothermal Liquid Blocks.**

**Libraries:**

Simscape /
Fluids /
Hydraulics (Isothermal) /
Low-Pressure Blocks

## Description

The Tank block models a pressurized fluid container with a variable fluid level. The tank has an optional number of ports ranging from one to three, with each number corresponding to a block variant. The tank pressurization is fixed regardless of changes to fluid volume or fluid level. The tank is vented if the pressurization is set to zero—a setting corresponding to an internal pressure equal to atmospheric pressure.

**Tank Ports and Port Elevations**

The block accounts for differences in port elevation. Hydrostatic pressure is computed separately for each port from the fluid level and port elevation. The hydrostatic pressure adds to the pressurization of the tank—increasing the port pressure as the fluid level rises. The block accounts also for minor pressure losses at the ports due to filters, fittings, and other local flow resistances. To modulate these losses, the block provides a pressure loss coefficient for each port.

### Changing the Number of Ports

To change the number of ports in the tank, use the **Modeling
option** parameter to change the active block variant. Variant options include:

`One inlet`

(default) — Exposes one hydraulic conserving port,**T**.`Two inlets`

— Exposes hydraulic conserving ports**A**and**B**.`Three inlets`

— Exposes hydraulic conserving ports**A**,**B**, and**C**.

Port **A** in the `Two inlets`

and
`Three inlets`

variants is a direct replacement of port
**T** in the `One inlet`

variant.

### Port Depth and Fluid Level

Port **T** in the `One inlet`

variant—or port **A**, its replacement in the
`Two inlets`

and ```
Three
inlets
```

variants—is by default located at the bottom of the
tank. The depth of this port relative to the top of the fluid volume is equal to the
fluid level—the height of the fluid volume:

$${y}_{T/A}=H,$$

where:

*y*_{T/A}is the depth of port**T**or**A**.*H*is the fluid level in the tank.

Ports **B** and **C** in the ```
Two
inlets
```

and `Three inlets`

variants are
assumed to be located above port **A**. The depths of these ports
are each computed as the difference between the fluid level and the port elevation
above port **A**:

$${y}_{B}=H-{H}_{AB},$$

and

$${y}_{C}=H-{H}_{AC},$$

where:

*y*_{B}and*y*_{C}are the depths of ports**B**, and**C**.*H*_{AB}and*H*_{AC}are the elevations of ports**B**and**C**above port**A**.

The fluid level, *H*, is computed during simulation from the
instantaneous fluid volume. This calculation depends on the **Tank volume
parameterization** setting. If the parameterization is set to
`Constant cross-sectional area`

(the default setting),
the fluid level is:

$$H=\frac{V}{S},$$

where:

*V*is the instantaneous fluid volume in the tank.*S*is the internal cross-sectional area of the tank, specified in the**Tank cross-section area**parameter.

If the **Tank volume parameterization** is set to
`Tabulated data — Volume vs. level`

, the fluid
level is computed by interpolation or extrapolation of tabulated fluid level data
specified as a function of fluid volume:

$$H=f(V)$$

The instantaneous fluid volume varies with the volumetric flow rates through the exposed ports. This volume increases if the sum of all flow rates is positive. A flow rate is positive if it is directed from the port to the interior of the tank, that is, if fluid enters the tank. The time rate of change of the fluid volume is defined as:

$$\frac{dV}{dt}={\displaystyle \sum _{i}{q}_{i},}$$

where *q*_{i} is the flow rate into the tank
through the port denoted by
*i*—**T**/**A**,
**B**, or **C**.

### Flow Rate and Pressure Drop

The volumetric flow rate through a port is a function of the pressure drop from that port to the interior of the tank. The flow rate is positive if the pressure drop is positive—that is, if pressure is higher at the port than in the tank—and negative otherwise:

$${q}_{i}={A}_{i}\sqrt{\frac{2}{{K}_{i}\rho}}\frac{\Delta {p}_{i}}{{\left(\Delta {p}_{i}^{2}+{p}_{Cr,i}^{2}\right)}^{1/4}},$$

where:

*A*_{i}is the internal cross-sectional area of the port denoted by*i*(**T**/**A**,**B**, or**C**):$${A}_{i}=\frac{\pi {d}_{i}^{2}}{4},$$

with

*d*_{i}as the internal diameter of the port.*K*_{i}is the pressure loss coefficient specified for the port.*ρ*is the hydraulic fluid density.*Δp*is the pressure drop from the port to the interior of the tank._{i}*p*_{Cr,i}is the critical pressure at which the flow through the port switches between laminar and turbulent.

The critical pressure at a port is computed from the critical
Reynolds number, internally set to a value of `15`

, and from the
respective port diameter. The critical pressure is modulated by the pressure loss
coefficient specified for the port—with this parameter serving as a gain for
the critical pressure:

$${p}_{Cr,i}={K}_{i}\frac{\rho}{2}\left(\frac{{\mathrm{Re}}_{Cr}\nu}{{d}_{i}}\right),$$

where:

*Re*_{Cr}is the critical Reynolds number.*ν*(*nu*) is the hydraulic fluid dynamic viscosity.*d*_{i}is the internal diameter of the port denoted by*i*.

The pressure drop from a port to the interior of the tank is computed
from the specified **Pressurization** value, the hydrostatic
pressure, and the pressure at the port:

$$\Delta {p}_{i}={p}_{port,i}-\left({p}_{press}+{p}_{elev,i}\right),$$

where:

*p*_{port,i}is the pressure at the port denoted by*i*.*p*_{press}is the specified tank**Pressurization**value.*p*_{elev,i}is the hydrostatic pressure at the port.

The hydrostatic pressure at a port is a function of the port
elevation above the bottom of the tank (zero for port
**T**/**A**):

$${p}_{elev,i}=\rho g{y}_{i},$$

where

*g*is the value of the gravitational acceleration at the mean elevation of the system.*y*_{i}is the elevation of the port denoted by*i*relative to the bottom of the port.

### C/C++ Code Generation

This block supports code generation for real-time simulation tasks. Certain blocks and block
settings may be more suitable for simulation on a real-time device. For suggestions on how
to improve real-time simulation performance, use the Simulink^{®}
Performance Advisor
function. Suggestions include ways to reduce model complexity and decrease numerical
stiffness.

In the Simulink Editor, click the **Debug** tab and select **Performance Advisor**from **Performance Advisor**. Set the
**Activity** parameter to ```
Execute real-time
application
```

to view suggestions specific to real-time simulation
performance. Expand the **Real-Time** node in the tree view pane to select
performance checks specific to Simscape™ products.

### Variables

To set the priority and initial target values for the block variables prior to simulation, use
the **Initial Targets** section in the block dialog box or
Property Inspector. For more information, see Set Priority and Initial Target for Block Variables.

Nominal values provide a way to specify the expected magnitude of a variable in a model.
Using system scaling based on nominal values increases the simulation robustness. Nominal
values can come from different sources, one of which is the **Nominal
Values** section in the block dialog box or Property Inspector. For more
information, see Modify Nominal Values for a Block Variable.