HyperStudy

HS-1570: DOE and Optimization Study Using FLUENT

HS-1570: DOE and Optimization Study Using FLUENT

Previous topic Next topic Expand/collapse all hidden text  

HS-1570: DOE and Optimization Study Using FLUENT

Previous topic Next topic JavaScript is required for expanding text JavaScript is required for the print function  

This tutorial demonstrates how to perform a DOE study using HyperStudy and FLUENT. HyperMorph is used to parameterize the shape of the design.

The objective of this tutorial is to analyze the pressure loss sensitivity to cross sectional changes in a 90-degree elbow.

The files used in this tutorial can be found in <hst.zip>/HS-1570/.  Copy the files from this directory to your working directory. The tutorial directory includes the following files:

elbow.hm

HyperMesh file of a typical model.

hst_fluent.py

Customizable execution script for FLUENT (Windows and Linux).

fluent_options.txt

Customizable command line options for FLUENT.

fluent_batch.jou

Template for a FLUENT journal file.  The content of this file without comment lines is:

file confirm-overwrite no

file rc  case_file_prefix

file rd  "base_directory_name/case_file_prefix"

solve iterate 1000

file write-dat  case_file_prefix

exit

fluent_1

Figure 1.  Elbow pipe model

In this tutorial, you will:

Parameterize the model using HyperMorph and HyperStudy
Set up a DOE study
Post process DOE results

 

You should not change the keywords case_file_prefix and base_directory_name; they are replaced at runtime.   For the nominal run, the number of iterations (1000) is not very important, but depending on the type of simulation, the actual number of maximum iterations may need to be changed.  You can also add other commands to this journal file to meet the needs of new cases.

After performing the baseline simulation, a DOE study will be executed to analyze the effect of changing the 90-degree bend cross-section on the pressure drop at constant flow rate.  This is just to illustrate one of the many types of studies that can be done using FLUENT with HyperMesh and HyperStudy.

A DOE or optimization study starts from a baseline model.  This would be a model that has already been simulated with FLUENT.  For completeness, this tutorial also describes typical steps followed during the initial or baseline FLUENT simulation.  To this end, we use a mesh created in HyperMesh, the file Elbow.hm.

hmtoggle_plus1greyStep 1: Load the Model In HyperMesh
1.Start HyperMesh Desktop.
2.In the User Profiles dialog, set the user profile to Engineering Solutions, CFD, General.

hs_1570_user_profiles_dialog

3.From the menu bar, click File > Open > Model.
4.In the Open Model dialog, open the elbow.hm file. A finite element appears in the graphics area. This mesh contains 3D elements in the fluid collect, and 2D elements in the inlet, outlet, wall and symm collectors.
5.From the menu bar, click File > Export > Solver Deck.
6.Set File type to CFD.
7.Set Solver type to Fluent.
8.In the File field, save the file as elbow.cas.
9.Click Export.

hs_3040_export

10.In the dialog that opens asking if you would like to continue, click Yes.
11.In the dialog that opens informing you that the elbow.cas file has been created, click OK.
12.Exit HyperMesh Desktop.

 

hmtoggle_plus1greyStep 2: Run the Baseline Simulation with FLUENT
1.Open FLUENT (3ddp) Mode (Full Simulation).
2.From the menu bar, click File > Read > Case.

baseline_fluent

3.Navigate to your working directory and open the elbow.cas file. FLUENT reads the mesh (with all boundary conditions) as illustrated below:

baseline_fluent_2bmp

4.HyperMesh Desktop created the mesh in mm length units. In order to define the simulation you need to scale the mesh to the correct dimensions first by clicking Mesh > Scale from the menu bar.
5.In the Scale Mesh dialog, click Convert Units.
6.From the Mesh Was Created In list, select mm.

hs_1570_beforescale

7.Click Scale. FLUENT scales the dimensions to the mm unit.

hs_1570_afterscale

8.Click Close. You can leave all of the default options for fluid (air), viscous model (Laminar), and so on.
9.From the menu bar, click Define > Boundary Conditions.
10.In the Zone area, click inlet.
11.From the Type list, select mass-flow-inlet.

