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

Adding a new temperature dependent viscositymodel?

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   May 6, 2010, 04:56
Default Adding a new temperature dependent viscositymodel?
  #1
New Member
 
Dan Gadensgaard
Join Date: Apr 2010
Posts: 13
Rep Power: 16
dgadensg is on a distinguished road
Hi Foamers.

I am currently trying to implement a new viscosity model that is dependent on temperature. I can see that a few others in this forum has succesfully implemented the CrossWLF model, but i have not yet seen how they have done it.

My problem is how to read the volScalarField T that i have for temperature, created in createFields.H and calculated with a temperature equation.

Whenever i do this, it messes up in several classes, because the viscositymodel suddenly have an extra parameter T besides U and phi.

Does anyone have a way to get around this? or maybe even a working code to do this?

// Dan
dgadensg is offline   Reply With Quote

Old   May 8, 2010, 13:30
Default Solved
  #2
New Member
 
Dan Gadensgaard
Join Date: Apr 2010
Posts: 13
Rep Power: 16
dgadensg is on a distinguished road
Hi again.

There is no need to answer, as i have just solved this issue. However, i did in a somewhat alternative way, by adding the volScalarField T to all my transportmodels. It works, but it is not the most elegant solution .

// Dan
dgadensg is offline   Reply With Quote

Old   May 12, 2010, 18:53
Default
  #3
Member
 
Johannes Baumann
Join Date: Mar 2009
Location: Baden-Wuerttemberg, Germany
Posts: 43
Rep Power: 17
johannes is on a distinguished road
Hi Dan,

I came across your thread just recently so I missed answering in time...

A few months ago I was in the same situation, searching for a CrossWLF viscosity model for OpenFOAM. Since I couldn't find any working code snippets floating around on the forum, I tried to implement it myself.

I don't know exactly if everything is implementet correctly, since I encountered some serious stability problems with increasing viscosity and VOF solvers.

However, maybe at least I can provide you with a 'more elegant' solution for your problem.

Assuming you already added volScalarField T to your CrossWLF class, you should be able to read it during the viscosity correction calcNu() using

Code:
const volScalarField& T = U_.mesh().lookupObject<volScalarField>("T");
Back then I lacked a suitable test case for validating the CrossWLF model, which was one of the reasons I stopped testing. Have you already found one?

Best regards,
Johannes
johannes is offline   Reply With Quote

Old   May 13, 2010, 03:32
Default
  #4
New Member
 
Dan Gadensgaard
Join Date: Apr 2010
Posts: 13
Rep Power: 16
dgadensg is on a distinguished road
Hi Johannes.

Thanks you for your answer. The code for accessing "T" in the models class you've provided is definetly more elegant, as iv'e implemented it by adding "volScalarField T" to all the constructors in the transportmodels.

As for the testcase, i am validating my implementation against the article: S. Radl, T. Tritthart, J.G. Khinast: "A Novel Design for hot-melt extrusion pelletizers", brought in Chemical Engineering Science, by Elsevier. In this article they have also use OpenFOAM, and they have shown the development of flow and temperature through a capillary die hole.

Note that I have not implemented the CrossWLF model, but instead added an exponential term to the powerLawModel.

Best Regards,
Dan
dgadensg is offline   Reply With Quote

Old   May 13, 2010, 07:39
Default
  #5
Senior Member
 
Laurence R. McGlashan
Join Date: Mar 2009
Posts: 370
Rep Power: 23
l_r_mcglashan will become famous soon enough
Is that really more elegant though? If you're looking for better programming practice then it is surely preferable to pass temperature through the constructor, as opposed to looking the temperature up in the object registry. Or you could just pass it through a new member function when you want to evaluate a new viscosity.
__________________
Laurence R. McGlashan :: Website
l_r_mcglashan is offline   Reply With Quote

Old   May 13, 2010, 08:32
Default
  #6
New Member
 
Dan Gadensgaard
Join Date: Apr 2010
Posts: 13
Rep Power: 16
dgadensg is on a distinguished road
Well, i see your point, but passing it through the constructor is in my opinion only an elegant solution if it done consistenly throughout the code, which requires a respectible amount of work. This will also result in the volScalarField T being added to many classes, without ever being used.

I am sure that you could pass it through a new member function, but being on the "beginner"-level in OpenFOAM, this will take me a considerable amount of time to do.

// Dan
dgadensg is offline   Reply With Quote

Old   May 13, 2010, 08:53
Default
  #7
Senior Member
 
