# Zero Equation Turbulence models

 Register Blogs Members List Search Today's Posts Mark Forums Read

 April 9, 2013, 11:56 Zero Equation Turbulence models #1 New Member   Stefan Gracik Join Date: Oct 2011 Location: Penn State Posts: 8 Rep Power: 7 Has anyone implemented any zero equation turbulence models to OpenFOAM? That is, a turbulence model which uses algebraic equations to calculate turbulent viscosity rather than PDE's (k, ε etc.). The classic example of this is the Prandtl mixing length model. I'm trying to implement a specialized model and am having trouble modifying the 2 and 1 eq models to remove the PDE's, so I figured having a zero equation model already implemented would help me understand what I need to do. Thanks

 April 16, 2013, 11:25 #2 New Member   Stefan Gracik Join Date: Oct 2011 Location: Penn State Posts: 8 Rep Power: 7 I've made some progress on this, but am stuck again. It is an equation designed for modeling external airflow over buildings. The turbulence model I'm trying to implement is depended on this distance to wall, where H is the average height of the building (implemented as a dimensionedScalar) for walldist <= 1.3*H, nut = const*exp(walldist/H)*U and for walldist >1.3*H, nut = const*walldist ... etc. I thought the best way to write this would be with an if statement. Currently I have written it like this (where d_ is the walldist) Code: ``` if (d_ <= (1.3*H_)) { nut_ = a_*zh_*exp(-b_*d_/H_)*U_*pow((d_/H_),2); nut_.correctBoundaryConditions(); } else { nut_ = 0.16*Uh_*(d_ + z0_)/Foam::log((d_ + z0_)/z0_); nut_.correctBoundaryConditions(); }``` but receive a pretty long error Code: ```wmakeLnInclude: linking include files to ./lnInclude Making dependency list for source file mykEpsilon.C SOURCE=mykEpsilon.C ; g++ -m64 -Dlinux64 -DWM_DP -Wall -Wextra -Wno-unused-parameter -Wold-style-cast -Wnon-virtual-dtor -O3 -DNoRepository -ftemplate-depth-100 -I/opt/openfoam211/src/turbulenceModels -I/opt/openfoam211/src/transportModels -I/opt/openfoam211/src/finiteVolume/lnInclude -I/opt/openfoam211/src/meshTools/lnInclude -I/opt/openfoam211/src/turbulenceModels/incompressible/RAS/lnInclude -IlnInclude -I. -I/opt/openfoam211/src/OpenFOAM/lnInclude -I/opt/openfoam211/src/OSspecific/POSIX/lnInclude -fPIC -c \$SOURCE -o Make/linux64GccDPOpt/mykEpsilon.o mykEpsilon.H: In constructor ‘Foam::incompressible::RASModels::mykEpsilon::mykEpsilon(const volVectorField&, const surfaceScalarField&, Foam::transportModel&, const Foam::word&, const Foam::word&)’: mykEpsilon.H:81:31: warning: ‘Foam::incompressible::RASModels::mykEpsilon::H_’ will be initialized after [-Wreorder] mykEpsilon.H:77:31: warning: ‘Foam::dimensionedScalar Foam::incompressible::RASModels::mykEpsilon::Uh_’ [-Wreorder] mykEpsilon.C:47:1: warning: when initialized here [-Wreorder] mykEpsilon.C:160:19: error: no match for ‘operator<=’ in ‘((Foam::incompressible::RASModels::mykEpsilon*)this)->Foam::incompressible::RASModels::mykEpsilon::d_ <= Foam::operator*(const Foam::dimensioned&, const Foam::dimensioned&) [with Type = double]((*(const Foam::dimensioned*)(&((Foam::incompressible::RASModels::mykEpsilon*)this)->Foam::incompressible::RASModels::mykEpsilon::H_)))’ mykEpsilon.C:160:19: note: candidates are: /opt/openfoam211/src/OpenFOAM/lnInclude/UList.C:224:6: note: bool Foam::UList::operator<=(const Foam::UList&) const [with T = double] /opt/openfoam211/src/OpenFOAM/lnInclude/UList.C:224:6: note: no known conversion for argument 1 from ‘Foam::dimensioned’ to ‘const Foam::UList&’ /opt/openfoam211/src/OpenFOAM/lnInclude/VectorSpaceI.H:693:13: note: template bool Foam::operator<=(const Foam::VectorSpace&, const Foam::VectorSpace&) mykEpsilon.C:162:50: error: no match for ‘operator=’ in ‘((Foam::incompressible::RASModels::mykEpsilon*)this)->Foam::incompressible::RASModels::mykEpsilon::nut_ = Foam::operator*(const Foam::tmp >&, const Foam::tmp >&) [with Type = Foam::Vector, PatchField = Foam::fvPatchField, GeoMesh = Foam::volMesh]((*(const Foam::tmp >*)(& Foam::pow(const Foam::tmp >&, const scalar&) [with PatchField = Foam::fvPatchField, GeoMesh = Foam::volMesh, Foam::scalar = double]((* &2.0e+0)))))’ mykEpsilon.C:162:50: note: candidates are: /opt/openfoam211/src/OpenFOAM/lnInclude/GeometricField.C:1083:6: note: void Foam::GeometricField::operator=(const Foam::GeometricField&) [with Type = double, PatchField = Foam::fvPatchField, GeoMesh = Foam::volMesh] /opt/openfoam211/src/OpenFOAM/lnInclude/GeometricField.C:1083:6: note: no known conversion for argument 1 from ‘Foam::tmp, Foam::fvPatchField, Foam::volMesh> >’ to ‘const Foam::GeometricField&’ /opt/openfoam211/src/OpenFOAM/lnInclude/GeometricField.C:1108:6: note: void Foam::GeometricField::operator=(const Foam::tmp >&) [with Type = double, PatchField = Foam::fvPatchField, GeoMesh = Foam::volMesh] /opt/openfoam211/src/OpenFOAM/lnInclude/GeometricField.C:1108:6: note: no known conversion for argument 1 from ‘Foam::tmp, Foam::fvPatchField, Foam::volMesh> >’ to ‘const Foam::tmp >&’ /opt/openfoam211/src/OpenFOAM/lnInclude/GeometricField.C:1144:6: note: void Foam::GeometricField::operator=(const Foam::dimensioned
