# ACU-T: 5201 Coupled Simulation of a Check Valve using AcuSolve and MotionSolve

## Prerequisites

This tutorial introduces you to the workflow for setting up an AcuSolve-MotionSolve co-simulation using HyperMesh Desktop. Prior to starting this tutorial, you should have already run through the introductory HyperWorks 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-T5201_CheckValveCoupled.hm and Valve_model.xml 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 addressed in this tutorial is shown schematically in Figure 1. It consists of a cylindrical pipe containing water that flows past a check valve with a shutter attached to a virtual spring (not included in the geometry). The inlet pressure varies over time and the movement of the shutter will be determined as a function of the balance of the fluid forces against the reactive force of the spring. The problem is rotationally periodic at 30° increments about the longitudinal axis, and it is assumed that the resulting flow is also rotationally periodic, allowing for modeling with the use of a wedge-shaped section. For this tutorial, a 30° section of the geometry is modeled, as shown in the figure. Modeling a portion of an rotationally periodic geometry leads to reduced computation time while still providing an accurate solution.

The pipe has an inlet diameter of 0.08 m and is 0.4 m long. The check-valve assembly is 0.085 m downstream of the inlet. It consists of a plate 0.005 m thick with a centered orifice 0.044 m in diameter and a shutter with an initial position 0.005 m from the opening, simulating a nearly closed condition. The shutter plate is 0.05 m in diameter and 0.005 m thick. The shutter plate is attached to a stem 0.03 m long and 0.01 m in diameter. The mass of the shutter and stem is 0.2 kg and its motion is affected by a virtual spring with a stiffness of 2162 N/m. The motion of the valve shutter is limited by a stop mounted on a perforated plate downstream of the shutter.

Modeling the geometry as a 30° section requires that the fluid model is set up to be consistent with the rigid-body model. Since only 1/12 of the rigid body is modeled, the forces computed by AcuSolve that act on the valve shutter represent 1/12 of the actual force on the device. The rigid-body-dynamics model was set up in MotionSolve with scaled settings of mass and spring stiffness to account for the fact that you are only modeling a small section of the full geometry. Additional information regarding the setup of this problem in MotionSolve is provided in the MotionSolve documentation.

The fluid in this problem is water, which has a density (ρ) of 1000 kg/m3 and a molecular viscosity (μ) of 1 X 10-3.

At the start of the simulation the flow field is stationary. Flow is driven by the pressure at the inlet, which varies over time as a piecewise linear function shown in Figure 2. As the pressure at the inlet rises, the flow will accelerate as the valve opens. The turbulence viscosity ratio is assumed to be 10.

The initial inlet pressure is 0 Pa. At 0.002 s the pressure begins to ramp up and reaches 29,000 Pa at 0.05 s. The pressure is held at 29,000 Pa and begins to ramp back down starting at 0.2 s, reaching the initial pressure at 0.25 s where it remains for the rest of the simulation.

Prior simulations of this geometry indicate that the average velocity at the inlet reaches a maximum of 0.98 m/s. At this velocity, the Reynolds number for the flow is 78,400. When the Reynolds number is above 4,000 it is generally accepted that flow should be modeled as turbulent. Mesh motion will be modeled using arbitrary mesh movement (arbitrary Lagrangian-Eulerian mesh motion).

For this case, the transient behavior of interest occurs in the time it takes for the pressure to ramp up and ramp back down, which is given by the transient pressure profile. To allow time for the spring to recover additional time will be simulated. For this tutorial 0.1 s is added after the pressure drops back to initial conditions for a total duration of 0.35 s.

Another critical decision in a transient simulation is choosing the time increment. The time increment is the change in time during a given time step of the simulation. It is important to choose a time increment that is short enough to capture the changes in flow properties of interest, but does not require unnecessary computation time. The change in inlet pressure from initial conditions to maximum occurs over 0.048 s. A time increment of 0.002 s would allow for excellent resolution of the transient changes without requiring excessive computational time.

## Open the HyperMesh Model Database

1. Start HyperMesh Desktop 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-T5201_CheckValveCoupled.hm and click Open.
4. Click File > Save As.
The Save Model As dialog opens.
5. Create a new directory named CheckValve_Coupled 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 Valve_Coupled as the file name for the database, or choose any name of your preference.
7. Click Save to create the database.
8. Move the Valve_model.xml file (provided along with the input file) to the problem directory.

## Set the General Simulation Parameters

### Set the Analysis Parameters

1. Go to the Solver Browser, expand 01.Global, then click PROBLEM_DESCRIPTION.
2. In the Entity Editor, change the Analysis type to Transient.
3. Set the Turbulence model to Spalart Allmaras.
4. Set the Mesh type to Arbitrary Mesh Movement (ALE).
5. Turn External Code On.

### Specify the Solver Settings

1. In the Solver Browser, click 02.SOLVER_SETTINGS under 01.Global.
2. In the Entity Editor, set the Max time steps to 0.
3. Set the Final time to 0.35 sec.
4. Set the Initial time increment to 0.002 sec.
5. Verify that the Convergence tolerance is set to 0.001.
6. Set the Max stagger iterations to 3.
7. Change the Relaxation factor to 0.
8. Turn External code On and verify that the Flow, Turbulence and Mesh options are turned on.

