# ACU-T: 4002 Sloshing of Water in a Tank

This tutorial provides the instructions for setting up, solving and viewing results for a transient simulation of a two-phase flow in a rectangular tank using the level set model. In this simulation, AcuSolve is used to compute the time-varying water-level interface due to sloshing of the water against the tank walls. This tutorial is designed to introduce you to a number of modelling concept necessary to perform two-phase simulations.

The basic steps in any CFD simulation are shown in ACU-T: 2000 Turbulent Flow in a Mixing Elbow. The following additional capabilities of AcuSolve are introduced in this tutorial:
• Two-phase flow simulation
• Transient simulation
• Use of a script for the water volume fraction initialization
• Use of user defined function for varying gravity
• Post-processing with AcuFieldView

## Prerequisites

You should have already run through the introductory tutorial, ACU-T: 2000 Turbulent Flow in a Mixing Elbow. It is assumed that you have some familiarity with AcuConsole, AcuSolve, and AcuFieldView. You will also need access to a licensed version of AcuSolve.

Prior to running through this tutorial, copy AcuConsole_tutorial_inputs.zip from <Altair_installation_directory>\hwcfdsolvers\acusolve\win64\model_files\tutorials\AcuSolve to a local directory. Extract sloshing_tank.x_t and gravity.cfrom AcuConsole_tutorial_inputs.zip.

## Analyze the Problem

An important step in any CFD simulation is to examine the engineering problem at hand and determine the important parameters that need to be provided to AcuSolve. Parameters can be based on geometrical elements (such as inlets, outlets, or walls) and on flow conditions (such as fluid properties, velocity).

In general, multiphase flows are mainly observed in real life environment, consisting of two or more fluids (gas, liquid, or solid). They have possible combinations of gas-liquid (dissolved gas), liquid-liquid (oil in water), liquid-solid (immersed particles), as well as gas-liquid-solid. The first two are examples of two-phase immiscible flows. The two-phase immiscible flows can be solved by tracking the interface between the two-phases. This tutorial will guide you through how to set up the two-phase flow problem using the level set method.

Figure 1 shows a schematic of the partially-filled water tank. From t = 0 onwards, water is subjected to a sinusoidal varying body force along x direction and constant gravity along y-direction, i.e.(1)
where
• Α = Amplitude of oscillation
• ω = Frequency of oscillation = $\frac{2\pi }{T}$
• T = Time period of oscillation
• φ = Phase difference
• t = Time
In the present simulation, we use the following values for the variables of the equation above.
• Α = -0.06 m
• T = 1.74 sec
• φ = 0

A UDF (gravity.c) written in C language is used for this purpose. For the details of the functions used in the gravity.c, refer to the AcuSolve User-Defined Functions Manual.

## Define the Simulation Parameters

### Start AcuConcolse and Create the Simulation Database

In this tutorial, you will begin by creating a database, populating the geometry-independent settings, loading the geometry, creating groups, setting group attributes, adding geometry components to groups, and assigning mesh controls and boundary conditions to the groups. Next you will generate a mesh and run AcuSolve to solve for the number of time steps specified. Finally, you will visualize some characteristics of the results using AcuFieldView.

1. Start AcuConsole from the Windows Start menu by clicking Start > Altair <version> > AcuConsole.
2. Click the File menu, then click New to open the New data base dialog.
Note: You can also open the New data base dialog by clicking on the toolbar.
3. Browse to the location that you would like to use as your working directory.
This directory is where all files related to the simulation will be stored. The AcuConsole database file (.acs) is stored in this directory. Once the mesh and solution are created, additional files and directories will be created within this directory.
4. Create a new folder named Sloshing_tank and open this folder.
5. Enter Sloshing_tank as the file name for the database
Note: In order for other applications to be able to read the files written by AcuConsole, the database path and name should not include spaces.
6. Click Save to create the database.

### Set General Simulation Parameters

In the next steps you will set attributes that apply globally to the simulation. To simplify this task, you will use the BAS filter in the Data Tree Manager. This filter reduces the number of items shown in the Data Tree to make navigation easier.