hs_1570_bc_inlet_1

12.In the dialog that appears prompting you to change the inlet type, click Yes.
13.In the Mass-Flow Inlet dialog, enter 0.01 in the Mass Flow Rate (kg/s).
14.From the Direction Specification Method list, select Normal to Boundary.

hs_1570_mass_flow_inlet_dialog

15.Click OK.
16.In the Zone area, click Outlet.
17.From the Type list, select pressure-outlet.
18.In the dialog that appears prompting you to change the outlet type, click Yes.
19.In the Pressure Outlet dialog, accept default setting of 0 Pascal and click OK.
20.Leave the symm and wall boundaries with their default values. In the Doe study, you will be monitoring the average pressure on the inlet surface.
21.From the menu bar, click Solve > Monitors.
22.In the Surface Monitors area, click Create.

hs_1570_monitors

23.In the Surface Monitors dialog, select the Plot and Write check boxes.
24.From the Report Type list, select Area-Weighted Average.
25.From the Field Variable lists, accept the default selections of Pressure and Static Pressure.
26.In the Surfaces area, select inlet.

hs_1570_monitors_surface

27.In the File Name field, accept the default filename surf-mon-1.out. You will use this file in HyperStudy during the Doe and/or Optimization stuides.
Note:For both Windows and UNIX systems, verify that that surf-mon-1.out file does not include directory information, otherwise this file will always be created in that directory. You will need the surf-mon-1.out file in the execution directories.
28.Click OK.
29.In the Residuals, Statistic and Force Monitors area, select Residuals - Print, Plot.
30.Click Edit.

hs_1570_monitors_residuals1

31.In the Residuals Monitors dialog, select the Print to Console check box.
32.In the Residual Values area, select the Normalize check box.

hs_1570_monitors_residuals2

33.Accept all of the other default settings and click OK. FLUENT will save the case file now.
34.From the menu bar, click File > Write > Case.
35.In the Case File field, enter elbow.cas.
36.Click OK (accept overwrite). You can now initialize the FLUENT simulation.
37.From the menu bar, click Solve > Initialization.
38.In the Initialization Methods area, click Standard Initialization.
39.From the Compute from list, select inlet.
40.Click Initialize.

hs_1570_inuit

41.From the menu bar, click Solve > Methods.
42.From the Momentum list, select First Order Upwind. You can now perform the baseline simulation.

hs_1570_solutionmethods

43.From the menu bar, click Solve > Run Iterations.
44.In the Number of Iterations field, enter 1000.
45.Click Calculate. The solution converges to ~ 100 - 160 iterations depending on the solver version.  The maximum air velocity is approx 85 m/s.
46.From the menu bar, click Report > Surface Integrals.
47.Click Report Type Area-Weighted Average.
48.Accept the defaults settings in the Field Variable area for Pressure and Static Pressure.
49.For Surfaces, select inlet.
50.Click Compute. FLUENT prints the value (approx.) 408.63 Pa. The same value appears on the last line of file surf-mon-1.out in the current directory.
51.To save the solution, click File > Write > Data from the menu bar.
52.Accept the default file name Elbow.dat and click OK.
53.To save the case file, click File > Write > Case from the menu bar.
54.Accept the default file name Elbow.cas.
55.Clear the Write Binary Files check box.
56.Click OK. You do not want to write a binary case file because you will need to read the case file while doing the Doe and/or Optimization studies.

fluent_case

57.Exit FLUENT. You are now ready to import elbow.cas file into HyperMesh, and create the shape design variables (geometrical changes) that will be used for the Doe and/or Optimization stuidies.

 

hmtoggle_plus1greyStep 3: Load the Model in HyperMesh
1.Optional. If you closed HyperMesh Desktop, reopen it in Engineering Solutions using the CFD, General user profile.
2.From the menu bar, click File > Import > Solver Deck.
3.Set File type to CFD.
4.Set Solver type to Fluent.
5.In the File field, open the elbow.cas file.
6.Click Import.