### Set External Code Parameters for Communication with MotionSolve

In this simulation, MotionSolve is being used to calculate the motion of the valve in response to the fluid loads calculated by AcuSolve. In order to achieve this, AcuSolve and MotionSolve will communicate through a socket connection. This communication approach enables the two codes to be run on separate machines and even different operating systems.
1. In the Solver Browser, under 01.Global, click 08.EXTERNAL_CODE.
2. In the Entity Editor, verify that the Communication option is set to Socket.
3. Verify that the Socket initiate check box is not activated.
This will ensure that the external code (MotionSolve) will open the socket and AcuSolve will “listen” for a connection on the indicated socket port.
4. Verify that the Socket host is set to localhost.
This indicates that AcuSolve and MotionSolve are running on the same machine. If MotionSolve was running on a different machine, the host name or IP address would need to be supplied here.
5. Enter 48000 as the Socket port.
This is the default port used for communication between AcuSolve and MotionSolve.

### Define the Nodal Output Frequency

1. In the Solver Browser, expand 17.Output then click NODAL_OUTPUT.
2. In the Entity Editor, set the Time step frequency to 1.
3. Save the model.

## Set the Boundary Conditions

### Create a Multiplier Function for Inlet Pressure

In this step, you will create a multiplier function for the pressure at the inlet, which will then be applied at the inlet later in the tutorial. The inlet pressure starts at 0 Pa, ramps up to 29,000 Pa, is then held steady briefly, and then ramps back to 0 Pa.
1. Go to the Model Browser. Right-click anywhere in empty space and select Create > Curve from the context menu.
2. In the Curve editor dialog, click New.
3. In the panel area, enter inlet_pressure as the Name and then click on proceed.
4. In the Curve editor dialog, enter the following X,Y values.
5. Click Update to plot the curve on the graph in the dialog.
6. Click Close.
7. Go to the Solver Browser, right-click on 05.Multiplier_Function and select Create.
8. Name the multiplier function inlet_pressure.
9. In the Entity Editor, change the Multiplier Function Type to Piecewise Linear.
10. For Curves, select inlet_pressure.
11. Verify that the Curve fit variable is set to Time and the Evaluation Type is set to Per Time Step.

### 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 FLUID.
2. Set the Material to Water_HM.
3. Leave the remaining default options.
3. Click Inflow. In the Entity Editor,
1. Change the Type to INFLOW.
2. Turn On Show advanced features.
3. Change the Inflow type to Stagnation Pressure.
4. Set the Stagnation Pressure to 1 N/m2.
5. Set the Stagnation Pressure multiplier function to inlet_pressure.
6. Set the Turbulence input type to Viscosity Ratio.
7. Set the Material to Water_HM in the top portion of the Entity Editor.
8. Set the Turbulence viscosity ratio to 10.
4. Click Outflow. In the Entity Editor, change the Type to OUTFLOW.
5. Click Valve_wall. In the Entity Editor,
1. Change the Type to EXTERNAL_CODE_SURFACE.
2. Set the Coupling type to Rigid body.
3. Verify that the Coupling direction is set to Both.
4. Enter Model-Shutter Body as the name of the Rigid body.
The name entered here needs to match the body name in the prepared MotionSolve model, Valve_model.xml, to ensure that information about forces and motion for this surface match up between AcuSolve and MotionSolve.
6. Click Outflow. In the Entity Editor, verify that the Type is set to WALL.
7. Click Front_symmetry. In the Entity Editor,
1. Change the Type to SYMMETRY.
2. Change the Mesh displacement BC type to Slip.
8. Similarly, click Back_symmetry, set the Type to SYMMETRY, and the Mesh displacement BC type to Slip.
9. Save the model.

## Compute the Solution

This tutorial uses a coupled solution between AcuSolve for the flow field and MotionSolve for the rigid-body-dynamics. Solving the problem for this tutorial involves two steps:
1. Start AcuSolve
2. Start MotionSolve

The next sets of steps provide instructions for these two tasks.

### Run AcuSolve

In this step, you will launch AcuSolve to compute a solution for this case.

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. Set the Number of processors to 4.
4. Leave the remaining options as default and click Launch to start the solution process.

### Run MotionSolve

In the next steps you will start MotionSolve and provide settings for communication with AcuSolve.
1. Run Start > All Programs > Altair HyperWorks <version> > MotionSolve to open the HyperWorks Solver Run Manager.
2. Click beside the Input file(s) field, browse to the location where you saved Valve_model.xml, and open it.
3. Click to open the Available Options dialog.
4. Enable the -as_cosim option to indicate coupling between MotionSolve and AcuSolve.
5. In the -as_cosim dialog that appears, click None.
6. In the Available Options options dialog, click Apply Options and close the dialog.
7. Click Run to start MotionSolve.
As the solution progresses, a HyperWorks Solver View window will open. Solution progress is reported in this window. The AcuSolve AcuTail window will also update as the solution progresses.
As the solution progresses, you can monitor the progress with AcuProbe, as detailed in the next steps.

