UMassAmherst First Dutch OpenFOAM Day Nov 4th, 2010 Implementation of the OrientedEddy Collision Turbulence Model in OpenFoam Blair Perot Mike Martell Chris Zusi Department of Mechanical and Industrial Engineering Mechanical and Industrial Engineering Theoretical & Computational Fluid Dynamics Laboratory UMassAmherst Goal: Develop a New Turbulence Model Navy Requirements Easy for others to test. Easy for others to adopt. Easy to test real world applications. Our Requirements Solve coupled tensor PDE’s. Mixed BCs. Handle arbitrary numbers of equations. Mechanical and Industrial Engineering Theoretical & Computational Fluid Dynamics Laboratory 2 UMassAmherst Why OpenFoam? Advantages over commercial code • Free, open source, parallel • Users can inspect, alter, expand on the source code. Advantages over in house code development • Many numerical methods, operators, utilities already implemented and tested Large, user-driven support community • Interact with other OpenFOAM users. • Get help from CFD experts. Mechanical and Industrial Engineering Theoretical & Computational Fluid Dynamics Laboratory 3 UMassAmherst Why OpenFoam? Advantages over commercial code • Free, open source, parallel • Users can inspect, alter, expand on the source code. Advantages over in house code development • Many numerical methods, operators, utilities already implemented and tested Large, user-driven support community • Interact with other OpenFOAM users. • Get help from CFD experts. Mechanical and Industrial Engineering Theoretical & Computational Fluid Dynamics Laboratory 4 UMassAmherst Why OpenFoam? Advantages over commercial code • Free, open source, parallel • Users can inspect, alter, expand on the source code. Advantages over in house code development • Many numerical methods, operators, utilities already implemented and tested Large, user-driven support community • Interact with other OpenFOAM users. • Get help from CFD experts. Mechanical and Industrial Engineering Theoretical & Computational Fluid Dynamics Laboratory 5 UMassAmherst Prior Experience: In House Codes UNS3D: Moving unstructured staggered mesh code for two-phase incompressible flows Stag++: Cartesian staggered mesh for DNS/LES of incompressible turbulence. Fluent User defined subroutines for RANS modeling. OpenFoam Wind turbine blade simulation. Rotating imbedded mesh. Mechanical and Industrial Engineering Theoretical & Computational Fluid Dynamics Laboratory 6 UMassAmherst Wind Turbine Calculations with OpenFoam Spin indicator = second invariant of the strain tensor Runs on 8-16 CPUs No major issues Mechanical and Industrial Engineering Theoretical & Computational Fluid Dynamics Laboratory 7 UMassAmherst Eddy Collision Model Overview Assumption: Turbulent Flow = Flow of a Colloidal suspension of disk-like spinning objects. Pouring Spherical objects results in RANS eqns. Pouring a concentrated Disk suspension results in OEC model Mechanical and Industrial Engineering 8 Theoretical & Computational Fluid Dynamics Laboratory UMassAmherst Review of OEC Model Properties Cost roughly about 10x k/e. Four model constants. Realizable, Material Frame Indifferent, Galilean Invariant, Exact in linear limit, etc. LES Log(Cost ) 100 OEC 10 1 RANS 0.1 0.1 1 10 100 Log(Physics ) Mechanical and Industrial Engineering Theoretical & Computational Fluid Dynamics Laboratory 9 UMassAmherst PDE Formulation Dqi qk uk ,i 1 q 2 1 qi ( Ai Bi ) 1 ( t )qi ,k ,k Wi 3 R 3 Dt Eddy Size and Orientation (vector) q q qq ui ,k i 2 l il 2ul*,k Rkj u j ,k j 2 l jl 2ul*,k Rki q 2 1 Rij R Dt q q ( K ), k ( K ), k Rij Aij M ij t Rij ,k ,k D t ( K ),k E t Rij Wij K K K ,k DRij Eddy Velocity Fluctuation (tensor) • Global Variables (sum many eddies – 20-50) Rij N1 Rij T Mechanical and Industrial Engineering Theoretical & Computational Fluid Dynamics Laboratory 1 2 Rii / Rii q 2 2 10 UMassAmherst Open Foam Formulation Dqi qk uk ,i 1 q 2 1 qi ( Ai Bi ) 1 ( t )qi ,k ,k Wi 3 R 3 Dt fvm::ddt(qiINT) - (1.0/3.0)*fvm::laplacian(dEff(), qiINT) + (1.0/3.0)*fvm::SuSp(((alpha*nu()*qsq + tauR)), qiINT) == - fvc::div(phi_, qiINT) - ( qiINT & fvc::grad(U) ) - ( Ai + Bi ) Implicit terms on the left-hand side. Explicit terms on the right-hand side. Mechanical and Industrial Engineering Theoretical & Computational Fluid Dynamics Laboratory 11 UMassAmherst First Challenge: Multiple Eddies The Number of Eddies for each physical location is arbitrary. 10 is minimal necessary. 100 is usually very good. 6 23 37 1 49 55 102 108 2 998 256 16 Pointer lists are employed to keep track of eddies Rij_[eddy][cell].xx() Pointer list with an entry for every eddy Mechanical and Industrial Engineering Theoretical & Computational Fluid Dynamics Laboratory Location in mesh 9 Component (11 in this case) 12 UMassAmherst Multiple Eddies: OpenFoam Solution forAll(initOrientations_,i) { ... solveqR(i, qi_[i], ...); ... } This system allows us to write generalized functions which handle any number of eddy vectors. void OEC::solveqR(int i, volVectorField qiINT, ...) { ... tmp<fvVectorMatrix> qEqn The model can be implemented on ( a per-eddy basis. fvm::ddt(qiINT) = ... Averaging all of the entities in a ); ... given pointer list is also easy, which solve(qEqn, mesh_.solver("q")); is good because all we really care ... about is the average R, K, etc. } Mechanical and Industrial Engineering Theoretical & Computational Fluid Dynamics Laboratory 13 UMassAmherst Second Challenge: Tensors No gradient of a rank 2 (and higher) tensor Rij D t ( K ),k K ,k Solution: Break it into vectors forAll (mesh_.C(), { Rx[cell].x() Rx[cell].y() Rx[cell].z() … fvc::grad(R) … cell) // internal cells = Rtmp[cell].xx(); = Rtmp[cell].xy(); = Rtmp[cell].xz(); ... gradKgradR[cell].xx() = ( + + gradKgradR[cell].yy() = ( + + gradKgradR[cell].zz() = ( + + Mechanical and Industrial Engineering Theoretical & Computational Fluid Dynamics Laboratory gradK[cell].x()*gradRx[cell].xx() gradK[cell].y()*gradRx[cell].xy() gradK[cell].z()*gradRx[cell].xz() ); gradK[cell].x()*gradRy[cell].yx() gradK[cell].y()*gradRy[cell].yy() gradK[cell].z()*gradRy[cell].yz() ); gradK[cell].x()*gradRz[cell].zx() gradK[cell].y()*gradRz[cell].zy() gradK[cell].z()*gradRz[cell].zz() ); 14 UMassAmherst Third Challenge: Boundary Conditions On wall, the boundary conditions are mixed. 108 Y 23 1 6 49 wall This is for an xz-wall. We currently can not do walls that are not aligned with the tensor coordinate directions. Mechanical and Industrial Engineering Theoretical & Computational Fluid Dynamics Laboratory Rij slip wall qi wall R13 R11 0 R 0 12 y y R22 0 R23 0 R 33 y q1 0 q 2 0 y q 0 3 15 UMassAmherst Last Challenge: Stable Time Marching Many source terms have no fvm:: (implicit) implementation. Some explicit source terms can be unstable with Explicit Euler time advancement. Solution: • Write a RK3 solver. • Modify equations with explicit time derivative • Use FOAM’s .storeOldTime() to save the old time values. Mechanical and Industrial Engineering Theoretical & Computational Fluid Dynamics Laboratory 16 UMassAmherst Last Challenge: Stable Time Marching Many source terms have no fvm:: (implicit) implementation. Some explicit source terms can be unstable with Explicit Euler time advancement. Solution: • Write a RK3 solver. • Modify equations with explicit time derivative • Use FOAM’s .storeOldTime() to save the old time values. Mechanical and Industrial Engineering Theoretical & Computational Fluid Dynamics Laboratory 17 UMassAmherst Last Observation: Gradient of a vector ax1 ai , j a1 1 x2 a1,1 a2 a1,2 x2 a2 x1 Mechanical and Industrial Engineering Theoretical & Computational Fluid Dynamics Laboratory a2,1 g11 a2,2 g 21 g12 i a j g22 18 UMassAmherst Summary: OEC is implemented in OpenFoam. Mechanical and Industrial Engineering Theoretical & Computational Fluid Dynamics Laboratory 19