1. Click BAS in the Data Tree Manager to switch to basic view in the Data Tree.
2. Double-click the Global Data Tree item to expand it.
Tip: You can also expand a tree item by clicking next to the item name.
3. Double-click Problem Description to open the Problem Description detail panel.
Note: You may need to widen the detail panel by dragging the right edge of the panel frame.
4. Enter AcuSolve Multiphase Tutorial as the Title for this case.
5. Enter Sloshing tank 2D as the Sub title for this case.
6. Change the Analysis type to Transient.
7. Change the Multiphase equation to Level Set.

### Set Solution Strategy Parameters

1. Double-click Auto Solution Strategy in the Data Tree to open the Auto Solution Strategy detail panel.
2. Check that the Analysis type is set to Transient.
3. Set the Max time steps to 0.
4. Set the Final time to 4.0.
5. Set the Initial time increment to 0.006.
When setting up a transient analysis, if the Max time steps option is set to zero, this option is ignored. In such a case, the Final time must be specified. AcuSolve will then run until this final time is reached, incrementing with the specified initial time increment at each time step.
6. Set the Convergence tolerance to 0.001.
7. Set the Min stagger iterations to 2.
8. Set the Max stagger iterations to 6.
9. Set the Relaxation factor to 0.
When solving transient solutions, the relaxation factor should be set to zero. A non-zero relaxation factor causes incremental updates of the solution, which will impact the time accuracy of the solution for transient cases.
10. Check that the Flow and Multiphase flags are turned On.
11. Change Fluid 1 to Air.
12. Change Fluid 2 to Water.

### Set the Material Model Attributes

AcuConsole has three pre-defined materials, Air, Aluminum, and Water, with standard parameters defined. In the next steps you will verify that the pre-defined material properties of air and water match the desired properties for this problem.
1. Double-click Material Model in the Data Tree to expand it.
2. Double-click Water in the Data Tree to open the Water detail panel.

The material type for water is Fluid. Fluid is the default material type for any new material created in AcuConsole.

Note: Resize the detail panel, if needed, by dragging the right frame of the panel.
3. Click the Density tab. The density of water is 1000.0 kg/m3.
4. Click the Viscosity tab. The viscosity of water is 0.001 kg/m-sec.
5. Double click Air in the Data Tree to open the Air material detail panel.

The material type for air is Fluid. Fluid is the default material type for any new material created in AcuConsole.

6. In the Density tab, check the following:
1. The Type is set to Constant.
2. The Density value is 1.225 kg/m3.
7. Click the Viscosity tab. The viscosity of air is 1.781 x 10-5kg/m – sec.
8. Save the database to create a backup of your settings. This can be achieved with any of the following methods.
• Click the File menu, then click Save.
• Click on the toolbar.
• Click Ctrl+S.
Note: Changes made in AcuConsole are saved into the database file (.acs) as they are made. A save operation copies the database to a backup file, which can be used to reload the database from that saved state in the event that you do not want to commit future changes.

## Import the Geometry and Define the Model

### Import the Geometry

You will import the geometry in the next part of this tutorial. You will need to know the location of sloshing_tank.x_t in order to complete these steps. This file contains information about the geometry in Parasolid ASCII format.
1. Click File > Import.
2. Browse to the directory containing sloshing_tank.x_t.
3. Change the file name filter to Parasolid File (*.x_t *.xmt *X_T …).
4. Select sloshing_tank.x_t and click Open to open the Import Geometry dialog.

For this tutorial, the default values for the Import Geometry dialog are used to load the geometry. If you have previously used AcuConsole, be sure that any settings that you might have altered are manually changed to match the default values shown in the figure. With the default settings, volumes from the CAD model are added to a default volume group. Surfaces from the CAD model are added to a default surface group. You will work with groups later in this tutorial to create new groups, set flow parameters, add geometric components, and set meshing parameters.

5. Click Ok to complete the geometry import.
6. Rotate the visualization to view the entire model.

### Set the Multiphase Parameters

