Computer Exercise 2 - Strömningsteknik · Lund University / Division of Fluid Mechanics /...

17
Computer Exercise 2 MVK150: Applied CFD Holger Grosshans

Transcript of Computer Exercise 2 - Strömningsteknik · Lund University / Division of Fluid Mechanics /...

Page 1: Computer Exercise 2 - Strömningsteknik · Lund University / Division of Fluid Mechanics / 25.3.2011 To do • Answer the questions marked with (*) • Max 1-2 pages • Each answer

Computer Exercise 2

MVK150: Applied CFD

Holger Grosshans

Page 2: Computer Exercise 2 - Strömningsteknik · Lund University / Division of Fluid Mechanics / 25.3.2011 To do • Answer the questions marked with (*) • Max 1-2 pages • Each answer

Lund University / Division of Fluid Mechanics / 25.3.2011

To do

• Answer the questions marked with (*)

• Max 1-2 pages

• Each answer should be one or two sentences only.

• 1 report per student

• Send your report to

[email protected]

Page 3: Computer Exercise 2 - Strömningsteknik · Lund University / Division of Fluid Mechanics / 25.3.2011 To do • Answer the questions marked with (*) • Max 1-2 pages • Each answer

Lund University / Division of Fluid Mechanics / 25.3.2011

Case structure

Page 4: Computer Exercise 2 - Strömningsteknik · Lund University / Division of Fluid Mechanics / 25.3.2011 To do • Answer the questions marked with (*) • Max 1-2 pages • Each answer

Lund University / Division of Fluid Mechanics / 25.3.2011

Grid independency study

• Create 4 cases from the case ”pipe” and change the number of cells: 10, 20, 40 and 100. (for each block and direction)

• Run these cases (blockMesh + icoFoam)

• (*) Compare the velocity components and pressure at the sample line going trough the bend of the pipe

• (*) Deduce the coarsest independent grid.

• (*) Plot for this case the convergence history.

– IcoFoam > terminal

– Pick ca. 15 values for Ux Initial residual

– Plot (eg. Excel) log(residual) vs. log(timestep)

Page 5: Computer Exercise 2 - Strömningsteknik · Lund University / Division of Fluid Mechanics / 25.3.2011 To do • Answer the questions marked with (*) • Max 1-2 pages • Each answer

Lund University / Division of Fluid Mechanics / 25.3.2011

icoFoam

• Solver application

• Solves the incompressible Navier-Stokes equations

Page 6: Computer Exercise 2 - Strömningsteknik · Lund University / Division of Fluid Mechanics / 25.3.2011 To do • Answer the questions marked with (*) • Max 1-2 pages • Each answer

Lund University / Division of Fluid Mechanics / 25.3.2011

icoFoam

• Uses PISO (pressure-implicit splitting operator) algorithm to solve these equations iteratively :

1. Guess p, flux (from previous time step)

2. Velocity predictor : solve momentum equations to get Ux, Uy, Uz

3. Solve pressure equation

4. Correct flux to satisfy continuity

5. go back to 2. until convergence is reached

Page 7: Computer Exercise 2 - Strömningsteknik · Lund University / Division of Fluid Mechanics / 25.3.2011 To do • Answer the questions marked with (*) • Max 1-2 pages • Each answer

Lund University / Division of Fluid Mechanics / 25.3.2011

icoFoam

• How is it done in OpenFOAM?

• Let's have a look at the source code (only Linux version) :

icoFoam.C

Page 8: Computer Exercise 2 - Strömningsteknik · Lund University / Division of Fluid Mechanics / 25.3.2011 To do • Answer the questions marked with (*) • Max 1-2 pages • Each answer

Lund University / Division of Fluid Mechanics / 25.3.2011

icoFoam

• The time loop starts

• The fvSolution PISO dictionary is read

• The CFL number is evaluated and printed to the screen

• The momentum equations are defined

• The velocity predictor is solved for the PISO loop

