customization of les turbulence model in openfoam

Click here to load reader

Post on 28-Jul-2015

173 views

Category:

Engineering

28 download

Embed Size (px)

TRANSCRIPT

1. Customiza*onofLESturbulencemodel inOpenFOAM yotakagi77 OpenCAELocalUserGroupsinJapan @Kansai June13,2015,OsakaUniversity 2. Agenda Basicinforma*ononturbulencemodel Tensormathema*cs Exercise1:Compilingandexecu*onofWALE model Exercise2:Implementa*onofcoherent structureSmagoriskymodel Addi*onalworks 3. Basicinforma*ononturbulencemodel 4. Turbulentowsimula*on DNSLESRANS ModelingNoSubgridscaleReynoldsaverage Accuracy Cost Vortex(eddy)eldReynoldsaverage4 5. Turbulentowsimula*on DNSLESRANS ModelingNoSubgridscaleReynoldsaverage Accuracy Cost DNSgrid,uReynoldsaverage5 6. Turbulentowsimula*on DNSLESRANS ModelingNoSubgridscaleReynoldsaverage Accuracy Cost LESgrid,u=uuReynoldsaverage6 7. Turbulentowsimula*on DNSLESRANS ModelingNoSubgridscaleReynoldsaverage Accuracy Cost FilteringapproachReynoldsaverage7 8. Detached-eddysimula*on(DES) P.R.Spalart(1997): WenamethenewapproachDetached-Eddy Simula8on(DES)toemphasizeitsdis8ncttreatmentsof a?achedandseparatedregions. Super-RegionRegion Euler(ER) RANS(RR)Viscous(VR) Outer(OR) LES(LR)Viscous(VR) Focus(FR) Departure(DR) 8 Spalart(2001) 9. Detached-eddysimula*on(DES) P.R.Spalart(1997): WenamethenewapproachDetached-Eddy Simula8on(DES)toemphasizeitsdis8ncttreatmentsof a?achedandseparatedregions. Super-RegionRegion Euler(ER) RANS(RR)Viscous(VR) Outer(OR) LES(LR)Viscous(VR) Focus(FR) Departure(DR) Spalart(2001) 9 10. Couplingwithmomentumequa*on throughviscosity RANS LES U t + UU( ) + t( ) U + (U)T ( )( )= p U t + UU( ) + SGS( ) U + (U)T ( )( )= p Turbulent viscosity Sub-grid scale viscosity Onlychangeviscosity! 10 11. Signicantproblem: dierenceofltering(average)approaches LESFilteringReynoldsaverage Spa*alTemporal InconsistencyattheinterfacebetweenLESandRANSregions 11 12. StandardSGSmodelinOpenFOAM LibrarynameNote SmagorinksySmagorinskymodel Smagorinksy2Smagorinskymodelwith3-Dlter homogeneousDynSmagor insky HomogeneousdynamicSmagorinskymodel dynLagragianLagrangiantwoequa*oneddy-viscositymodel scaleSimilarityScalesimilaritymodel mixedSmagorinskyMixedSmagorinsky/scalesimilaritymodel homogeneousDynOneEqE ddy OneEqua*onEddyViscosityModelforincompressible ows laminarSimplyreturnslaminarproper*es kOmegaSSTSASk-SSTscaleadap*vesimula*on(SAS)model 13. StandardSGSmodelinOpenFOAM LibrarynameNote oneEqEddyk-equa*oneddy-viscositymodel dynOneEqEddyDynamick-equa*oneddy-viscositymodel spectEddyViscSpectraleddyviscositymodel LRDDiStressLRRdieren*alstressmodel DeardorDiStressDeardordieren*alstressmodel SpalartAllmarasSpalart-Allmarasmodel SpalartAllmarasDDESSpalart-Allmarasdelayeddetachededdysimula*on (DDES)model SpalartAllmarasIDDESSpalart-AllmarasimprovedDDES(IDDES)model vanDriestDelta Simplecube-rootofcellvolumedeltausedin incompressibleLESmodels 14. Tensormathema*cs 15. Tensor Rank0:scalar,e.g.volumeV,pressurep. Rank1:vector,e.g.velocityvectoru,surface vectorS.Descrip*on:a=ai=(a1,a2,a3). Rank2:tensor,e.g.strainratetensorSij, rota*ontensorij. Descrip*on: T = Tij = T11 T12 T13 T21 T22 T23 T31 T32 T33 ! " # # # $ % & & & 16. Symmetric/an*symmetrictensor Velocitygradienttensorisdecomposedinto strainratetensor(symmetric)andvor*city tensor(an*symmetric,skew). Inturbulencemodeling,Sijandijareusually used. Dij = ui xj , Sij = 1 2 ui xj + uj xi " # $$ % & '', ij = 1 2 ui xj uj xi " # $$ % & '' Dij = Sij +ij 17. Opera*onsexclusivetotensorsofrank2 T = 1 2 (T+ TT )+ 1 2 (T TT ) = symmT+skewT, trT = T11 +T22 +T33, diagT = (T11,T22,T33), T = T 1 3 (trT)I+ 1 3 (trT)I = devT+ hydT, detT = T11 T12 T13 T21 T22 T23 T31 T32 T33 18. OpenFOAMtensorclasses Opera2onMathema2calClass Addi*ona+ba+b Subtrac*onabab Scalarmul*plica*onsas*a Scalardivisiona/sa/s Outerproductaba*b Innerproductaba&b Doubleinnerproducta:ba&&b Crossproductaba^b Squarea2sqr(a) Magnitudesquared|a|2magSqr(a) Magnitude|a|mag(a) Poweranpow(a,n) 19. OpenFOAMtensorclasses Opera2onMathema2calClass TransposeTTT.T() DiagonaldiagTdiag(T) TracetrTtr(T) DeviatoriccomponentdevTdev(T) SymmetriccomponentsymmTsymm(T) Skew-symmetric component skewTskew(T) DeterminantdetTdet(T) CofactorscofTcof(T) InverseinvTinv(T) 20. Exercise1:Compilingandexecu*onof WALEmodel 21. Governingequa*onforincompressibleLES Filteredcon*nuityandNavier-Stokesequa*ons where ui xi = 0, ui t +uj ui xj = 1 p xi + xi (ij + 2Sij ) ij = uiuj uiuj 22. SGSeddyviscositymodel Decomposi*onofkine*cenergy Conserva*onofGSenergykGS Conserva*onofSGSenergykSGS kGS t +uj kGS xj = ijSij GS + xi uiij puj + kGS xj # $ %% & ' (( k = 1 2 ukuk = 1 2 ukuk + 1 2 (ukuk ukuk ) kGS kSGS kSGS t +uj kSGS xj = ijSij SGS + xi uiij 1 2 (uiuiuj +uj uiui ) puj puj + kSGS xj # $ % % & ' ( ( 23. Smagorinskymodel LocalequilibriumbetweenSGSproduc*on rateandSGSenergydissipa*on: Eddyviscosityapproxima*on: Aperdimensionalanalysisandscaling, SGS ui xj ui uj ui xj ui xj $ % && ' ( )) = ijSij ij a = 2vSGS Sij SGS = (CS )2 | S |, | S |= 2SijSij , CS : Smagorinskyconstant 24. WALEmodel Tracelesssymmetricpartofthesquareofthe velocitygradienttensor: EddyviscosityofWALEmodel: Sij d = 1 2 (Dij 2 + Dji 2 ) 1 3 ijDkk 2 = SikSkj +ikkj 1 3 ij SmnSmn mnmn #$ %& Sij d Sij d = 1 6 (S2 S2 +2 2 )+ 2 3 S2 2 + 2IVS, S2 = SijSij, 2 = ijij, IVS = SikSkjjlli SGS = (Cw)2 (Sij d Sij d )3/ 2 (SijSij )5/ 2 + (Sij d Sij d )5/ 4 (NicoudandDucros,1999) 25. ModelparametersofWALEmodel FieldaFieldbFieldcFielddFieldeFieldf Cw 2/Cs 210.8110.5210.8410.5510.7011.27 If CS = 0.18, 0.55 CW 0.6. If CS = 0.1, 0.32 CW 0.34. ModelparameterCwisdependentonSmagorinsky constantCS. (NicoudandDucros,1999) 26. SourcecodeofWALEmodel V&Vworkinggroup,OpenCAESocietyofJapan hsps://github.com/opencae/VandV/tree/master/ OpenFOAM/2.2.x/src/libraries/incompressibleWALE OpenFOAM-dev hsps://github.com/OpenFOAM/OpenFOAM-dev/tree/ master/src/TurbulenceModels/turbulenceModels/LES/WALE 27. Downloadandcompile $ mkdirp$FOAM_RUN $ cd $ gitclonehttps://github.com/opencae/VandV $ cdVandV/OpenFOAM/OpenFOAM-BenchmarkTest/ channelReTau110 $ cprsrc$FOAM_RUN/.. $ run $ cd../src/libraries/incompressibleWALE $ wmakelibso $ ls$FOAM_USER_LIBBIN 1. DownloadthesourcecodeofWALEmodelfromtheV&V repository,andcompiletheWALEmodellibrary. 28. Simula*onofchannelow $ run $ cpr$FOAM_TUTORIALS/incompressible/pimpleFoam/ channel395/./ReTau395WALE $ cdReTau395WALE 2. ThestandardtutorialcaseofchannelowatRe=395: copythetutorialcaseleintoyourrundirectory. 3. Editconstant/LESProper*esandsystem/controlDict $ geditconstant/LESProperties LESModelWALE; printCoeffson; deltacubeRootVol; ... 29. Simula*onofchannelow $ geditsystem/controlDict ... libs ("libincompressibleWALE.so"); ThislineisnecessarytocallthenewWALElibraryinsolver. $ ./Allrun 4. Apercheckingothernumericalcondi*onsandparameter, runthesolver. 5. Ifthesolvercalcula*onisnormallynished,youcheckthe logsandvisualizetheoweldwithParaView,andplotthe eldsprolegeneratedbypostChannel. 30. Simula*onofchannelowatRe=110 $ run $ cpr~/VandV/OpenFOAM/OpenFOAM-BenchmarkTest/ channelReTau110/template$FOAM_RUN/ReTau110WALE $ cdReTau110WALE $ geditcaseSettings 6. IfyouusethetestcaseofchannelowsuppliedintheV&V repository,copythetemplatecaseandedittheseung. controlDict { deltaT0.002; endTime0.022; libs"libincompressibleWALE.so"; } 31. Simula*onofchannelowatRe=110 turbulenceProperties { simulationTypeLESModel; } LESProperties { LESModelWALE; deltacubeRootVol; } TheoriginalcaseSeungsisforDNSsimula*ononlargeparallel machine.Youhadbesertochangeotherparametersin blockMeshDictanddecomposeParDict. 32. Simula*onofchannelowatRe=110 $ ./Allrun 7. Apercheckingothernumericalcondi*onsandparameter, runthesolver. 8. Ifthesolvercalcula*onisnormallynished,youcheckthe logsandvisualizetheoweldwithParaView.Ifthe integra*on*meisnotsucientfortheoweldtobecome fullydevelopedstate,runlongersimula*ons. 33. Exercise2:Implementa*onofcoherent structureSmagoriskymodel 34. OriginalsourcecodesforSGSmodel $ src $ cdturbulenceModels/incompressible/LES/ $ ls 1. ChecktheoriginalsourcecodeforSGSmodel. 2. GlancethecodesofSmagorinskymodel. $ geditSmagorinsky/Smagorinsky.* 3. Inthisexercise,welookthecodesofdynamicmodels. $ ls*[Dd]yn* 4. Comparethestructuresandstatementsoftherelatedcodes (*.Cand*.H). 35. Privatememberfunc*ons: updateSubGridScaleFields voidSmagorinsky::updateSubGridScaleFields (constvolTensorField&gradU) {nuSgs_=ck_*delta()*sqrt(k(gradU)); nuSgs_.correctBoundaryConditions(); } voiddynLagrangian::updateSubGridScaleFields (consttmp&gradU) {nuSgs_=(flm_/fmm_)*sqr(delta())*mag(dev(symm(gradU))); nuSgs_.correctBoundaryConditions(); } voiddynOneEqEddy::updateSubGridScaleFields (constvolSymmTensorField&D, constvolScalarField&KK ) {nuSgs_=ck(D,KK)*sqrt(k_)*delta(); nuSgs_.correctBoundaryConditions(); } InSmagorinsky.C IndynLagrangian.C IndynOneEqEddy.C 36. Understandingformula*onwithcodes Whatcalcula*on,mathema*calopera*on,andvariableare necessaryforcoherentstructureSmagosinskymodel(CSM)? Comparetheformula*onofmodelswiththerelatedsource codes. InCSM,thesecondinvariantofvelocitygradientisused: where Q = 1 2 ijij SijSij( )= 1 2 uj xi ui xj Sij = 1 2 ui xj + uj xi # $ %% & ' ((, ij = 1 2 ui xj uj xi # $ %% & ' (( 37. CoherentstructureSmagorinskymodelfornon- rota*ngow(NRCSM) Smagorinskymodel(SM)basedonaneddy-viscosity, ThemodelparameterCisdeterminedasfollows: with where NRCSMmodelisinvalidforrota*ngow. C = C1 | FCS |3/ 2 C1 = 1 20 , FCS = Q E ij a = 2C2 | S | Sij (ij a = 2t Sij, t = C2 | S |) E = 1 2 ijij + SijSij( )= 1 2 ui xj $ % && ' ( )) 2 38. CoherentstructureSmagorinskymodel(CSM) Smagorinskymodel(SM)basedonaneddy-viscosity, ThemodelparameterCisdeterminedasfollows: with where ImprovedCSMmodelisvalidforrota*ngow. C = C2 | FCS |3/ 2 F C2 = 1 22 , FCS = Q E , F =1 FCS ij a = 2C2 | S | Sij (ij a = 2t Sij, t = C2 | S |) E = 1 2 ijij + SijSij( )= 1 2 ui xj $ % && ' ( )) 2 39. Seungformakingnewlibrary $ run $ cd../src/libraries $ cp-rincompressibleWALE/WALE/./NRCSM $ cprincompressibleWALE/Make./NRCSM $ cdNRCSM $ renameWALENRCSM* $ rmrNRCSM.dep $ rmrfMake/linux64Gcc47DPOpt $ geditMake/files 1. CopythesourcecodeofWALEmodel.Compilethem. NRCSM.C LIB=$(FOAM_USER_LIBBIN)/libNRCSM $ sedis/WALE/NRCSM/gNRCSM.C $ sedis/WALE/NRCSM/gNRCSM.H 40. Seungformakingnewlibrary $ wmakelibso $ ls$FOAM_USER_LIBBIN Ifyoundtherenamedandrecompiledlibrary(libNRCSM.so), youarereadytomakeanewlibraryfortheNRCSM. 2.Youcaneasilylearnthecodesforcalcula*ngtheQandE termsfromthepostProcessingu*li*es. Therearetwowaysofcalcula*ngQ,thatis,withvelocity gradienttensorandwithSSand terms. $ util $ cdpostProcessing/velocityField/Q $ geditQ.C& 41. IntroducingmodelcoecientC1 $ run $ cd../src/libraries/NRCSM/ $ geditNRCSM.CNRCSM.H 3. Replaceallcwwithc1(geditorsed),andchangethevalue to0.05. c1_ ( dimensioned::lookupOrAddToDict ( "c1", coeffDict_, 0.05 ) ) NRCSM.C $ wmakelibso 42. QandEcalcula*ons 4. InNRCSM.C,insertthecalcula*onofQandE.Copy&Paste thecorrespondingsec*onfromQ.C.SaveandCompilethem. volScalarFieldQ ( 0.5*(sqr(tr(gradU))-tr(((gradU)&(gradU)))) ); volScalarFieldE ( 0.5*(gradU&&gradU) ); NRCSM.C $ geditNRCSM.C $ wmakelibso 43. FCSandCcalcula*ons 5. InNRCSM.C,insertthecalcula*onofFCSandC(coecient ofeddyviscositymodel).SaveandCompilethem. volScalarFieldFcs ( Q/ max(E,dimensionedScalar("SMALL",E.dimensions(),SMALL)) ); volScalarFieldccsm_ ( c1_*pow(mag(Fcs),1.5) ); NRCSM.C $ geditNRCSM.C $ wmakelibso 44. SGScalcula*on 6. InNRCSM.C,modifythenuSGS_calcula*on.Looktheother updateSubGridScaleFieldsfunc*onsinthedynamicmodels. nuSgs_=ccsm_*sqr(delta())*mag(dev(symm(gradU))); NRCSM.C Saveandcompilethem. $ wmakelibso 7. Finally,commentoutordeleteunnecessarystatements(the calcula*onsforWALEmodel).Saveandcompilethem. $ wmakelibso $ geditNRCSM.C 45. kSGScalcula*on //-ReturnSGSkineticenergy //calculatedfromthegivenvelocitygradient tmpk(consttmp&gradU)const { return(2.0*c1_/ce_)*sqr(delta())*magSqr(dev(symm(gradU))); } NRCSM.H 8. Thecalcula*onofkSGSisinvalid,butthevalueofkSGSisnot actuallyusedinLESwithNRCSMmodel.Ifyourequiresa properkSGS,consultthepaperofKobayashi(PoF,2005). 46. Valida*onwithchannelow $ run $ cpr$FOAM_TUTORIALS/incompressible/pimpleFoam/ channel395/./ReTau395NRCSM $ cdReTau395NRCSM 9. ThestandardtutorialcaseofchannelowatRe=395: copythetutorialcaseleintoyourrundirectory. 10.Editconstant/LESProper*esandsystem/controlDict $ geditconstant/LESProperties LESModelNRCSM; printCoeffson; deltacubeRootVol; ... 47. Valida*onwithchannelow $ geditsystem/controlDict ... libs ("libNRCSM.so"); ThislineisnecessarytocallthenewNRCSMlibraryinsolver. $ ./Allrun 11.Apercheckingothernumericalcondi*onsandparameter, runthesolver. 12.Ifthesolvercalcula*onisnormallynished,youcheckthe logsandvisualizetheoweldwithParaView,andplotthe eldsprolegeneratedbypostChannel. 48. Addi*onalworks 1. CompileandtesttheWALEmodelsuppliedfrom openfoam-dev.PrepareaMakedirectoryby yourself. 2. Implementa*onofCSMmodel.AddFtermandC2 coecient. 3. Calcula*onofQandEtermswithSSandterms. Comparetheresultswiththesolu*onofExercise2. 4. Valida*onofcustomizedmodelwithotherow eldssuchpipe,backstep,cylinder,androta*ng ow. 49. References OpenFOAMUserGuide OpenFOAMProgrammersGuide , ,(2014). P.R.Spalartetal.,CommentsontheFeasibilityofLESfor Wings,andonaHybridRANS/LESApproach,1stASOSR CONFERENCEonDNS/LES(1997). P.R.Spalart,Young-PersonsGuidetoDetached-Eddy Simula*onGrids,NASACR-2001-211032(2001). F.NicoudandF.Ducros,Subgrid-scalemodellingbasedon thesquareofvelocitygradienttensor,Flow,Turbulenceand Combus*on,62,pp.183-200(1999). 50. References , ,,29,pp.157-160(2010). H.Kobayashi,Thesubgrid-scalemodelsbasedoncoherent structuresforrota*nghomogeneousturbulenceand turbulentchannelow,Phys.Fluids,17,045104(2005). H.Kobayashi,F.HamandX.Wu,Applica*onofalocalSGS modelbasedoncoherentstructurestocomplexgeometries, Int.J.HeatFluidFlow,29,pp.640-653(2008).