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

## Prerequisites

This tutorial provides instructions for running a transient simulation of a two-phase flow in a rectangular tank using the level set model. Prior to starting this tutorial, you should have already run through the introductory tutorial, ACU-T: 1000 Basic Flow Set Up, and have a basic understanding of HyperWorks CFD and AcuSolve. To run this simulation, you will need access to a licensed version of HyperWorks CFD and AcuSolve.

Before you begin, copy the file(s) used in this tutorial to your working directory.

Since the HyperWorks CFD database (.hm file) contains meshed geometry, this tutorial does not include steps related to geometry import and mesh generation.

## Problem Description

The problem to be solved is shown schematically in the figure below. It consists of a partially filled water tank and from time t=0, water inside the tank is subjected to a sinusoidal varying body force along x-direction and constant gravity along y-direction.

The body force in the x-direction is given by the expression:

$A{\omega }^{2}\mathrm{sin}\left(\omega t+\phi \right)$
Where
• Α = Amplitude of oscillation = -0.06 m
• ω = Frequency of oscillation = $\frac{2\pi }{T}$ = 3.6 rad/sec
• T = Time period of oscillation = 1.74 sec
• φ = Phase difference = 0

## Start HyperWorks CFD and Open the HyperMesh Database

1. Start HyperWorks CFD from the Windows Start menu by clicking Start > Altair <version> > HyperWorks CFD.
2. From the Home tools, Files tool group, click the Open Model tool.
The Open File dialog opens.
3. Browse to the directory where you saved the model file. Select the HyperMesh file ACU-T4002_TankSloshing.hm and click Open.
4. Click File > Save As.
5. Create a new directory named Tank_Sloshing and navigate into this directory.
This will be the working directory and all the files related to the simulation will be stored in this location.
6. Enter tank_sloshing as the file name for the database, or choose any name of your preference.
7. Click Save to create the database.

## Validate the Geometry

The Validate tool scans through the entire model, performs checks on the surfaces and solids, and flags any defects in the geometry, such as free edges, closed shells, intersections, duplicates, and slivers.

To focus on the physics part of the simulation, this tutorial input file contains geometry which has already been validated. Observe that a blue check mark appears on the top-left corner of the Validate icon on the Geometry ribbon. This indicates that the geometry is valid, and you can go to the flow set up.

## Set Up the Problem

### Set Up the Simulation Parameters and Solver Settings

1. From the Flow ribbon, click the Physics tool.
The Setup dialog opens.
2. Under the Physics models setting:
1. Activate the Multiphase flow radio button.
2. Set the Multifluid type to Immiscible and the Immiscible material to Air-Water
3. Set the Time step size to 0.006 and the Final time to 4.0
4. Select Laminar as the Turbulence model.
5. Set the gravity to -9.81 m/sec2 in the y direction.
6. Select Absolute for the Pressure scale.
3. Click the Solver Controls setting.
1. Set the Minimum stagger iterations to 2.
2. Set the Maximum stagger iterations to 6.
4. Close the dialog and save the model.

### Assign Material Properties

1. From the Flow ribbon, click the Material tool.
2. In the Materials legend, verify that Air-Water is assigned.
3. Click on the guide bar.

### Set the Body Force

1. From the Flow ribbon, click the Sources > Momentum tool.
2. Select the solid body.
3. In the microdialog, set the Type to User Function.
4. Click and enter the following values.

These values are for the amplitude of oscillation = -0.06 m; time period of oscillation = 1.74 sec; Phase difference = 0

5. In Momentum Source legend, double-click on Momentum, rename it to bodyForce, then press Enter.
Note: The values provided above are the ones described in the problem description. 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.
6. On the guide bar, click to execute the command and exit the tool.

### Compile the Body Force UDF

A UDF in the form of C language (bodyForce.c) is provided with the tutorial. This program should be compiled using the following steps.
• For Windows:
1. Start AcuSolve Command Prompt from the Windows Start menu by clicking Start > Altair <version> > AcuSolve Cmd Prompt .
2. Change the directory to the present working directory using the cd command.
3. Enter the following command then press Enter.

acuMakeDll -src bodyForce.c

• For Linux:
1. In the terminal, change the directory to the present working directory using the cd command.
2. Enter the following command then press Enter.

acuMakeLib -src bodyForce.c

This command creates a set of files necessary for the use of the UDF.

### Define Flow Boundary Conditions

1. From the Flow ribbon, click the No Slip tool.
2. Select all four surfaces shown in the figure below.
3. Click on the guide bar.
4. Click the Slip tool.
5. Select the right most face on the positive z-axis, as shown in the figure below.
6. In the Boundaries legend, double-click on Slip, rename it to z_pos, then press Enter.
7. On the guide bar, click to execute the command and remain in the tool.
8. Rotate the model and select the opposite face.
9. In the Boundaries legend, rename Slip to z_neg.
10. Click on the guide bar.
11. Save the database.

### Define Nodal Initial Conditions

1. From the Solution ribbon, click the Plane tool.
2. Select the solid body.
3. Click Plane on the guide bar.
4. Click any point on the model to initially position the plane.
5. Click in the microdialog and manually set the plane axis to Y.
6. Click and set the coordinates to (0.60, 0.12, 0.10).
7. Press Esc two times.
8. Click to add a variable then select Fluid from the list.
9. Make sure that the Value is set to Water then press Esc again.
10. Click on the guide bar.
11. Save the database.

### Define Nodal Outputs

1. From the Solution ribbon, click the Field tool.
The Field Output dialog opens.
2. Set the parameters for Solution variables as shown in the figure below.

## Run AcuSolve

1. From the Solution ribbon, click the Run tool.
The Launch AcuSolve dialog opens.
2. Set the Parallel processing option to Intel MPI.
3. Optional: Set the number of processors to 4 or 8 based on availability.
4. Expand the Default initial conditions tab and deactivate the Pre-compute flow and Pre-compute turbulence options.
5. Set the x-velocity to 0.
6. Leave the remaining options as default and click Run to launch AcuSolve.
The Run Status dialog opens. Once the run is complete, the status is updated and you can close the dialog.
Tip: While AcuSolve is running, right-click on the AcuSolve job in the Run Status dialog and select View Log File to monitor the solution process.

## Post-Process the Results with HW-CFD Post

1. Once the solution is completed, navigate to the Post ribbon.
2. From the menu bar, click File > Open > Results.
3. Select the AcuSolve log file in your problem directory to load the results for post-processing.
The solid and all the surfaces are loaded in the Post Browser.
4. Click the Top face on the View Cube to align the model.
5. Right-click on the z_pos boundary in the Post Browser and select Edit.
6. In the display properties microdialog, set the display to volume fraction water.
7. Activate the Legend toggle and click to refresh the range.
8. Click , and set the Colormap Name to Rainbow Uniform.
9. Click on the guide bar.
10. Click at the bottom of the modeling window to view a live animation of the flow.
11. Save the animation.
1. Go to File > Screen Capture > Advanced Capture.
2. Click on the toolbar.
3. Uncheck Include mouse cursor.
4. Set the frame rate to 24.
5. Click on the toolbar then drag over the area you want to record.
6. Click to start recording and the same button to stop recording.
7. Name the file and save it.

## Summary

In this tutorial, you successfully learned how to set up and solve a transient multiphase flow problem involving water sloshing in a tank using HyperWorks CFD and AcuSolve. You also learned how to create a multiphase model using the Level Set method and specify the body force using a user-defined function and then compile the UDF. Once the solution was computed, you post-processed the results using the Post ribbon where you generated an animation of the water sloshing in the tank.