# Multi-level tanks

Tank models with non-convex shape may have, depending on geometry and acceleration vector direction, several basins where the single-level assumption is not enough to analyze certain aspects.

#### Multi-level tank assumptions

• An orifice, or opening, is a polygon defined by a number of coplanar triangles part of the complex tank shape.
• An orifice polygon has a corresponding orifice polygon of the same shape on the connected sub-tank. The polygon pair does not have to be the same number of triangles.
• A pair of corresponding orifice polygons are at the same position.

There are no safeguards against violating these assumptions in a model which could possibly imply the following.

• Non-flat orifice polygons will introduce an error on the flow calculations. Small deviations are negligible.
• A pair of orifice polygons not having the same shape will cause asymmetric flow response, e.g., two different sub-tank levels when they should reach a single level at equilibrium or flows when they should be stationary.
• The orifice polygon pair is a physical connection where fluid flows at a single location. If the polygons are at different positions, the fluid would instantaneously move interspatially to another position which could introduce potential energy into the system.

#### Workflow

##### Pre-process tank shape

To create a multi-level tank assembly, the tank shape must be divided into a number of mostly-convex shapes where the aim is to have as little concavity as possible. Dividing into strictly convex shapes usually implies an excessive number of divisions.

This division is done in a CAD tool. Each sub-tank shape is then exported as an ascii STL file.

Note: Make sure each sub-tank shape consists of one closed surface with normals pointing outwards. The orifices (cuts) between sub-tanks need to be closed as well.

Remember the face indices defining the orifice for each sub-tank. They will be used later to set the orifice geometry in the model.

Important! Some CAD software start counting from zero (0), while indexing in Modelica starts from one (1).

Here is an example illustration of a non-convex tank shape being divided in two with highlighted orifice definitions:

##### Configure Modelica model

In your Modelica model, add a MultiLevelTank component for every sub-tank and an Orifice component for every pair of openings. Set the tank shape fileName parameter on each tank component to point to the respective tank shape file. Set the tank orifice parameters enableOrifice=true, numOrifices to the number of openings in the applicable sub-tank, and orificeIndices record array to the triangle indices of each triangle defining the orifice.

Example: In the illustration above, we would have two tank components and one orifice. Both gets numOrifices=1 since there is only one orifice in each sub-tank. The triangle indices are set with

orificeIndices={FuelSystem.Volumes.ComplexTankInternals.AreaComputation.TriangleRowIndice(indices=41:42)}, and

orificeIndices={FuelSystem.Volumes.ComplexTankInternals.AreaComputation.TriangleRowIndice(indices=1:2)}

for the left and right tank respectively.

Connect all tank models with orifice flow models according to the geometry parameterization. tank orifice port to the orifice flow component.

The orifice port is vectorized with the number of openings in that sub-tank (numOrifices). E.g., leftTank.orifice[1] should be connected to rightTank.orifice[1] via an orifice flow model if leftTank.orificeIndices[1] correspond to the opening towards rightTank, and vice versa.

#### Master tank selection

The multi-level tank works based on the pressure lumping concept. Read the documentation of MultiLevelTank for more details. It is important to note that the selection of a master or a slave impacts the results. See an example below:

In MultiLevelTank.RotatingTankBox experiment model, two tanks are connected through a small orifice. The acceleration vector is set to allow the fuel to flow from tank1 to tank2 initially and backward after some time. By default, tank1 is selected as the master. This can be done by setting lumpingMode in the Initialization tab to master (please note: if this is not manually set, the tool will automatically decide any one of the tanks as a master). Since tank1 is selected as the master, pressure state computation is done in tank1. Since fuel is leaving tank1 initially, we can see the pressure computed is reducing (see the plot below). By the lumping connector, this pressure is transferred to the tank2.

Duplicate the model to your work package. Set tank2 as master and tank1 as a slave.

Run the model for default settings of 15s. Now plot the gas pressure in tank1. We could see that the pressure is increasing (see the plot below).

This is because tank2 is now selected as the master. Pressure computation is done in tank2. Since fuel is entering tank2, the gas pressure in tank2 is increasing. This pressure is then transferred to tank1 via the lumping connector.

Thus, the selection of the master tank plays a crucial role in deciding the gas pressure and subsequent results.