&) [with Type = double, PatchField = Foam::fvPatchField, GeoMesh = Foam::volMesh] /opt/openfoam211/src/OpenFOAM/lnInclude/GeometricField.C:1144:6: note: no known conversion for argument 1 from ‘Foam::tmp, Foam::fvPatchField, Foam::volMesh> >’ to ‘const Foam::dimensioned&’ make: *** [Make/linux64GccDPOpt/mykEpsilon.o] Error 1 stefan@stefan-OpenFOAM:~/OpenFOAM/stefan-2.1.1/src/turbulenceModels/incompressible/RAS/mykEpsilon\$``` Any idea what the issue is? I have a feeling it has something to do with comparing walldist to a dimensionedScalar, but I'm really not sure.

 April 17, 2013, 03:33 #3 Member   cosimo bianchini Join Date: Mar 2009 Location: Florence, Tuscany, Italy Posts: 88 Rep Power: 9 If I did not misunderstand you should use your if statement within a loop on the internal cells of your volScalarField nut_. What the error is saying is that it makes no sense a statement like <= for a volScalarField in fact for some cells it will be > for others <. In order to make it work write something like forAll(nut_,cellI) { if(d_[cellI] <= (1.3*H_)) { nut_[cellI] = a_*zh_*exp(-b_*d_[cellI]/H_)*mag(U_)*pow((d_[cellI]/H_),2); } else { nut_[cellI] = 0.16*Uh_*(d_[cellI] + z0_)/Foam::log((d_[cellI] + z0_)/z0_); } } assuming that all other variables except for d_ and U_ are of type scalar this should work. Another thing you should pay attention to is in the use of vector variables (I guessed U_ it is velocity vector) in a statement with scalars on the LHS, I added the operator mag(U_) to evaluate the magnitude of velocity but I'm not sure this is what you want. Change the operator accordingly to your needs but check that it returns a scalar. __________________ Cosimo Bianchini Ergon Research s.r.l. Via Panciatichi, 92 50127 Florence - ITALY Tel: +39 055 0763716 Mob: +39 320 9460153 e-mail: cosimo.bianchini@ergonresearch.it URL: www.ergonresearch.it

 April 17, 2013, 14:12 Thanks #4 New Member   Stefan Gracik Join Date: Oct 2011 Location: Penn State Posts: 8 Rep Power: 7 Thanks for the help!! but now I have a new error. d_ is generated from walldist.H, so it's the distance to the nearest wall. All of the other constants I've defined as dimensionedScalar Code: ```a_ ( dimensioned::lookupOrAddToDict ( "a", coeffDict_, 0.09 ) ), b_ ( dimensioned::lookupOrAddToDict ( "b", coeffDict_, 0.09 ) ), H_ ( dimensioned//::lookupOrAddToDict ( "H", dimensionSet(0, 1, 0, 0, 0, 0, 0), 1.92 ) ), Uh_ ( dimensioned//::lookupOrAddToDict ( "Uh", dimensionSet(0, 1, -1, 0, 0, 0, 0), 1.44 ) ), zh_ ( dimensioned//::lookupOrAddToDict ( "zh", dimensionSet(0, 1, 0, 0, 0, 0, 0), 1.92 ) ), z0_ ( dimensioned//::lookupOrAddToDict ( "z0", dimensionSet(0,1,0,0,0,0,0), 1.3 ) ),``` but I still receive the error "mykEpsilon.C:180:83: error: cannot convert ‘Foam::dimensioned’ to ‘double’ in assignment" Anyone have any idea why this could be?

 Thread Tools Display Modes Linear Mode

 Posting Rules You may not post new threads You may not post replies You may not post attachments You may not edit your posts BB code is On Smilies are On [IMG] code is On HTML code is OffTrackbacks are On Pingbacks are On Refbacks are On Forum Rules

 Similar Threads Thread Thread Starter Forum Replies Last Post Mohsin FLUENT 2 October 3, 2016 14:18 Mihail CFX 7 September 7, 2014 06:27 Beginner Main CFD Forum 1 January 7, 2009 06:36 summer FLUENT 4 July 13, 2007 09:57 haider FLUENT 0 March 8, 2006 00:58

All times are GMT -4. The time now is 21:27.