CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Software User Forums > OpenFOAM > OpenFOAM Programming & Development

modifying the viscosity model (BirdCarreau)

Register Blogs Community New Posts Updated Threads Search

Like Tree2Likes
  • 1 Post By alexeym
  • 1 Post By alexeym

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   June 17, 2014, 09:28
Default modifying the viscosity model (BirdCarreau)
  #1
Sun
Senior Member
 
Sun's Avatar
 
Join Date: Nov 2010
Posts: 103
Rep Power: 15
Sun is on a distinguished road
Hi,
I am trying to modify the BirdCarreau viscosity model. The current expression in OpenFOAM is:
Code:
 nuInf_
      + (nu0_ - nuInf_)
       *pow(scalar(1) + sqr(k_*strainRate()), (n_ - 1.0)/2.0);
where nuInf, nu0, k_ and n_ are constants (dimensionedScalar and being read from the transportProperties). But I should implement two time-dependent correlations for nuInf and nu0. The equations look like the following:

nu0_tmdep = a/(1+b*t+c*t^2)
nuInf_tmdep = exp(e+f*t+g*t^2)

a,b,c,d,e,f, and g are given constants whereas t is time. I have created two volScalarFields in the .C file and deleted reading of nu0_ and nuInf_ everywhere in the .H file.
Code:
Foam::tmp<Foam::volScalarField>
Foam::viscosityModels::ModifiedBirdCarreau::calcNu() const
{
	
	volScalarField nu0_tmdep 
	    (
	     scalar(84.455311)/(scalar(1)-scalar(0.0309746)*runTime.value()+scalar(0.00024088)*sqr(runTime.value()))
	    );

	volScalarField nuInf_tmdep
	    (
	     Foam::exp(scalar(12.022048)-scalar(0.629963)*runTime.value()+scalar(0.00898332)*sqr(runTime.value()))
	    );

	
    return
        nuInf_tmdep
      + (nu0_tmdep - nuInf_tmdep)
       *pow(scalar(1) + sqr(k_*strainRate()), (n_ - 1.0)/2.0);
}
In compilation, I am getting these errors:
ModifiedBirdCarreau/ModifiedBirdCarreau.C: In member function ‘Foam::tmp<Foam::GeometricField<double, Foam::fvPatchField, Foam::volMesh> > Foam::viscosityModels::ModifiedBirdCarreau::calcNu () const’:
ModifiedBirdCarreau/ModifiedBirdCarreau.C:55:54: error: ‘runTime’ was not declared in this scope
ModifiedBirdCarreau/ModifiedBirdCarreau.C: In constructor ‘Foam::viscosityModels::ModifiedBirdCarreau::Modif iedBirdCarreau(const Foam::word&, const Foam::dictionary&, const volVectorField&, const surfaceScalarField&)’:
ModifiedBirdCarreau/ModifiedBirdCarreau.C:104:5: error: no matching function for call to ‘Foam::GeometricField<double, Foam::fvPatchField, Foam::volMesh>::GeometricField()’


I would be really thankful if someone can give me some pieces of advice and I must say I am kind of new in OpenFOAM territory, so I might have done something pretty silly!
Cheers!
Sun is offline   Reply With Quote

Old   June 17, 2014, 10:41
Default
  #2
Senior Member
 
Alexey Matveichev
Join Date: Aug 2011
Location: Nancy, France
Posts: 1,930
Rep Power: 38
alexeym has a spectacular aura aboutalexeym has a spectacular aura about
Send a message via Skype™ to alexeym
Hi,

you can try

Code:
U_.time().timeOutputValue()
if you'd like to access runTime (which usually is available in solvers and is created in createTime.H include file).
Sun likes this.
alexeym is offline   Reply With Quote

Old   June 18, 2014, 02:31
Default
  #3
Sun
Senior Member
 
Sun's Avatar
 
Join Date: Nov 2010
Posts: 103
Rep Power: 15
Sun is on a distinguished road
Hi Alexey,
Thanks a lot for your help.
Now I've got access to the runTime. But it's still complaining about:

In member function ‘Foam::tmp<Foam::GeometricField<double, Foam::fvPatchField, Foam::volMesh> > Foam::viscosityModels::ModifiedBirdCarreau::calcNu () const’:
ModifiedBirdCarreau/ModifiedBirdCarreau.C:59:6: error: no matching function for call to ‘Foam::GeometricField<double, Foam::fvPatchField, Foam::volMesh>::GeometricField(double)’


I am not really sure, where it is coming from! any suggestions would be appreciated.

Cheers!
Sun is offline   Reply With Quote

Old   June 18, 2014, 02:45
Default
  #4
Senior Member
 
Alexey Matveichev
Join Date: Aug 2011
Location: Nancy, France
Posts: 1,930
Rep Power: 38
alexeym has a spectacular aura aboutalexeym has a spectacular aura about
Send a message via Skype™ to alexeym
Hi,

it's just trying to say that it can't construct volScalarField from double. Why would you like to use volScalarField for nu0_tmdep instead of dimensionedScalar? I can see that this value depends on time, but I don't see the dependence of coordinate. So I think this

Code:
volScalarField nu0_tmdep 
	    (
	     scalar(84.455311)/(scalar(1)-scalar(0.0309746)*runTime.value()+scalar(0.00024088)*sqr(runTime.value()))
	    );
should be

Code:
dimensionedScalar nu0_tmdep("nu0", <dimensions of nu0_tmdep>, scalar(84.455311)/(scalar(1) -scalar(0.0309746)*runTime.value() + scalar(0.00024088)*sqr(runTime.value())))
Or you can create this dimensionedScalar in constructor of the class and then just update it value in calcNu method.
Sun likes this.
alexeym is offline   Reply With Quote

Old   June 18, 2014, 03:24
Default
  #5
