# 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 HyperWorks UI Introduction, and have a basic understanding of HyperMesh, AcuSolve, and HyperView. To run this simulation, you will need access to a licensed version of HyperMesh and AcuSolve.

Prior to running through this tutorial, copy HyperMesh_tutorial_inputs.zip from <Altair_installation_directory>\hwcfdsolvers\acusolve\win64\model_files\tutorials\AcuSolve to a local directory. Extract ACU-T4002_SloshingTank.hm and gravity.c from HyperMesh_tutorial_inputs.zip.

Since the HyperMesh 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

## Open the HyperMesh Model Database

1. Start HyperMesh and load the AcuSolve user profile.
Refer to the HM introductory tutorial, ACU-T: 1000 HyperWorks UI Introduction, to learn how to select AcuSolve from User Profiles.
2. Click the Open Model icon located on the standard toolbar.
The Open Model dialog opens.
3. Browse to the directory where you saved the model file. Select the HyperMesh file ACU-T4002_SloshingTank.hm and click Open.
4. Click File > Save As.
The Save Model As dialog opens.
5. Create a new directory named TankSloshing 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 TankSloshing as the file name for the database, or choose any name of your preference.
7. Click Save to create the database.

## Set the General Simulation Parameters

### Set the Analysis Parameters

1. Go to the Solver Browser, expand 01.Global, then click PROBLEM_DESCRIPTION.
2. Change the Analysis type to Transient.
3. Set the Multiphase equation to Level Set.
4. In the Solver Browser, click 02.SOLVER_SETTINGS under 01.Global.
5. Set the Max time steps to 0 and press Enter.
6. Set the Final time to 4.0 sec.
7. Set the Initial time increment to 0.006 sec.
8. Change the Min stagger iterations to 2 and press Enter.
9. Change the Max stagger iterations to 6 and press Enter.
10. Change the Relaxation factor to 0.0.
11. Check that the Flow and Field options are turned On.

### Define the Nodal Outputs

1. In the Solver Browser, expand 17.Output and click NODAL_OUTPUT.
2. Set the Time step frequency to 10.
3. Toggle On the Output initial condition field.

## Create a Multiphase Model and Set the Body Force

### Create a Multiphase Material Model

1. In the Solver Browser, expand 02.Materials then right-click on MULTIPHASE and select Create.
2. Enter Air-Water as the name of the model.
3. In the Entity Editor, under the Fields tab, verify that the Field Interaction Type is set to Level Set.
4. Select Air_HM as the Field 1 Material.
5. Enter Air as the Field 1 name.
6. Select Water_HM as the Field 2 Material.
7. Enter Water as the Field 2 name.

### Set the Body Force