When Multiphase is activated in the Problem Description, by selecting a Multiphase equation, AcuConsole automatically generates the necessary set of parameters required to complete the multiphase model definition. These include defining the fields in the model, and also specifying the interaction models between the fields.

In this section you will define the multiphase parameters for the simulation.

1. Define the Fields:
1. Click on ALL in the Data Tree Manager to display all available simulation settings.
2. Expand the Advanced Solution Strategy > Multiphase Parameters Data Tree item.
3. Under Multiphase Parameters, expand the Fields item.
4. Double-click Air.
5. Set Modify advanced settings to On and check that the Material model is set to Air.
6. Double-click Water.
7. Set Modify advanced settings to On and check that the Material model is set to Water.
2. Define the Field Interaction Model:
1. Under Multiphase Parameters, expand the Field Interaction Model item.
2. Double-click Air-Water to open the detail panel.
3. Set Modify advanced settings to On.
4. Click Open Refs next to Fields 1.
5. Check that the entry in the Reference Editor is Air.
6. Click Open Refs next to Fields 2.
7. Check that the entry in the Reference Editor is Water.
8. Set the Surface tension model to None.
9. Set the Interface thickness option to Auto.
3. Define the Multiphase Model:
1. Under Multiphase Parameters, expand the Multiphase Model item.
2. Double-click Air-Water to open the detail panel.
3. Set Modify advanced settings to On.
4. Click Open Refs next to Field interaction models.
5. Check that the entry in the Reference Editor is Air-Water.

### Set the Body Force

The body force commands add volumetric source terms to the governing conservation equations. In this tutorial, gravitational body force will be applied to the fluid fields. The sinusoidal varying body force along x direction and constant gravity along y-direction will be defined as given by Equation 1.

1. Click BAS in the Data Tree Manager to switch to basic view in the Data Tree.
2. Double-click Body Force in the Data Tree to expand it.
3. Double-click on Gravity to open the Gravity detail panel.

The medium for gravity is Fluid. This means that the gravity defined here is applicable only on material models whose material type is fluid.

4. Change the Type to User Function.
5. Enter usrGravity for User function name.
6. Click Open Array next to User function values.
7. Click Add three times to create three rows and provide the following values:
Note: The values provided above are the ones described in the section Analyze the Problem. The user values should be provided in the same order as shown above because these values will be passed on to the UDF script, which refers to these values in specific order.
8. Click Ok.
Note: The definition of gravity here will have no effect on the simulation unless it is assigned to some volume set in the model.

### Compile the UDF

A UDF in the form of C language (gravity.c) is provided with the tutorial. This program should be compiled using the following steps:

1. For Windows:
1. Start AcuSolve Command Prompt from the Start menu by clicking Start > All Programs > Altair HyperWorks<version>AcuSolve > AcuSolve Cmd Prompt.
2. Change the directory to the present working directory using the 'cd' command.
3. Enter the command acuMakeDll –src gravity.c.
This command creates a set of files necessary for the use of the UDF.
2. For Linux:
1. In the terminal, change the directory to the present working directory using the 'cd' command.
2. Enter the command acuMakeLib -src gravity.c.
This command creates a set of files necessary for the use of the UDF.

### Define Nodal Outputs

The nodal output command specifies the nodal output parameters, for example, output frequency and number of saved states.

1. Expand the Output tree, then double-click Nodal Output to open the Nodal Output detail panel.
2. Set Time step frequency to 10.
This will save the nodal outputs at every time step.
3. Set Output initial condition to On.
This will instruct the solver to write the initial state of the problem as the first output file.
4. Make sure that the Number of saved states is set to 0.
Setting this option to zero will instruct the solver to save all of the solution state files.

### Set the Initial Conditions

1. Double-click on Nodal Initial Condition in the Data Tree to open the detail panel.
2. In the Multiphase field, select Water from the drop-down selector menu.
3. Set the Water initial condition type to Script.
4. Click Open text next to Water volume fraction script to open the text editor.
5. Enter the following script in the text editor:
value=0
if (y<0.12):value=1