Laurence R. McGlashan
Join Date: Mar 2009
Posts: 370
Rep Power: 23
l_r_mcglashan will become famous soon enough
I would have a look at how the thermophysical models are implemented, in particular how the basic/psiThermo and basic/rhoThermo inherit from basicThermo.

Obviously, it may not be worth the effort, but it may be quite satisfying to try!
__________________
Laurence R. McGlashan :: Website
l_r_mcglashan is offline   Reply With Quote

Old   May 19, 2010, 05:58
Default problem with adding a viscosityModel
  #8
Member
 
xianghong wu
Join Date: Mar 2009
Posts: 57
Rep Power: 17
wendywu is on a distinguished road
Hi, foamers,

I am adding a viscosityModel into OF. I set up a folder named myViscosityModel into viscosityModels folder, looks like PowerLaw. Surely I set up myViscosityModel.C
and myViscosityModel.H. when I finished these I compile it with command "wmake libso".
there comes an error in the results:
"myViscosityModelCoeffs_lookup" was not declared in this scope.
the myViscosityModel.C file is as follows:
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2008 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
\*---------------------------------------------------------------------------*/
#include "fvCFD.H"
#include "myViscosityModel.H"
#include "addToRunTimeSelectionTable.H"
#include "surfaceFields.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
namespace Foam
{
namespace viscosityModels
{ defineTypeNameAndDebug(myViscosityModel, 0);
addToRunTimeSelectionTable
(
viscosityModel,
myViscosityModel,
dictionary
);
}
}
// * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * * //
Foam::tmp<Foam::volScalarField>
Foam::viscosityModels::myViscosityModel::calcNu() const
{ //shearrate
//- in your class, we can obtain the temperature. The only possible way is looking up "T" through objectRgistry.
const volScalarField & T=U_.db().lookupObject<volScalarField>("T");


volScalarField shearrate=max(minshearrate_,sqrt(2.0*((symm(fvc::g rad(U_))) && (symm(fvc::grad(U_))))/3.0)); //锟斤拷锟斤拷锟截凤拷锟斤拷U原锟斤拷没锟斤拷锟铰伙拷锟斤拷
volScalarField Z=shearrate*(exp(deltaH_/(R_*T)));
return asinh(pow(Z/A_,1.0/n_))/(3*beta_*shearrate)/rho_;
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::viscosityModels::myViscosityModel::myViscosi tyModel
(
const word& name,
const dictionary& viscosityProperties,
const volVectorField& U_, //锟斤拷锟斤拷锟截凤拷锟斤拷U原锟斤拷没锟斤拷锟铰伙拷锟斤拷
const surfaceScalarField& phi
)
: viscosityModel(name, viscosityProperties, U_, phi), //锟斤拷锟斤拷锟截凤拷锟斤拷U原锟斤拷没锟斤拷锟铰伙拷锟斤拷
myViscosityModelCoeffs_(viscosityProperties.subDic t(typeName + "Coeffs")), //********what is this for???
rho_(myViscosityModelCoeffs_.lookup("rho")),
R_(myViscosityModelCoeffs_.lookup("R")),
A_(myViscosityModelCoeffs_.lookup("A")),
beta_(myViscosityModelCoeffs_.lookup("beta")),
deltaH_(myViscosityModelCoeffs_.lookup("deltaH")),
n_(myViscosityModelCoeffs_.lookup("n")),
minshearrate_(myViscosityModelCoeffs_.lookup("mins hearrate")),
nu_
(
IOobject
( name,
U_.time().timeName(), //锟斤拷锟斤拷锟截凤拷锟斤拷U原锟斤拷没锟斤拷锟铰伙拷锟斤拷
U_.db(),
IOobject::NO_READ,
IOobject::AUTO_WRITE
),
calcNu()
)
{}
// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
bool Foam::viscosityModels::myViscosityModel::read
( const dictionary& viscosityProperties
)
{
viscosityModel::read(viscosityProperties);
myViscosityModelCoeffs_ = viscosityProperties.subDict(typeName + "Coeffs");
myViscosityModelCoeffs_.lookup("rho") >> rho_;
myViscosityModelCoeffs_.lookup("R") >> R_;
myViscosityModelCoeffs_.lookup("A") >> A_;
myViscosityModelCoeffs_.lookup("beta") >> beta_;
myViscosityModelCoeffs_.lookup("deltaH") >> deltaH_;
myViscosityModelCoeffs_.lookup("n") >> n_;
myViscosityModelCoeffs_lookup("minshearrate")>>min shearrate_;
return true;
}
// ************************************************** ********************* //

the error is located at the last line: myViscosityModelCoeffs_lookup)"minshearrate")>>min shearrate_;

Anybody knows the reason? Thanks in advance.