Sun
Senior Member
 
Sun's Avatar
 
Join Date: Nov 2010
Posts: 103
Rep Power: 15
Sun is on a distinguished road
Thank you so much Alexey for the speedy answer. I created it as a dimensionedScalar in the constructor and no compilation error.
You've just made my day!
cheers!
Sun is offline   Reply With Quote

Old   March 16, 2015, 10:06
Default Adding Time
  #6
New Member
 
Stefan
Join Date: Mar 2015
Location: Bavaria
Posts: 7
Rep Power: 11
deve is on a distinguished road
Hey,

I didn't want to open a new thread since I think that my problem has a lot to do with the problem of the thread opener's.

i'm trying to modify a viscosity model (newtonian, but i guess it doesn't matter). What I want to do is, make the viscosity time dependent.
So I wrote a simple equation which describes this relation:
Viscosity = nu * ( 1 + nu / 700 * Time )
and implemented it in the following source code (see green lines!)
(Voelkl is the Name of my ViscosityModel)
Code:
#include "Voelkl.H"
#include "addToRunTimeSelectionTable.H"
#include "surfaceFields.H"
//extern Foam::Time runTime;
 
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
 
namespace Foam
{
namespace viscosityModels
{
    defineTypeNameAndDebug(Voelkl, 0);
    addToRunTimeSelectionTable(viscosityModel,Voelkl,dictionary);
}
}
 
 
// * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
Foam::viscosityModels::Voelkl::Voelkl
(
    const word& name,
    const dictionary& viscosityProperties,
    const volVectorField& U,
    const surfaceScalarField& phi
)
:
    viscosityModel(name, viscosityProperties, U, phi),
    nu0_("nu", dimensionSet(0, 2, -1, 0, 0), viscosityProperties_.lookup("nu")),
    nu_
    (
        IOobject
        (
            name,
            U_.time().timeName(),
            U_.db(),
            IOobject::NO_READ,
            IOobject::AUTO_WRITE
        ),
        U_.mesh(),
       nu0_* ( 1 + nu0_ / 700 * runTime.value() )
  //   nu0_* ( 1 + nu0_ / 700 * U_.time()timeOutputValue() )
    )
{}
 
 
// * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * * //
 
bool Foam::viscosityModels::Voelkl::read
(
    const dictionary& viscosityProperties
)
{
    viscosityModel::read(viscosityProperties);
 
    viscosityProperties_.lookup("nu") >> nu0_;
    nu_ = nu0_;
 
    return true;
}
 
 
// ************************************************************************* //
The Problem is that neither of the two variants are working. I tried a lot of things but had no success yet.
Among these tries were adding
Code:
#include "createTime.H"
which resulted in the following Problem:
Code:
deve@deve:~/OpenFOAM/deve-2.3.1/applications/viscosityModels/Voelkl$ wmake
wmakeLnInclude: linking include files to ./lnInclude
Making dependency list for source file Voelkl.C
SOURCE=Voelkl.C ;  g++ -m64 -Dlinux64 -DWM_DP -Wall -Wextra -Wno-unused-parameter -Wold-style-cast -Wnon-virtual-dtor -O3  -DNoRepository -ftemplate-depth-100 -I/opt/openfoam231/src/transportModels/incompressible/lnInclude/ -I/opt/openfoam231/src/finiteVolume/lnInclude -IlnInclude -I. -I/opt/openfoam231/src/OpenFOAM/lnInclude -I/opt/openfoam231/src/OSspecific/POSIX/lnInclude   -fPIC -c $SOURCE -o Make/linux64GccDPOpt/Voelkl.o
In file included from Voelkl.C:29:0:
/opt/openfoam231/src/OpenFOAM/lnInclude/createTime.H:5:5: error: ‘Info’ in namespace ‘Foam’ does not name a type
     Foam::Info<< "Create time\n" << Foam::endl;
     ^
/opt/openfoam231/src/OpenFOAM/lnInclude/createTime.H:7:53: error: ‘args’ was not declared in this scope
     Foam::Time runTime(Foam::Time::controlDictName, args);
                                                     ^
make: *** [Make/linux64GccDPOpt/Voelkl.o] Fehler 1
I noticed that the "createTime.H" file is not what i expected.
Code:
//
// createTime.H
// ~~~~~~~~~~~~
 
    Foam::Info<< "Create time\n" << Foam::endl;
 
    Foam::Time runTime(Foam::Time::controlDictName, args);

Does anyone have a clue what the problem is?
Thanks in advance
Deve

Edit: I was able to find a solution to my problem; send PM for further information

Last edited by deve; March 24, 2015 at 04:44. Reason: resolved
deve is offline   Reply With Quote

Old   February 10, 2016, 09:59
Default
  #7
New Member
 
Jeferson Souza
Join Date: Jan 2012
Location: Brazil
Posts: 19
Rep Power: 14
jasouza1974 is on a distinguished road
Hi deve,

I'm having the same problem. I can not access runTime() variable from my viscosity model.

How did you solve the problem?

Thanks.
jasouza1974 is offline   Reply With Quote

Reply


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 Off
Trackbacks are Off
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Problem with divergence TDK FLUENT 13 December 14, 2018 06:00
Viscosity model - Compressible flow Aurelien Thinat OpenFOAM Programming & Development 3 March 6, 2018 07:08
coefficient of power-Law viscosity Model in OpenFOAM Daniel_Khazaei OpenFOAM Running, Solving & CFD 6 April 5, 2016 04:23
Validity of Sutherland's viscosity model for high-T gases tatu Main CFD Forum 1 March 6, 2013 12:00
Power - Law Viscosity Model for Polymers NickolasPl OpenFOAM 2 August 12, 2011 08:26


All times are GMT -4. The time now is 14:16.