The script above will set the initial volume fraction of the field water in the domain. For the nodes where y < 0.12, the volume fraction of water will be set to 1. For all other nodes, the volume fraction of water will be set to zero. At these nodes, the volume fraction of air will be 1, as the sum of volume fractions of the field should always be unity.

6. Click Ok to close the text editor.

### Apply Volume Parameters

Volume groups are containers used for storing information about a volume region. This information includes solution and meshing parameters applied to the volume and the geometric regions that these settings are applied to.

When the geometry was imported into AcuConsole, all volumes were placed into the "default" volume container.

Since the model for this tutorial has only a single volume, it will be the only volume in the default volume group when the geometry is imported. Even when there is a single volume in the model, it is advisable to rename the volume for ease of identification in future. In the next steps you will rename the default volume group container, and set the material and other properties for it.

1. Expand the Model Data Tree item.
2. Right-click on Surfaces and click Display off to turn off the display of surfaces.
3. Expand Volumes. Toggle the display of the default volume container by clicking and next to the volume name.
Note: You may not see any change when toggling the display if Surfaces are being displayed, as surfaces and volumes may overlap.
4. Rename the default volume group.
1. Right-click on default.
2. Click Rename.
3. Enter Fluid as the new name and press Enter.
Note: When an item in the Data Tree is renamed, the change is not saved until you press Enter on your keyboard. If you move the input focus away from the item without entering it, your changes will be lost.
5. Set up the Fluid volume element set.
1. Expand Fluid in the Data Tree.
2. Double-click Element Set under Fluid to open it in the detail panel.
3. For Medium, select Multiphase.
4. For Multiphase model, select Air-Water.
5. For Body force, select Gravity.

### Create Surface Groups and Apply Surface Attributes

Surface groups are containers used for storing information about a surface, including solution and meshing parameters, and the corresponding surface in the geometry that the parameters will apply to.

In the next steps you will define surface groups, assign the appropriate settings for the different characteristics of the problem, and add surfaces to the group containers.

In the process of setting up a simulation, you need to move into different panels for setting up the boundary conditions, mesh parameters, and so on, which can sometimes be cumbersome (especially for models with too many surfaces). To make it easier, less error prone, and for saving time, two new dialogs are provided in AcuConsole which you can use to verify and provide the information for all surface or volume entities at once. They are the Volume Manager and Surface Manager. In this section some features of the Surface Manager are exploited.

1. In the Data Tree, right-click on Volumes and select Display off to turn off the display of volumes.
2. Right-click on Surfaces and select Surface Manager.
3. In the Surface Manager dialog, click New two times to create two new surface groups.
Note: If you cannot see the Simple BC Active and Simple BC Type columns, click Columns, select these two columns from the list, and click Ok.
4. Turn the display off for all surfaces except for default surface.
5. Rename Surface Names (column 1) for Surface 1 and Surface 2, and set the Simple BC Active and Simple BC Type columns as per the table shown below.
6. Assign the surfaces to the Front and Rear surface groups.
1. Click Add to in the row belonging to Front in the Surface Manager dialog.
2. Select the planar surface with the maximum z-coordinate as shown in figure below and click Done.
3. Similarly assign the surface with the minimum z-coordinate to the Rear surface group.

When the geometry was loaded into AcuConsole, all geometry surfaces were placed in the default surface group container. This default surface group was renamed to wall. In the previous steps, you assigned some surfaces to various other surface groups that you created. At this point, all that is left in the wall surface group are the surfaces which make up the outer wall of the tank as shown below.

7. Close the Surface Manager dialog.

## Assign Mesh Controls

### Set Global Mesh Attributes

Now that the flow characteristics have been set for the whole problem, a sufficiently refined mesh has to be generated.

Global mesh attributes are the meshing parameters applied to the model as a whole without reference to a specific geometric volume, surface, edge, or point. Local mesh attributes are used to create mesh generation controls for specific geometry components of the model.

In the next steps you will set the global mesh attributes.