Wendy
wendywu is offline   Reply With Quote

Old   May 19, 2010, 06:00
Default myviscosityModel.H
  #9
Member
 
xianghong wu
Join Date: Mar 2009
Posts: 57
Rep Power: 17
wendywu is on a distinguished road
here is the File "myViscosityModel.H"
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2008 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
Class
Foam::viscosityModels::myViscosityModel
Description
Standard viscoPlastic non-Newtonian viscosity model.
SourceFiles
myViscosityModel.C
\*---------------------------------------------------------------------------*/
#ifndef myViscosityModel_H
#define myViscosityModel_H
#include "viscosityModel.H"
#include "dimensionedScalar.H"
#include "volFields.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{ namespace viscosityModels
{
/*---------------------------------------------------------------------------*\
Class myViscosityModel Declaration
\*---------------------------------------------------------------------------*/
class myViscosityModel
: public viscosityModel
{
// Private data
dictionary myViscosityModelCoeffs_;
// dimensionedScalar k_;
// dimensionedScalar n_;
// dimensionedScalar nuMin_;
// dimensionedScalar nuMax_;
// volScalarField shearrate_;
// volScalarField Z_;
dimensionedScalar rho_;
dimensionedScalar R_;
dimensionedScalar A_;
dimensionedScalar beta_;
dimensionedScalar deltaH_;
dimensionedScalar n_;
volScalarField nu_;
dimensionedScalar minshearrate_;
// Private Member Functions
//- Calculate and return the laminar viscosity
tmp<volScalarField> calcNu() const;
public:
//- Runtime type information
TypeName("myViscosityModel");
// Constructors
//- Construct from components
myViscosityModel
(
const word& name,
const dictionary& viscosityProperties,
const volVectorField& U,
const surfaceScalarField& phi
);
// Destructor
~myViscosityModel()
{}
// Member Functions
//- Return the laminar viscosity
tmp<volScalarField> nu() const
{ return nu_; }
//- Correct the laminar viscosity
void correct()
{ nu_ = calcNu(); }
//- Read transportProperties dictionary
bool read(const dictionary& viscosityProperties);
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace viscosityModels
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************** *********************** //

Thanks,

Wendy
wendywu is offline   Reply With Quote

Old   May 19, 2010, 06:04
Default
  #10
Senior Member
 
Laurence R. McGlashan
Join Date: Mar 2009
Posts: 370
Rep Power: 23
l_r_mcglashan will become famous soon enough
Quote:
Originally Posted by wendywu View Post
{
viscosityModel::read(viscosityProperties);
myViscosityModelCoeffs_ = viscosityProperties.subDict(typeName + "Coeffs");
myViscosityModelCoeffs_.lookup("rho") >> rho_;
myViscosityModelCoeffs_.lookup("R") >> R_;
myViscosityModelCoeffs_.lookup("A") >> A_;
myViscosityModelCoeffs_.lookup("beta") >> beta_;
myViscosityModelCoeffs_.lookup("deltaH") >> deltaH_;
myViscosityModelCoeffs_.lookup("n") >> n_;
myViscosityModelCoeffs_lookup("minshearrate")>>min shearrate_;
return true;
}
// ************************************************** ********************* //

the error is located at the last line: myViscosityModelCoeffs_lookup)"minshearrate")>>min shearrate_;

Anybody knows the reason? Thanks in advance.

Wendy
You forgot the dot in that line:

myViscosityModelCoeffs_.lookup("minshearrate")>>mi nshearrate_;

You should also start another thread as this doesn't really relate to what was being discussed earlier.
__________________
Laurence R. McGlashan :: Website
l_r_mcglashan is offline   Reply With Quote

Old   May 22, 2010, 06:47
Default
  #11
Member
 
xianghong wu
Join Date: Mar 2009
Posts: 57
Rep Power: 17
wendywu is on a distinguished road
Laurence,

Thank you so much. Sorry for being so careless.

Wendy
wendywu is offline   Reply With Quote

Reply

Tags
temperature, viscosity models


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
Calculation of the Governing Equations Mihail CFX 7 September 7, 2014 07:27
Temperature Dependent Fluid Properties eliwide OpenFOAM Running, Solving & CFD 4 December 15, 2012 20:21
Poor convergence with temperature dependent density on modified pisoFOAM ovie OpenFOAM 1 March 20, 2011 04:19
Multicomponent with Temperature dependent SAKTI Siemens 3 September 15, 2008 23:09
Time Dependent Temperature Dependent BC Analysis RP Main CFD Forum 1 March 28, 2008 02:22


All times are GMT -4. The time now is 17:40.