Page 9: Computer Exercise 2 - Strömningsteknik · Lund University / Division of Fluid Mechanics / 25.3.2011 To do • Answer the questions marked with (*) • Max 1-2 pages • Each answer

Lund University / Division of Fluid Mechanics / 25.3.2011

icoFoam

• Piso loop:

- The pressure equation is defined

- and solved

- Correct the flux

• Print out the continuity error on the screen

• Evaluate the velocity field

Page 10: Computer Exercise 2 - Strömningsteknik · Lund University / Division of Fluid Mechanics / 25.3.2011 To do • Answer the questions marked with (*) • Max 1-2 pages • Each answer

Lund University / Division of Fluid Mechanics / 25.3.2011

icoFoam

• Print out the execution time on the screen

Page 11: Computer Exercise 2 - Strömningsteknik · Lund University / Division of Fluid Mechanics / 25.3.2011 To do • Answer the questions marked with (*) • Max 1-2 pages • Each answer

Lund University / Division of Fluid Mechanics / 25.3.2011

system/fvScheme

Page 12: Computer Exercise 2 - Strömningsteknik · Lund University / Division of Fluid Mechanics / 25.3.2011 To do • Answer the questions marked with (*) • Max 1-2 pages • Each answer

Lund University / Division of Fluid Mechanics / 25.3.2011

system/fvScheme

• Create a new case from the ”pipe” case.

• Change the schemes to higher order

time terms: second order bounded implicit

gradient terms: fourth order

divergence terms: fourth orderrest: as in original pipe case

• Reference : Numerical schemes in Chapter 4.4 in the User Guide. (...typo...)

Page 13: Computer Exercise 2 - Strömningsteknik · Lund University / Division of Fluid Mechanics / 25.3.2011 To do • Answer the questions marked with (*) • Max 1-2 pages • Each answer

Lund University / Division of Fluid Mechanics / 25.3.2011

system/fvScheme

• Create a new case from the ”pipe” case.

• Change the schemes to lower order

divergence terms: first order

laplacian terms: first orderrest: as in original pipe case

• (*) Compare the execution time for each case. ( icoFoam > terminal )

• (*) Compare the results.

Page 14: Computer Exercise 2 - Strömningsteknik · Lund University / Division of Fluid Mechanics / 25.3.2011 To do • Answer the questions marked with (*) • Max 1-2 pages • Each answer

Lund University / Division of Fluid Mechanics / 25.3.2011

system/fvSolution

• Linear-solver to solve the system of discretized equations

• Solver stops at current residual

• Solver stops at ratio of current to initial residual

• Controlling PISO algorithm

Page 15: Computer Exercise 2 - Strömningsteknik · Lund University / Division of Fluid Mechanics / 25.3.2011 To do • Answer the questions marked with (*) • Max 1-2 pages • Each answer

Lund University / Division of Fluid Mechanics / 25.3.2011

system/fvSolution

• Create 2 new cases from the ”pipe” case :

– Put tolerance values to 1e-3

– Put tolerance values to 1e-9

• (*) Discuss the sensitivity of the results:

- probe point (4.5 3 0.05), how can the difference be explained ?

- number of iterations per time step

Page 16: Computer Exercise 2 - Strömningsteknik · Lund University / Division of Fluid Mechanics / 25.3.2011 To do • Answer the questions marked with (*) • Max 1-2 pages • Each answer

Lund University / Division of Fluid Mechanics / 25.3.2011

system/controlDict

• Create one new case from the ”pipe” case

• Change the inlet velocity to 20 m/s

and the viscosity to 0.001 m^2/s

• (*) If your case diverges... which parameter would you change to obtain convergence?

• Simulate 1 s and look how the velocity field evolves.

Page 17: Computer Exercise 2 - Strömningsteknik · Lund University / Division of Fluid Mechanics / 25.3.2011 To do • Answer the questions marked with (*) • Max 1-2 pages • Each answer

Lund University / Division of Fluid Mechanics / 25.3.2011

system/controlDict

• Initial time

• Final time

• Time step

CFL = u dt / dx

• How often the results are printed into the time directory.