1. Click MSH in the Data Tree Manager to filter the settings in the Data Tree to show only the controls related to meshing.
2. Double-click the Global Data Tree item to expand it.
3. Double-click Global Mesh Attributes to open the Global Mesh Attributes detail panel.
4. Change the Mesh size type to Absolute.
5. Set Absolute mesh size to 0.015.

### Define Mesh Extrusion

The present simulation is equivalent to a representation of a 2D cross section of the model. In AcuSolve, 2D models are simulated by having just one element across the faces of the cross section. Thus, when these faces are set up with a similar boundary condition, it coerces the corresponding nodes across the faces to have same results. In this problem, these faces are the negative and positive z-surfaces. This kind of mesh is achieved in AcuSolve with mesh extrusion process. In the following steps you will define the process of extrusion of the mesh between these surfaces.

1. Expand the Model Data Tree item, right-click Mesh Extrusions and select New.
2. Right-click Mesh Extrusion 1, select Rename and enter Z extrusion.
3. Right-click on Z extrusion and select Define. Double-clicking Z extrusion will achieve the same result.
4. In the Mesh Extrusion Dialog Box that appears, make the following changes:
1. Check that Geometry type is set to surface.
2. From the drop down menus, assign Front and Rear as Side 1 and Side 2 respectively.
3. Check that Extrusion type is set to Number of layers.
4. Set Number of layers to 1.
5. Check that Extrusion options is set to Mixed Elements.
5. Click Ok to close the dialog box.

### Generate the Mesh

In the next steps you will generate the mesh that will be used when computing a solution for the problem.

1. Click on the toolbar to open the Launch AcuMeshSim dialog.
For this case, the default settings will be used.
2. Click Ok to begin meshing.

During meshing an AcuTail window opens. Meshing progress is reported in this window. A summary of the meshing process indicates that the mesh has been generated.

Note: The actual number of nodes and elements, and memory usage may vary slightly from machine to machine.
3. Visualize the mesh in the modeling window. Turn on the display of surfaces and set the display type to solid and wire.
4. You can rotate and zoom in the model to analyse the various mesh regions.

### Assign Reference Pressure

The present case does not have any inlet or outlet surfaces to define a boundary condition which sets the pressure level inside the domain. To make the solution more robust, you will set a pressure reference point using a nodal boundary condition. The following steps will show how to set up the reference pressure inside the CFD domain.

1. Click BAS in the Data Tree Manager to switch to basic view in the Data Tree.
2. Expand the Model Data Tree item.
3. Right-click on Nodes and select New from the context menu to create a new entity.
4. Rename Node 1 to Fixed Pressure Node.
5. Right-click Fixed Pressure Node and select Define.
6. In the Node Define Dialog Box, set Selection type to Pressure Point and Volumes to Fluid.
7. Click OK.
8. Expand Fixed Pressure Node and click Pressure.
Note: This single node will now act as the pressure reference point for the simulation.
9. Ensure that the Type is Zero.
10. Examine the location of the node.
1. Right-click on Fixed Pressure Node and select Display on.
2. Right-click on Surfaces and set Display Type to outline.
Note: The fixed pressure node should be displayed as a point in the modeling window.

## Compute the Solution and Review the Results

### Run AcuSolve

In the next steps, you will launch AcuSolve to compute the solution for this case.

1. Click on the toolbar to open the Launch AcuSolve dialog.

For this case, the default settings will be used. AcuSolve will run using four processors (if available, higher number of processors may be specified) and AcuConsole will generate AcuSolve input files and will launch AcuSolve. AcuSolvewill calculate the steady state solution for this problem.

2. Select Ok to start the solution process.

While computing the solution, an AcuTail window opens. Solution progress is reported in this window. A summary of the solution process indicates that the run has been completed.

The information provided in the summary is based on the number of processors used by AcuSolve. If you use a different number of processors than indicated in this tutorial, the summary for your run may be slightly different than the summary shown.

3. Close the AcuTail window and save the database to create a backup of your settings.

### Post-Process with AcuFieldView

