FLUENT Training Seminar
Christopher Katinas
July 21st, 2017
Motivation
• We want to know how to solve interesting
problems without the need to build our own code
from scratch
– GEMS has ~35 engineer-years to develop to date
• ANSYS Workbench is the overall package used to
perform meshing, obtain a solution, and post-
process results
• FLUENT is a commercially-available software
package commonly used for a plethora of fluid
dynamics and heat transfer systems
Before we get started….
• FLUENT only does two things:
– 1) Solves exactly what you tell it to solve
– 2) Nothing more
• Ask yourself what you would need to solve this
problem by hand
– Material properties
– Boundary conditions
– Duration of phenomena
– Sources of conserved quantities
• USE ENGINEERING INTUITION!
Problem Solving Methodology
• Assess what you are trying to model
• Create mesh for the domain with appropriate
domain boundaries
• Define governing equations and FLUENT models
which will be needed
• Define material properties
• Define boundary conditions
• Set solution method and under-relaxation factors
– Ensure numerical stability
• Select time stepping method
• Post-process results
Training Example
• Laser heating of a block with Gaussian beam
profile – without melting
• Can be analytic if constant material properties
– Jaeger solution to laser heating
– Seldom the case for non-isothermal systems
• This example shows the basics of what is needed
to setup and solve a more complex problem
– FLUENT cannot handle laser irradiation profiles natively
– BUT, we can still solve that!
• We can add additional physics, if desired
Heating Block of AISI 1018
Laser z
• Part Geometry
Beam – 86.36 mm x 171.45mm x 6.35mm
x
Scanning • Beam Diameter
Direction
– Gaussian, 5250μm Radius,146.8W
AISI 1018 Substrate
• Scanning Velocity
– 3mm/s
y • Absorptivity (α=0.35)
Scanning x • Density (ρ=7870 kg/m3)
Direction
• Thermal Conductivity
AISI 1018 Substrate k=46.8+4.4959e-2*T – 1.081e-4T2+4.757e-8T3
• Specific Heat
cp=481.65-0.2198*T + 6.710e-4T2-1.1734e-7T3
Heating Block of AISI 1018
• Assume all surfaces are insulated except the top
surface being irradiated
• Assume convection and radiation from the top
surface are negligible
• We want to know the maximum temperature of
the top surface during the laser scan.
• What does intuition say about where the
maximum temperature will be found?
ANSYS Workbench
Build your project here via
drag-and-drop interface!
Model Types
ANSYS Workbench
Drag Fluid Flow
(FLUENT) to
Workspace
ANSYS Workbench
At this point, save your project to a safe location. ANSYS does have a tendency to crash on
large or complex models.
ANSYS Workbench
Defining the Geometry
Double-click Geometry
Creating the Geometry
Remember the units you are building your geometry in!
This will be VERY important when we begin using
FLUENT.
Click OK!
This acts like any CAD software!
Adding a Brick of a Given Dimension
Input origin (X,Y,Z) and diagonal point coordinates to define a brick,
then click Generate to display the geometry
Adding a Brick of a Given Dimension
BAM! Geometry is Created
Certainly this process is substantially more difficult for more
complex components. In such a case, import a geometry file.
What Are We Trying to Solve
• We must know the physical basis of the system we are
attempting to simulate numerically.
• Which conservation principles are relevant?
– Conservation of Mass
– Conservation of Momentum Laser heating without
melting doesn’t require
– Conservation of Energy any conservation laws
beyond conservation of
– Conservation of Entropy energy!
– Conservation of Charge
• Can ANSYS even solve them?
– If an equation can be put into conservative form, the
numerical solver CAN solve it
𝜕𝜕(𝜌𝜌𝑋𝑋)
+ 𝛻𝛻 ∙ 𝜌𝜌𝜌𝜌𝜌𝜌 = 𝛻𝛻 ∙ 𝜇𝜇𝜇𝜇𝜇𝜇 + 𝑆𝑆
𝜕𝜕𝑡𝑡
– Whether it will or not depends on your model inputs
Meshing (Domain Discretization)
• Complex systems are approximated numerically to
obtain a solution
– Governing equations rarely have analytic solutions except in
very simple cases
• Too coarse of a mesh cannot provide granularity in the
numerical solution
• Too fine of a mesh requires a REALLY long time.
• General rules of thumb:
– Finer mesh in areas where you are interested in the result
and in locations adjacent to areas of high gradients of
quantities you are interested in
– Coarser mesh in remaining areas
– Transitional mesh to link coarse and fine mesh areas
together
Meshing
Double-click Mesh
Meshing
How small of a mesh should we use?
Laser beam diameter = 5250 μm (50 μm seems reasonable)
Meshing Calculation
• How many computational volumes does this lead to?
– 86.36 mm 1727 cells
– 171.45 mm 3429 cells
– 6.35 mm 127 cells
• Total control volumes = 7.521e8
– 4e5 control volumes takes O(1 second) per iteration
– 7.5e8 control volumes takes O(1.5 months) per iteration
– (P.S. GOOD LUCK!)
• Lets use fine mesh in the vicinity of laser irradiation
and coarser mesh everywhere else
– ~200 μm mesh is fine mesh size
Mesh Sizing
Right click on Mesh > Insert > Sizing
This will impose a sizing condition on the geometry you select
Select the four edges parallel to the z-axis at first
Modifying the Selection Type
Use the right mouse button within the view window and
select Cursor Mode to distinguish the geometry you need
Z-Direction Meshing
Within the “Details of Edge Sizing Dialog”
Select Type as Number of Divisions, with 10 divisions
Behavior should be “hard” if you do not want cell sizes to change during
meshing. Bias type should be “No Bias” (i.e. Uniform Spacing)
X-Direction Meshing
Select Type as Number of Divisions, with 400 divisions
Behavior should be “hard” if you do not want cell sizes to change during
meshing. Bias type should be “No Bias” (i.e. Uniform Spacing)
Y-Direction Meshing
Select Type as Number of Divisions, with 200 divisions
Set behavior to “hard” .
Bias type should be “--- -- - -- ---” (i.e. Concentrated at Center) with a
bias factor of 5.0. Now click “Generate Mesh”. It may take a while!
Checking Overall Mesh
Click “Mesh” with the Outline, and the mesh will be visible.
The number of cells can be found by scrolling down in the Details of
Mesh to view the Mesh Statistics.
We have 800,000 cells! This is a VERY large model for heat transfer.
Modifying the Mesh
Change the number of intervals as follows and “Generate Mesh”:
X-direction: 200 intervals
Y-direction: 150 intervals, biasing 6.0
Z-direction: 10 intervals
Define the Boundary Faces
Create a unique “Named Selection” for each type of boundary.
We need two Named Selections:
Irradiated boundary at the +Z-plane
Insulated boundary at the remaining faces
Save and Close the Mesh
Alternatively, if you close the mesh, you can save the project from the
Workbench interface. Generally, its safer to save the project, then close.
Update the Project
This is necessary prior to entering the Setup section! You want to
ensure the latest version of the mesh is being utilized for subsequent
steps.
FLUENT Setup
Double-click Setup
FLUENT Launcher
Dimensionality of the model will automatically be
selected
Parallelization can be performed to speed up calculation
(typically only on large domains)
Double precision allows for less computer-based round-
off error, slower calculation but more accurate
Much slower with MPI since
more data must be passed
between processors
If you can use single precision,
it is highly recommended
Double precision also requires
twice the memory of single
precision calculations.
FLUENT Startup
Navigation Task Page Graphics Window
Menu
Command Window
FLUENT may take a while to load, especially if parallel processing is used
Upon loading, you should see your mesh within the Graphics Window.
General Model Setup
Select Transient-based model We need to simulate laser scanning
Pressure-based model is ideal for most systems
If gravity needs to be considered, select the “Gravity” checkbox and
specify the direction of the gravitational force.
General Model Setup
Select the Scale… push button
Verify the scale of the model to ensure consistent units based on the
geometry created earlier.
If consistent units are evident, click Close, otherwise scale the geometry.
Models Setup
This is where the types of models that are needed for the analysis are
selected. In many cases, changes to the type of models being used will
affect the material properties.
We need the Energy equation active, so let’s turn on the Energy model.
Select Energy > Edit… > Check Energy Equation
Click OK
Do we need any other types of models?
Materials Input
By default, a fluid and solid are automatically included in the model.
If the material is not being used, it doesn’t affect the results.
We are not using aluminum, but rather 1018 Steel.
Click “aluminum” under the Solid material and then “Create/Edit…”
Materials Input
Change the Material Name to “steel1018” and the Chemical Formula to “steel”.
Modify the density to 7870
Change the specific heat dropdown from “constant” to “polynomial”
A polynomial profile window will open
Change coefficients to 4 since we have a third order polynomial
Enter coefficients from low power to T to highest power of T
cp=481.65-0.2198*T + 6.710e-4T2-1.1734e-7T3
Materials Input
Change the thermal conductivity dropdown from “constant” to “polynomial”
A polynomial profile window will open
Change coefficients to 4 since we have a third order polynomial
Enter coefficients from low power to T to highest power of T
k=46.8+4.4959e-2*T – 1.081e-4T2+4.757e-8T3
Click “Change/Create” button and overwrite the aluminum default material
Cell Zone Conditions
Ensure that the material being used within the domain is the newly created
steel material.
Other inputs for this problem are not necessary, but if you are dealing with
rotating equipment or a problem with moving mesh, remaining options within
this dialog may be important.
In the event heat addition occurs within the domain (electric heating, for
example) include it as a source term by checking the source term box and
filling the Source Terms tab inputs.
Boundary Conditions
The Named Selections created earlier were the boundary faces for the domain.
We grouped them so that the +z plane (a wall) was the irradiated surface and
remaining faces (also walls) were insulated surfaces.
A third boundary condition is shown but only represents faces internal to the
domain. NEVER show the mesh for this boundary zone, EVER!
Select “insulated_boundary” and click “Edit…”
By default, FLUENT makes wall boundary conditions zero flux!
Do we need to change anything for an insulated boundary?
Boundary Conditions
Now, select “irradiated_boundary” and click “Edit…”
Look through the Heat Flux types and there are no others than “constant”.
There are no default options for the method of heating we are interested in.
We need to make our own heat flux boundary type via a User Defined Function
UDFs are written in C code and can be one of two types:
Compiled or Interpreted C-code (compiled is faster)
User-Defined Function
• Allows override of boundary conditions, source
terms and/or material properties during the
solution.
• We will use an interpreted UDF for this example
• No need to run a compiler beforehand
– FLUENT will compile the code for us at a price of
computation time
• UDF’s will slow down FLUENT analysis regardless
since they require computation time to calculate
the functions.
User-Defined Function
#include "udf.h"
#define PI 3.1415926 //Pi, a constant
#define sigma_q 0.35 //Absorptivity
#define P 146.8 //Laser power
#define R 5.250e-3 //Radius of laser beam
#define v 3.000e-3 //Scanning velocity
DEFINE_PROFILE(heat_flux,thread,position) //The UDF profile will have the name “heat_flux”
{
face_t f; //Define face variable
double x[ND_ND],r,time,vol; //Define face centroid vector, distance, time, and exponential for laser
double tempp,conv,emiss; //Define temperature, convection and emission energy
time=RP_Get_Real("flow-time"); //Acquire time from FLUENT solver
begin_f_loop(f,thread) //Loop through all relevant boundary faces
{
tempp=F_T(f,thread); //Get the temperature of the face
F_CENTROID(x,f,thread); //Acquire the face centroid location
r=sqrt(pow((x[0]+R-v*time),2.0)+pow(x[1]-0.085725,2.0)); //Determine distance from beam center
conv=0.0*17.0*(tempp-299.4); //Calculate convective losses
emiss=0.0*5.67e-8*(pow(tempp,4.0)-pow(299.0,4.0)); //Calculate radiation losses
if (conv<0.0) {conv=0.0;} //Prevent convection if surface is colder than surroundings
if (emiss<0.0) {emiss=0.0;} //Prevent radiation if surface is colder than surroundings
//calculate the intensity with convective and radiation losses in the next two lines
vol=2.0*r*r/(R*R);
F_PROFILE(f,thread,position)=(2.0*P*sigma_q*exp(-vol)/(PI*R*R)-conv-emiss); //Set face flux
end_f_loop(f,thread)
}
}
Interpreting a User-Defined Function
By going through Define > User-Defined > Functions > Interpreted…
Select the C-code file which has the previously shown UDF
Click “Interpret”. If an error occurs, there is likely an error with the UDF
C-code, and it will need to be revised and saved. Then repeat the steps.
UDF Build Successful
If the UDF build was successful, the command window will have text printing
similar to this in nature.
In this case, 7 parallel processes are being used, hence a total of 7 compilation
lines (cpp). Be patient when doing the compilation, as larger functions will
require additional compilation time.
Once the UDF has been compiled, additional options will be available based on
the type of function you built inside the C code.
Irradiation Boundary Condition
We now have a new option for the heat flux based on the UDF we compiled!
Once the UDF profile has been selected, the input box for the heat flux value
will disappear.
Troubleshooting UDFs are difficult to do during simulation, thus it is highly
recommended to test the functions offline to ensure you acquire the expected
function output.
Solution Methods (Numerics)
When flow is active, a pressure-velocity
coupling is required if a pressure-based
solver is being used.
Options are SIMPLE, SIMPLEC, PISO, and
Coupled.
Only use coupled when you have very
large time steps or when mesh quality is
poor. SIMPLE is the most common
choice of solver.
Spatial discretization describes order of
accuracy of derivatives at cell faces and
how the derivatives are acquired
numerically.
Generally, the default values for these
will suffice, as higher order accuracy will
increase computation time.
Solution Controls Dialog
Unhighlight “Flow”
Only the highlighted equations will be solved.
By default, all equations are solved based on the models selected previously.
Do we need flow equations for this simulation? Why/why not?
Under Relaxation Factors (URF):
Pressure and Momentum URFs MUST sum to 1.00
Flow stability is best with smaller pressure URF (0.03 is not uncommon)
Temperature URF must be less than or equal to 1, typically 1 works fine
Tnew=α*Tsol+(1-α)*Told
Monitors
Monitors show various quantities during the simulation process and can be
residuals or other calculated parameters (max/min cell values, average
temperature, etc.).
Parameters can be plotted, written to the screen, or to a predefined file.
Typical residual thresholds are as follows:
Continuity, Momentum, Turbulence 1e-6
Energy 1e-12
Turbulence 1e-6
Monitors
Let’s create a monitor to track the maximum temperature at the surface being
irradiated.
Create a “Surface Monitor”
Select Facet Maximum of Static Temperature
“irradiated boundary” should be the only surface selected
We will also plot the surface monitor to a new plot window (Window 2) after
each iteration.
Solution Initialization
Prior to starting any simulation using
numerical methods, an initial condition
of the solution must be made.
For steady-state simulation, the initial
condition is a guess of the converged
steady-state solution.
In transient simulations, the initial
condition provides the temporal starting
point for the simulation, and results will
likely be affected by the initial condition.
For the case of the substrate being
heated, the plate is initially at 299 K,
which is room temperature. Once the
initial condition is described, click the
“Initialize” button.
Saving Data Periodically
We may want to look at the temperature field during transient simulation, thus
we need to export the solution at the wall.
Create an Automatic Export and export the Static Temperature at boundaries.
Select the frequency to 100 time steps to a file named Wall_T.
Time Stepping
FLUENT uses a dual-timestepping
method for time advancement.
Each physical time step consists of
iterations:
1) Until specified number of iterations
2) Residuals for equations decreases
below threshold (1e-12 for energy)
The iterations allow the solver to
converge within a timestep before
continuing to the next timestep.
But we need to know how big of a time
step to use and how many time steps
and iterations (pseudo-timesteps) to
use.
How Small of a Time Step Should We Use?
• The time step should be sufficiently small to guarantee
the physics can be captured from a numerical
perspective.
• Typically, source displacement should be less than one
tenth of a computational volume. Larger time steps
can be taken, with increased numerical error
– Mesh size: 86.36mm/200 cells = 0.432 mm/cell
– Laser Scanning Speed : 3 mm/s
1 𝑠𝑠 𝑚𝑚𝑚𝑚
∆𝑡𝑡 = ∗ 0.432 ∗ 0.1 𝑐𝑐𝑐𝑐𝑐𝑐𝑐𝑐 = 0.0144 𝑠𝑠
3 𝑚𝑚𝑚𝑚 𝑐𝑐𝑐𝑐𝑐𝑐𝑐𝑐
• At least 1999 physical time steps will be required to
solve the domain, assuming we need to traverse the
entire width of the block.
Time Stepping
We calculated the necessary time step
for this domain and the number of
physical time steps required.
Number of time steps are the physical
time steps for the solution
It is generally a good idea to have a large
number of maximum iterations per time
step, though if the physics are simple
and coupling between equations is
small, a lower number can be used.
Set the reporting interval to the max
iterations (one reporting update per
time step).
Profile update interval should be
changed each pseudo timestep.
Running the Model
Press calculate to start acquiring the
numerical solution.
When the solution is being obtained,
lines within the command area will
show values of the residuals for each
equation and anything else you
requested to have printed.
The graphics window will have various
pages to show a monitor of the residuals
graphically and, in our case, the monitor
for the maximum face temperature of
the irradiated surface.
We actually want to simulate this for
2300 time steps
Monitoring Model Progress
In general, residuals in transient simulations will start at an elevated level at
the start of a physical time step and then decay.
We want to ensure the residual does not change substantially prior to
advancing to the next time step. If this occurs, the last iteration may not
properly describe the solution at the prior time step, yielding inaccurate results
Maximum Surface Temperature
The monitor we set up previously shows us the maximum temperature of the
domain. Similarly, the value will be shown in the command window (391.4K).
Post-Processing of the Data
• Before doing anything else, SAVE your project!
– This can be done directly from FLUENT
• Once the simulation has completed running, we
need to visualize the results
• Post-processing within ANSYS is rather limited,
thus Tecplot is used (hence why we exported
Tecplot data for the transient save points).
• Tecplot 2015 will be used to show how to create a
movie from single data frames
• You should have 23 files named Wall_T-XXXX.dat
Open Tecplot and Load the Data Files
Click Load Data File(s)… within Tecplot
Loading of the Data Files
Data files will be located in the ANSYS project directory/dp0/FFF/Fluent
Select all of the files starting with Wall_T then click “Open”
Make sure files are sorted numerically in increasing order from top to bottom!
Tecplot Contour Plots
The data will take a while to load, but once it is completed, you should see this.
The gray rectangle denotes the shaded domain.
Uncheck “Shade” and check the “Contour” box.
Tecplot Contour Plots
Now we see a contour plot, but what time is this plot for. ALL OF THEM. We
need to tell Tecplot to separate the files out since the data was transient.
Tecplot Transient Contour Plot
Data > Edit Time Strands… needs to be used to accomplish this
Tecplot Transient Contour Plot
Select all of the zones in the left hand side of the dialog box
Check “Multiple Zones Per Time Step” since each time step has the insulated
and irradiated boundary
Enter two zones per group
Selected “Constant delta” (our time steps were uniform)
Delta is 1.44 seconds since 100 time steps per file @0.0144 s /step was used
Click “Apply”, then “Close”
Tecplot Transient Contour Plot
You will see the play bar active now! The data can be viewed transiently.
Tecplot Transient Contour Plot
If we want to take a look at the domain in three dimensions, change the plot
type from 2D-Cartesian to 3D-Cartesian
View 3D Domain
A rather thick domain is shown. We should know something is not correct.
The domain thickness should be less than 1/10th the width. When Tecplot has
domains of high aspect ratio, it automatically adjusts it.
View 3D Domain
We can adjust it back using Plot > Axis…
Domain Aspect Ratio
By changing XY dependent to XYZ dependent and setting the X to Z ratio to 1…
View 3D Domain
We get a more realistic looking representation of our geometry.
Labels are an important aspect of visualization, so we should annotate the
display window.
Automatic Text
Add Time=&(SOLUTIONTIME) seconds as a text box on the display window
Similarly, add a second text box with :
Max Temperature = &(MAXVAR[4]%4.1f) K
Finding the Maximum Temperature
Scroll through the solution time to find the maximum temperature at the
surface (390.2 K).
Why is the maximum temperature at the edge of the domain? Use intuition.
Creating a Video
Create a movie file by clicking Animate > Time…
Create a Video
Change the destination “To File”.
When you click “Animate to File…”, The Export window shows up.
Select AVI and set the animation to 4 frames/second.
When “OK” is clicked, select where to save the video file.
The Finished Video
Learning Objectives Accomplished
• Learned the basics of the ANSYS interface
• Created a simple geometry using the interface
• Meshed the geometry with a variety of edge seeds
• Learned the FLUENT interface and how to setup a
simple heat transfer problem to solve a traversing
laser beam problem
• Post-processed the data into a meaningful format
Resources
• All dialog boxes have a “Help” button. If you don’t
know what FLUENT is doing…USE IT!!!
• FLUENT Theory Guide (describes the physics of
each input)
• FLUENT UDF Manual – for user-defined functions
• CFD forums- https://www.cfd-online.com/Forums/
• Google.com
A Twist
• Now that we have set up a simple heating model with a Gaussian beam,
what changes would we need to make to the model to allow for melting?
• First, what changes in the physics exists?
– Tsolidus for 1018 Steel is ~1588K
– Tliquidus for 1018 Steel is ~1723K
– Heat of Fusion 2.65e5 J/kg
• With the given conditions for laser irradiation, will there be any effect?
Why/why not?
• Maximum temperature was 390K, therefore no melting will be observed. If
the laser were more concentrated, then melting may be required.
• Thermal properties would need to be expanded to higher temperatures
– Validity of property correlations may not be valid at melting
• Block can not longer be considered a solid, since it could flow
– Change Cell Zone type to “Fluid”
• Marangoni stress would need to be included (a significant driving force)
Modifying Plate Dimensions
• What if we wanted to change the thickness of the
plate from 6.35mm to 1.00mm?
– If you already have the mesh created from the thicker
domain, DON’T rebuild it
– Use scaling of the mesh
• Click “Specify Scaling Factors”
• Set z-scale to 0.1574803 (1mm/6.35mm) and click “Scale”