↑top

Tutorial : Measuring drag coefficient on simple car model

Updated: January 12, 2020

In this tutorial, we will create analysis area around a imporing shape and setting files for OpenFOAM® and output force coefficient values ​​such as drag coefficient and lift coefficient.

Analysis summary

We will calculate the external flow around a simple car-model (Ahmed body) for 5 seconds in simulation time. The model is placed in a air flow of approximately 10 km/h. And we will set the output settings to obtain the values of drag coefficient, lift coefficient and others at each time.

ParaFoam velocity result Analysis result

Creating an analysis configuration file

Creating a project

Open XSim. Type "MyProject" as Project Name and click Create button to create project.

A dialog for project creating A dialog for project creating

Importing shapes

We will use a prepared shape file in this tutorial. Please download a zipped file from next link, "tutorial-AhmedBody.zip", and extract it.

Drag&Drop the extracted file "AhmedBody.stl" at "Drop files" tab and load it. The loaded shape will be shown in 3D view.

Importing shapes from a file Importing shapes from a file

Select "Cuboid" as type in "Add shapes" tab and set (-2, -1.5, 0) m to minimum coordinate, (5, 1.5, 1.5) m to maximum coordinate. Then click Add. You can switch the 3D display to semitransparent by clicking a display-mode button'toggle display' iconunder 3D view.

Adding a shape Adding a shape
Adding a shape for analysis area (3D view) Adding a shape for analysis area (3D view)

Click Next button to go to Mesh page.

Mesh

  • Refinement settings

    Select "Cuboid" as range type in "Refinement settings" and set (-0.1, -0.5, 0) m to minimum coordinate, (3, 0.5, 0.5) m to Maximum coordinate. And set 2 to refinement level. Preview the range shape by clicking preview button'Preview' icon, then click Add.

    Refinement settings (Cuboid) Refinement settings (Cuboid)
    Cuboid area for refinement Cuboid area for refinement

    Then select "Surface" as range type in "Refinement settings" and "AhmedBody" as assembly. Set 3 to refinement level and click Add.

    Refinement settings (Surface) Refinement settings (Surface)
  • Layer mesh settings

    Confirm that 0.3 is set to layer thickness ration and 3 is set to number of layers. Click "AhmedBody" and "ZMin" in Navigation view at left side of the window to select, then click Set.

    Layer mesh settings Layer mesh settings

Click Next button to go to Basic Settings page.

Basic Settings

In this section, we will set a type of analysis. Select "Transient" and set 5 seconds as end time.

Basic Settings Basic Settings

Click Next button to go to Physical Property page.

Physical Property

In this section, we will set a type of fluid. Click Physical property library button'Physical property library' iconto show dialog. Select "Air" in the dialog and click OK.

Physical Property Physical property
A dialog for physical property library A dialog for physical property library

Click Next button to go to Initial Condition page.

Initial Condition

We will set initial flow field to get final solution as early as possible. Select "Velocity" as physical quantity and set (2.77, 0, 0) m/s as value. Then click Set.

Initial condition settings Initial condition settings

Click Next button to go to Flow Boundary Condition page.

Flow Boundary Condition

  • Inflow boundary

    Select "Selected regions" as region and "Fixed flow velocity" as type. Then select "XMin" on Navigation view and set (2.77, 0, 0) m/s as flow velocity. After that, click Set.

    Inflow boundary condition Inflow boundary condition
  • Outflow boundary

    Select "Selected regions" as region and "Fixed static pressure" as type. Then select "XMax" on Navigation view and set 0 Pa as static pressure. After that, click Set.

    Outflow boundary condition Outflow boundary condition
  • Stationary wall boundary

    Select "Selected regions" as region and "Stationary wall" as type. Then select "AhmedBody" and "ZMin" on Navigation view and click Set.

    Wall boudary condition Wall boudary condition

Inflow boudary and outflow boudary are displayed as arrows in 3D view.

Inflow/Outflow boundaries will be shown in 3D view Inflow/Outflow boundaries will be shown in 3D view

Click Next button to go to Calculation Settings page.

Calculation Settings

In this section, we set parallel number of CPU core that we use in this calculation (for example, 4).

Calculation settings Calculation settings

Click Next button to go to Output page.

Output

Because this analysis is a transient analysis, select "Each specified time" as type and set 1 second to interval.

Output settings Output settings

Next, we will set to output drag coefficient.

Select "Region" tab and select "Selected regions" as region and "Force coefficients" as type. Then set 2.77 m/s as Reference velocity.

Select "AhmedBody" on Navigation view and click Measure projection area button'Measure projection area' icon to show Projection Area dialog. Then click OK to set Reference area.

Projection Area dialog
Projection Area dialog

After setting all parameters, click Set button to set Force coefficients output setting.

Force coefficients output setting
Force coefficients output setting

Click Next button to go to Export page.

Export

Finally we finished all setings. Click Export button to export the analysis setting as zipped OpenFOAM case directory "MyProject.zip". The zip file download starts immediately.

Export Export

Running calculation

Extract downloaded file "MyProject.zip". There is a bash-script "Allrun " in the case directory. So run the script to make mesh and calculate the OpenFOAM solver by following command.

./Allrun

If the machine that calculation is running has desktop environment and gunuplot was installed, residual convergence chart will be displayed.

Chart for monitoring Chart for monitoring

Confirming calculation result

After the calculation, execute a following command to visualize the mesh and the calculation result.

paraFoam

Mesh is following.

Mesh of shape surface Mesh of shape surface
Mesh of cross section in flow direction Mesh of cross section in flow direction
Mesh of cross section in flow direction (zoom) Mesh of cross section in flow direction (zoom)

Distributions of Flow velocity and pressure are following.

Flow velocity distribution Flow velocity distribution
Flow velocity distribution (only fluid-side) Flow velocity distribution (only fluid-side)
Pressure distribution Pressure distribution
Pressure distribution (only fluid-side) Pressure distribution (only fluid-side)

Drag coefficient and other force coefficients are output at forceCoeffs.dat file in postProcessing/forceCoeffs(AhmedBody)/0 folder as following.

# Force coefficients
# liftDir     : (0.000000e+00 0.000000e+00 1.000000e+00)
# dragDir     : (1.000000e+00 0.000000e+00 0.000000e+00)
# pitchAxis   : (0.000000e+00 -1.000000e+00 0.000000e+00)
# magUInf     : 2.770000e+00
# lRef        : 1.000000e+00
# Aref        : 1.151719e-01
# CofR        : (3.369437e-01 2.145408e-05 7.275021e-02)
# Time        	Cm            	Cd            	Cl            	Cl(f)         	Cl(r)         
0.000978474   	-6.357709e+00	6.849434e+01	1.544316e+01	1.363869e+00	1.407929e+01
0.00208115    	-6.835383e+00	7.889048e+01	1.890370e+01	2.616468e+00	1.628723e+01
0.0033086     	-5.389873e+00	6.456209e+01	1.583506e+01	2.527657e+00	1.330740e+01
…………
4.99615       	1.775397e-01	5.243182e-01	5.323724e-01	4.437259e-01	8.864652e-02
4.99808       	1.776140e-01	5.243803e-01	5.320828e-01	4.436554e-01	8.842744e-02
5             	1.776393e-01	5.244558e-01	5.318148e-01	4.435467e-01	8.826809e-02

Cm, Cd and Cl represent the torque coefficient, drag coefficient and lift coefficient. Cl(f) and Cl(r) is defined by "Cl/2.0 + Cm" and "Cl/2.0 - Cm".