1. In the Solver Browser, expand 03.Body_Force then expand BODY_FORCE and click Gravity_HM.
2. In the Entity Editor, under the Gravity tab, change the Gravity type to User Function.
3. Set the User function name to usrGravity.
4. Set the Number of user values to 3.
5. Click the table icon in the Data: User values field.
The Number of user values dialog opens.
6. Enter (-0.06, 1.74, 0) as the three values then click Close.
7. A UDF in the form of C language (gravity.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 > All Programs > Altair HyperWorks <version> > AcuSolve Cmd Prompt .
2. Change the directory to the present working directory using the cd command.
3. Enter the command acuMakeDll -src gravity.c and press Enter.
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 and press Enter.
This command creates a set of files necessary for the use of the UDF.

## Set the Boundary Conditions and Nodal Initial Conditions

### Set the Boundary Conditions

By default, all components are assigned to the wall boundary condition. In this step, you will change them to the appropriate boundary conditions and assign material properties to the fluid volumes.
1. In the Solver Browser, expand 12.Surfaces > WALL.
2. Click Fluid. In the Entity Editor,
1. Change the Type to MULTIPHASE
2. Select Air-Water as the Material.
3. Select Gravity_HM as the Body force.
3. Click Wall. In the Entity Editor, verify that the Type is set to WALL.
4. Change the Front and Rear component Types to SLIP.

### Create a Node Set

1. Go to the Model Browser, right-click on empty space in the browser area, and select Create > Set.
2. In the Entity Editor, rename the set to Water_Column.

### Set the Nodal Initial Conditions

1. Go to the Solver Browser, expand 01.Global, then click 03.NODAL_INITIAL_CONDITION.
2. In the Entity Editor, under the Field tab, set the Type to Nodal Values.
3. Set the Multiphase Field to Water.
4. Set the Select nodes by option to Node Set.
5. With the Node Set Count set to 1, select Water_Column as the Node Set.
6. Set the Initial Volume Fraction to 1.0.
7. Save the model.

### Assign Nodes to the Node Set

1. Go to the Model Browser, right-click on empty space in the browser area, and select Create > Block.
2. In the Entity Editor, rename the block to Water_Column.
3. Set the Min and Max coordinates to (0, 0, 0) and (1.2, 0.12, 0.1), respectively.
4. In the Model Browser, click Sets > Water_Column. In the Entity Editor, click on the Nodes collector in the Entity IDs field.
5. In the panel area, click the nodes collector and select the by block option.
6. Toggle on the Water_Column block then click select.
All the nodes in the Water column block are highlighted in the graphics area.
7. Click proceed.
8. Optional: Turn off the display of the Water_Column block.
9. Save the model.

### Assign the Reference Pressure

1. In the Solver Browser, right-click on 15.Nodal_Boundary_Condition and select Create.
2. Change the name to Fixed Pressure Node.
3. Change the Definition to Nodes.
4. Set the Number of Nodes to 1.
5. Click the Node collector and select a node on the Fluid volume in the graphics window.
6. Click proceed in the panel area.
7. Change the Boundary condition variable to Pressure.
8. Save the model.

## Compute the Solution

In this step, you will launch AcuSolve directly from HyperMesh and compute the solution.

### Run AcuSolve

1. Turn on the visibility of all mesh components.
For the analysis to run, the mesh for all active components must be visible.
2. Click on the ACU toolbar.
The Solver job Launcher dialog opens.
3. Optional: For a faster solution time, set the number of processors to a higher number (4 or 8) based on availability.
4. The Output time steps can be set to All or Final. Since this is a Transient analysis, set it to All.
5. Leave the remaining options as default and click Launch to start the solution process.

## Post-Process the Results with HyperView

Once the solution has converged, close the AcuProbe and AcuTail windows. Go to the HyperMesh window and close the AcuSolve Control tab.

### Open HyperView and Load the Model and Results

1. In the HyperMesh main menu area, click Applications > HyperView.
Once the HyperView window is loaded, the Load model and results panel should be open by default. If you do not see the panel, click File > Open > Model.
2. In the Load model and results panel, click next to Load model.
3. In the Load Model File dialog, navigate to your working directory and select the AcuSolve .Log file for the solution run that you want to post-process. In this example, the file to be selected is TankSloshing.1.Log.
4. Click Open.
5. Click Apply in the panel area to load the model and results.

### Create the Water Flow Animation

In this step, you will create an animation of the water flow as it fills in through the inlet.

1. Orient the display to the xy-plane by clicking on the Standard Views toolbar.
2. Click on the Results toolbar to open the Contour panel.
3. Select Volume_fraction-2-Water (s) as the Result type.
4. Click Apply to display the volume fraction contour at the first time step.
5. Click the Legend tab then click Edit Legend.
6. In the Edit Legend dialog, change the Number of levels to 2 and the Numeric format to Fixed.
7. On the Animation toolbar, click the Animation Controls icon .
8. Drag the Max Frame Rate slider to 5 fps.
9. Click the Start/Pause Animation icon to play the animation in the graphics area.

### Save the Animation

1. In the menu area, select Preferences > Export Settings > AVI.
2. In the Export Settings AVI dialog, set the Frame rate to 5 fps and click OK.
3. On the ImageCapture toolbar, make sure that the Save Image to File option is On.
4. Click the Capture Graphics Area Video icon .
The Save Graphics Area Video As dialog opens.
5. Navigate to the location where you want to save the file, enter a name of your choice, and click Save.

## 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 HyperMesh 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 in HyperView where you generated an animation of the water sloshing in the tank.