The tutorial has been written with the assumption that you have become familiar with the AcuFieldView interface and basic operations. In general, it will be helpful to understand the following basics:
• How to find the data readers in the File menu and open up the desired reader panel for data input.
• How to find the visualization panels either from the Side toolbar or the Visualization panel menu to create and modify surfaces in AcuFieldView
• How to move the data around the graphics window using mouse actions to translate, rotate and zoom in to the data.
This tutorial shows you how to work with steady state analysis data.
1. Click on the AcuConsole toolbar to open the Launch AcuFieldView dialog.
2. Click OK to start AcuConsole.
You will see that the pressure contours have already been displayed on all the boundary surfaces with mesh.

#### Set Up AcuFieldView

1. Close the Boundary Surface dialog.
2. Click Viewer Options.
3. In the Viewer Options dialog box:
1. Deselect Perspective to turn off the perspective view.
2. Click Axis Markers to disable the axis markers.
3. Click Close.
4. On the toolbar, click the Colormap icon .
5. In the Scalar Colormap Specification dialog, click Background and select White.
6. Close the Scalar Colormap Specification dialog.
7. Click the Toggle Outline icon on the toolbar to turn off the outline display.
Your display should look similar to figure 1.

#### Coordinate the Surface Showing Water-Air Interface on the Mid Coordinate Surface

1. From the Surface tab in the Boundary Surface dialog, turn off the Visibility for the active boundary surfaces.
2. Click Create to create a new Boundary Surface set.
3. For the new set:
1. Turn on the visibility.
2. Set the Display Type to Outlines.
3. For Boundary Types, click Select All.
4. Click Ok.
5. Click to open the Coordinate Surface dialog.
6. Click Create to create a new coordinate surface.
7. Select Z as the Coordinate Plane.
This will create a coordinate surface at the mid – Z coordinate plane. The coordinate surface created is the mid plane between the two side surfaces in the model.
8. Change the Coloring to Scalar.
9. Change the Display Type to Smooth.
10. For Scalar Function, select volume_fraction-Water.
11. In the Colormap tab, set the maximum and minimum threshold values to 0.501 and 0.499 respectively.
12. From the Defined Views list, select +Z as the viewing direction.
Your view should now look like this:

#### Visualize the Animation of the Water Flow

1. Close the Coordinate Surface dialog.
2. From the Tools menu, select Flipbook Build Mode.
3. In the Flipbook Size Warning window, click OK to close it.
4. Go to the Tools menu again and select Transient Data.
The Transient Data Controls dialog opens.

If the Sweep Control in this dialog says Sweep instead of Build, the Flipbook Build Mode is not active. In Sweep mode, you will be able to create and visualize the animation but you will not be able to save it. To be able to save the animation, enable the Flipbook Build Mode.

1. Drag the time step slider to its leftmost position. Alternatively, enter zero in the Time Step or Solution Time box.
2. Click Apply.
The displayed state now corresponds to the initial state of the domain.
3. Click Build.
AcuFieldView will now build the frame-by-frame animation of the solution progressing through all the available time steps. You will be able to see the progress in the Building Flipbook dialog.

Once the Build process is complete, a Flipbook Controls dialog will appear.

4. In the Flipbook Controls dialog, click Frame Rate.
5. For Minimum time, enter 0.1 seconds and click Close.
6. Click Play to play the animation.
7. To save the animation, click Pause , and then click Save.
8. Provide a file name in the Flipbook File Save dialog, and click Save.

## Summary

In this AcuSolve tutorial, you successfully set up and solved a multiphase flow problem. The problem simulated sloshing of a rectangular water tank due to the gravity. As the water sloshed against the walls, the air-water interface in the tank was visualized. You started the tutorial by creating a database in AcuConsole, importing and meshing the geometry, and setting up the simulation parameters. Air and water were modelled as different fields occupying a single volume. Once the case was setup, the solution was generated with AcuSolve. Results were post-processed in AcuFieldView where you generated an animation of the water flow. New features that were introduced in this tutorial include: use of user defined function for simulating varying gravity.