hs_3040_import

7.In the dialog that appears asking if you would like to overwrite components/node numbers that may already exist in the input file, click Yes. A model appears in the graphics area.

hs_1570_finite_model

8.In the Model browser, Component folder, right-click on fluid and select Isolate Only from the context menu. The graphics area only displays the fluid component.

hs_1570_fluid_component

 

hmtoggle_plus1greyStep 4: Do the Shape Parameterization in HyperMorph
1.In the panel area, click HyperMorph.
2.Click domains. This Domains subpanel opens, from which you can create domains for the shape parameterization.
Note:For this tutorial, you can use the domains that are generated automatically.
3.Go to the create subpanel.
4.Click the first arrow and select 3D domains.
5.Click the toggle and select elems. The entity selector appears.

hs_3040_domain_panel

6.On the Standard Views toolbar, click hm_left_plane_view. The graphics area displays the XZ left plane view of the model.
7.Click elems >> by window.
8.In the graphics area, select all the elements at the 90-degree radius as indicated in the image below. Do not select the elements on the straight sections.

3040_tube

9.Click select entities.
10.Click create. A domain is created.

3040_tube2

11.Click return.
12.In the panel area, click handles.
13.In the graphics area, select the node on the inner radius and the node on the outer radius (both on the symmetry plane, and half way between the already existing handles (yellow).

3040_tube3

14.Click create. Two new handles are created.
15.Click return.
16.In the panel area, click morph. The Morph subpanel opens, from which you can morph the shape of the mesh. The objective of the following steps is to create two design variables that will change the inner and outer radii of the elbow.
17.Go to the set biasing subpanel.
18.In the graphics area, select the two handles created during step 14.
19.In the bias = field, enter 2.000.
20.Click update.
21.Go to the move handles subpanel.
22.Click the second arrow and select translate.
23.Click the second arrow and select along xyz.
24.In the x val= field, enter 0.001.
25.In the z val= field, enter -0.001.

hs_3040_move_handles

26.Select the middle handle on the inner radius as indicated in the image below.

3040_inner_radius

27.Click morph. The first shape is generated.
28.Go to the save shape subpanel.
29.Click the first toggle and select as node perturbations.
30.In the name= field, enter sh1.
31.Click save.
32.Click undo to prepare for the generation of the next shape.
33.Go to the move handles subpanel.
34.Click the second arrow and select along xyz.
35.In the x val= field, enter -0.002.
36.In the z val= field, enter 0.002.
37.In the graphics area, select the middle handle on the outer radius as indicated in the image below.

hs_1570_2_shape

38.Click morph. A second shape is generated.
39.Go to the save shape subpanel.
40.In the name= field, enter sh2.
41.Click save.
42.Click undo to get back to the initial mesh.
43.Click return twice to return to the main menu.

 

hmtoggle_plus1greyStep 5: Export the Shape Parameterization from HyperMesh
1.In the panel area, click shape.
2.Go to the desvar subpanel.
3.Click the arrow and select multiple desvars.
4.Click the shapes selector. A list of shapes appear.

hypermesh_shape_selector

5.Select the shapes sh1 and sh2.
6.Click select.
7.Click create. A shape design variable is created for each selected shape.
8.Optional: If you would like to animate or visualize the shapes, click animate.
9.Optional: In the Deformed panel, click modal or linear to animate the shape variables in the graphics area.
10.Optional: While the shape is animating, you can adjust the animation speed by moving the slider as indicated in the image below.

hs_3070_animate

11.Click return to return to the Shape subpanel.
12.From the menu bar, click View > Browsers > HyperMesh > Utility.
13.In the Utility browser, click CFD I/O.
14.Under Export files for FLUENT, click shapes.

hs_3040_export files for fluent

15.In the dialog that appears, click Yes.
16.In the Open baseline ASCII case file dialog, open the Elbow.cas file. This is the original FLUENT case file that was saved in ASCII format and then imported into HyperMesh before creating the shapes.
17.In the dialog that appears, click OK. The files elbow.shp (Grid perturbation vector data read by elbow.fluent.node.tpl) and elbow.fluent.node.tpl (Grid coordinates template.) are created.

writing_files

18.In the dialog that appears, click OK. The HyperStudy template file, elbow.tpl, for FLUENT is created.

template_file

19.Exit HyperMesh Desktop.

 

hmtoggle_plus1greyStep 6: Register FLUENT as a Solver

In order to use FLUENT as a solver, you need to modify a script to assign the correct information for the location of the FLUENT executable on your machine. To customize the script for your site, copy the hst_fluent.py file from <install_directory>/tutorials/hst/hs-1570/ to your c:/test directory. This file contains two lines, with site-specific information, that you will have to customize according to the software installation on your machine:

strFluent_exe = "C:/Program Files/ANSYS Inc/v140/fluent/ntbin/win64/fluent.exe"

strFluent_arch = "lnx86"

 

hmtoggle_plus1greyStep 7: Perform the Study Setup
1.To start a new study, click File > New from the menu bar, or click files_new_hst2 on the toolbar.
2.In the HyperStudy – Add dialog, enter a study name, select a location for the study, and click OK.
3.Go to the Define models step.
4.Add a Parameterized File model.
a.From the Directory, drag-and-drop the Elbow.tpl file into the work area.
b.In the Solver input file column, enter elbow.cas. This is the name of the solver input file HyperStudy writes during any evaluation.
c.In the Solver execution script column, select Python.
d.In the Solver input arguments column, enter c:/test/hst_python.py” $file.

Optional. If you are running HyperStudy on Linux, you may want to enter -nobg after $file in the Solver input arguments column to ensure that HyperStudy and the Fluent solver work interactively.

5.Click Import Variables. Two input variables are imported from the Elbow.tpl file.
6.Go to the Define Input Variables step.
7.Review the input variable's lower and upper bound ranges.
8.Go to the Specifications step.

This section is for information only, it is not to be used in this tutorial unless you have more than one version of FLUENT installed on your system.

To customize Fluent's run time execution, add a file named Fluent_options.txt to you main HyperStudy directory. A sample file is provided in the tutorial directory <install_directory>/tutorials/hst/Fluent. This sample file contains an assignment line similar to the following:

FLUENT_OPTS = -r6.3.26  3ddp -hidden -i Fluent_batch.jou

The purpose of this assinment line is to select the version of FLUENT to be used (6.3.26 in this case), and to specify the double precision (3ddp) FLUENT executable instead of the default single precision (3d) executable.

Note:When more than one version is installed on your system, you need to specify the version, otherwise FLUENT will abort the batch execution. More details can be found as comments in the sample file.

Typical options for parallel runs are: –tn –cnf=AbsoluteDirPath/hosts.txt, where –tn specifies the number of processors (for example -t4 for a 4-processor job), and the hosts.txt file contains a list of hosts. Do not use spaces in file names. See FLUENT’s documentation for more information on parallel options.

A very important file that must exist in your main HyperStudy directory is the Fluent journal file, Fluent_batch.jou. This file contains the main tasks to be performed by Fluent in each execution sub directory. An example file is provided in your HyperWorks installation, in the hw10.0/tutorials/hst/Fluent. sub directory. Do not change the keywords case_file_prefix  and base_directory_name. These keywords will be replaced at run time. For the nominal run, the number of iterations is not very important because it is assumed that the baseline run converged, but depending on the type of simulation, the actual number of maximum iterations may need to be changed. You can also add other commands to this journal file to meet the needs of new cases, to perform post processing, and to extract any data that you may need. For example, the following is a modified version of the default Fluent_batch.jou file with command lines to modify the residual tolerances of the monitors:

 

file confirm-overwrite no

file rc  case_file_prefix

file rd  "base_directory_name/case_file_prefix"

;This is to change the residual tolerances from the values saved

;in the baseline .cas file

/solve/monitors/residual/monitor  y y y y

/solve/monitors/residual/check-convergence  y y y y

/solve/monitors/residual/convergence-criteria  1.e-4 1.e-3 1.e-3 1.e-3

solve iterate 1000

file write-dat  case_file_prefix

exit

Consult  FLUENT’s Text Command List where all the commands that can be placed in file Fluent_batch.jou are documented.

For advanced users, this file can be changed at any time while HyperStudy is running. This file is copied to the execution directories (for example the m_1 directory) at the time when the simulation in that particular directory is going to start, not when HyperStudy first writes the .cas file to that directory. Also, in any particular execution directory (for example the m_1 directory) you can put a customized version of this file and HyperStudy will NOT overwrite it, and HST/Fluent will use the file that you placed in the execution directory.

 

 

hmtoggle_plus1greyStep 8: Perform the Nominal Run
1.In the work area, set the Mode to Nominal Run.
2.Click Apply.
3.Go to the Evaluate step.
4.Click Evaluate Tasks. The run is executed using FLUENT, and an approach/nom_1/ directory is created inside the study directory, which contains the following files:
elbow.cas (FLUENT input file)
Fluent_run_sh.log (log file of the HyperStudy script execution; read the contents of this file to see if there are any problems)
Fluent_batch_out.txt (output file from FLUENT, which may contain information if there are any licensing or runtime problems).

The approaches/nom_1/run__00001/m_1 directory contains the surf-mon-1.out, which is the result file of the nominal run.

5.Go to the Define Output Responses step.

 

hmtoggle_plus1greyStep 9: Create and Define Output Responses
1.From the Directory, drag-and-drop the surf-mon-1.out file, located in the approaches/nom_1/run__00001/m_1 directory, into the work area.

This is a two column file (iteration result) similar to the lines shown below:

158                408.70844

159                408.41904

Note:The average value of pressure continues to change with the iterations. You may have to reduce the residual tolerances if you want to minimize this change.
2.In the File Assistant dialog, set the Reading technology to Altair® HyperWorks® and click Next.
3.Select Single item in a time series, then click Next.
4.Define the following options, and then click Next.
a.Set Type to unknown.
b.Set Request to Request 1.
c.Set Component to Component 2.
5.Optional. Enter labels for the vector source and output response.
6.Set Expression to First Element.
7.Click Finish. The output response is added to the work area.
8.In the Expression field of the output response, enter v_1[numpts(v_1)-1].

This expression evaluates the second column of the last line of file surf-mon-1.out.

9.Click Evaluate Expressions.

 

hmtoggle_plus1greyStep 10: Run a DOE Study
1.In the Explorer, right-click and select Add Approach from the context menu.
2.In the HyperStudy - Add dialog, select Doe and click OK.
3.Go to the Select Input Variables step.
4.Verify that both input variable's lower, Initial, and upper bound values are -1.0, 0.0, 1.0.
5.Go to the Specifications step.
6.In the work area, set the Mode to Full Factorial.
7.Click the Levels tab, and change the number of levels for both input variables to 3.

hs_3040_levels

8.Click Apply.
9.Review the run matrix by clicking Edit > Run Matrix in the top, right corner of the work area.

hs_1570_run_matrix

10.Go to the Evaluate step.
11.Click Evaluate Tasks to start solving the run matrix.
12.Go to the Post processing step.
13.Click the Summary tab to review a table of the output responses defined from the nine runs. From the table, you can gather that the lowest average inlet pressure occurs for during run nine where sh1 and sh2 = 1.0. This makes sense because the elbow has the maximum cross sectional area. The next two lowest values occur during runs six and right, when one of the shapes has a value 1.0, and the other has a value of 0.0. In relative terms, the pressure drop for runs six and eight are not much larger than run nine.

hs_3040_post_processing

 

hmtoggle_plus1greyStep 11: Post Processing the Results of the DOE Study
1.In the Explorer, right-click and select Add Approach from the context menu.
2.In the HyperStudy - Add dialog, select Fit and click OK.
3.Go to the Select matrices step.
4.Click Add Matrix.
5.In the HyperStudy - Add dialog, add one matrix.
6.In the Matrix Source column, select Doe 1 (doe_1).
7.Click Import Matrix. The matrix from Doe 1 is loaded to the current Fit approach as an input matrix.
8.Go to the Specifications step.
9.In the work area, set the Mode to Least Squares Regression (LSR).
10.In the Settings tab, change the Order to 2.
11.Click the Input Matrix tab to review the input matrix.
12.To create the approximation, you are not going to use run one because the output response value is the highest and much larger than the minimum value in run nine, therefore clear the checkbox for the first run in the Include column. There should be only eight rows included for the Fit approach.

hs_3040_input_matrix

13.Click Apply.
14.Click the Regression Terms tab to review the regression terms for Response 1.

hs_3040_regression_terms

15.Go to the Evaluate step.
16.Click Evaluate Tasks.
17.Go to the Post processing step.
18.Click the Residuals tab to review the residuals of fitting. The absolute maximum percent error is approx 1.27%.
19.Click the Trade-Off 3D tab to review the response surface in a 3D plot.

hs_3040_2d plot

 

hmtoggle_plus1greyStep 12: Do a Simple Optimization Study Using the DOE Study Results
1.In the Explorer, right-click and select Add Approach from the context menu.
2.In the HyperStudy - Add dialog, select Optimization and click OK.
3.Go to the Select Input Variables step.
4.Review the input variable's lower and upper bound ranges.
5.Go to the Select Output Responses step.
6.Click Add Objective.
7.In the HyperStudy - Add dialog, add one objective.
8.Define the objective.
a.Set Type to Minimize.
b.Set Evaluate From to Response1_LSR (r_1_fit_1).
Note: You are instructed to select the Response1_LSR (r_1_fit_1) option rather then the Solver option, due to the fact that it will run much faster. CFD analyses generally take a considerable amount of CPU time. If you use the Solver option, a FLUENT solution will need to be computed for every iteration in the optimization process, which translates to long run times.
9.Click Apply.
10.Go to the Specifications step.
11.In the work area, set the Mode to Adaptive Response Surface Method (ARSM).
Note:Only the methods that are valid for the problem formulation are enabled.
12.In the Settings tab, Relative convergence field, enter 0.1%.

Because this is a very quick optimization based on a Least Square Regression, you are able to reduce the Relative convergence tolerance to the minimum 0.1%.

hs_1570_settingstable

13.Click Apply.
14.Go to the Evaluate step.
15.Click Evaluate Tasks to start the Optimization.
16.Click the Iteration History tab to review the results of the Optimization.

The results indicate that minimizing the approximation leads to an asymptotic minimization of the Response_1 with sh1 and sh2 approaching their maximum values.

Besides any sensitivity of the pressure results to the default Residual tolerance used in your baseline FLUENT simulation, the pressure drop for sh1=sh2=1 was 367.1 Pa, whereas the pressure drops for the cases (sh1=0, sh2=1) and (sh1=1, sh2=0) were not that much larger in relative terms. This explains why the LSR_1 approximation leads to an asymptotic minimization of Response_1 with the values of sh1 and sh2 being close but not equal to the maximum values.  Also, the approximation leads to a minimum pressure that is slightly lower than the actual pressure predicted for the values of sh1 and sh2 close to 1, but this difference is very small in relative terms, and is an effect of the approximation.

The main objective of this simple optimization was to illustrate the steps involved in doing shape optimization based on the results of a DOE study.

 

hmtoggle_plus1greyConcluding Remarks

This tutorial illustrates the main steps required to perform a Doe study, to build an approximation from the DOE results, and to perform a simple shape optimization study using a LSR, saving CPU and turn around time. HyperMesh was used to generate the mesh for FLUENT and the shape variables used to modify the geometry of the fluid flow domain. HyperStudy and FLUENT were used to perform the DOE and optimization studies.  Simple modeling assumptions were used in this tutorial (for example laminar flow), but the steps described here apply to CFD analyses of any complexity and size.

 

 

 

See Also:

HyperStudy Tutorials