### Monitor the Solution with AcuProbe

While AcuSolve is running, you can monitor flow characteristics such as inlet pressure, displacement of the valve, and velocity of the valve, using AcuProbe.

Once the MotionSolve run launched, the AcuProbe window will be launched automatically after the first time step.

1. In the AcuProbe Data Tree, expand Surface Output > Inflow > Pressure.
2. Right-click on pressure and select Plot.
3. Similarly, expand Valve_wall > Geometry under Surface Output.
4. Right-click on mesh_x_displacement and select Plot.
Note: You might need to click on the toolbar in order to properly display the plot.

In the next steps you will create a plot of the x-velocity of the valve walls.

5. Turn off the plot of pressure at the inlet by right-clicking on Inflow and selecting Plot None.
6. Expand Valve_wall > Momentum, right-click on x_velocity, and select Plot.

## Post-Process the Results with HyperView

In this step, you will create an animation of the valve motion as the water flows across the valve. Once the solver run is complete, close the AcuProbe and AcuTail windows. In the HyperMesh Desktop window, close the AcuSolve Control tab and save the model.

### Switch to the HyperView Interface and Load the AcuSolve Model and Results

1. In the HyperMesh Desktop window, click the ClientSelector drop-down in the bottom-left corner of the graphics window.
2. Select HyperView from the list.
3. In the pop-up dialog that appears, click Yes.
The interface is changed to HyperView.

Once HyperView is loaded, the Load model and results panel should be open by default. If you do not see the panel, click File > Open > Model.

4. In the Load model and results panel, click next to Load model.
5. 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 Valve_Coupled.1.Log.
6. Click Open.
7. Click Apply in the panel area to load the model and results.

### Create an Animation of Velocity Magnitude

In the next step, you will create an animation of the velocity magnitude on the symmetry plane and then save it.
1. In the Results Browser, expand the list of Components then click the Isolate Shown icon .
2. Click the Front_symmetry component to turn off the visibility of all the components except the front symmetry surface.
3. Orient the display to the xy-plane by clicking on the Standard Views toolbar.
4. Click on the Results toolbar to open the Contour panel.
5. In the panel area, change the Result type to Velocity (v) and verify that the drop-down below it is set to Mag (magnitude).
6. Click the Components entity selector. In the Extended Entity Selection dialog, select Displayed.
7. Click Apply.
8. In the panel area, under the Display tab, turn off the Discrete color option.
9. Go to the Legend tab and then click Edit Legend.
10. In the Edit Legend dialog, change the Type to Dynamic scale and the Numeric format to Fixed then click OK.
11. Click on the Animation toolbar to play the velocity magnitude animation on the front symmetry plane.
12. On the ImageCapture toolbar, click on the Capture Graphics Area Video icon .
13. In the Save Graphics Area Video As dialog, browse to the directory where you want to save the animation, give a name to the video (ex: velocity mag), then click Save.

### Display Pressure and Velocity Contours on a Section Cut

In the next step, you will create a section cut on the mid-z plane and then display the pressure contours and velocity vectors on that cross section.
1. In the Results Browser, turn off the display of all the Components except the Fluid component.
2. Click on the Results toolbar to open the Contour panel.
3. In the panel area, change the Result type to Pressure (s).
4. Click the Components entity selector. In the Extended Entity Selection dialog, select Displayed.
5. Click Apply to create the contour plot of pressure.
6. In the panel area, under the Result tab, activate the Overlay result display check box (if not already selected).
7. Click the Section cut icon on the HV-Display toolbar.
8. In the panel area, click Add to create a new section cut named Section 1.
9. In the Define plane section, set the axis to Z Axis then click Apply.
10. Set the Z Base coordinate to 0 and press Enter.
11. Change the Display options from Clipping plane to Cross section.
12. Click Gridline. In the Gridline Options dialog, deactivate the Show check box under Grid line then click OK.
13. Click on the Results toolbar to open the Vector panel.
14. In the panel area, set the Result type to Velocity (v).
15. Click the Selection drop-down and select Sections from the list of options.
16. Click the Sections entity selector then select All.
17. In the panel area, activate the Overlay result display check box (if not set already).
18. Click Apply.
19. Under the Plot tab, verify that only the X+Y+Z Resultant option is selected.
20. Go to the Display tab, set the Size scaling option to Uniform, and enter a value of 0.002 in the size field.
21. Set the Color by option to Direction and set the X+Y+Z color to White.
22. Go to the Section tab, activate the Projected check box, then click Apply.
The vector plot should look like the one shown in the figure below.

The result at 0.156 sec is shown.

## Summary

In this tutorial, you learned the basic workflow to set up a co-simulation using AcuSolve and MotionSolve. The tutorial introduced you to the steps involved in setting up external code communication between AcuSolve and MotionSolve using HyperMesh Desktop and then running the simulation and post-processing the results using HyperView. You also learned how to create a vector plot on an existing contour plot on a cut plane.