# Temperature dependent viscosity (Carreau-Yasuda)

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

May 6, 2016, 09:48
Temperature dependent viscosity (Carreau-Yasuda)
#1
New Member

Join Date: Apr 2016
Posts: 13
Rep Power: 6
New OpenFoam (2.4) user!

As per the title... I wish to use a temperature dependent viscosity model. I've seen various posts and papers on this so I've followed the example modifying the power law - that compiles ok.

My next step was to take the BirdCarreau and modify to suit Carreau-Yasuda:
Quote:
 u=u0 * alpha * [lambda * alpha * strainrate + 1]^((n-1)/2) alpha = exp[beta * (1/T - 1/Tref)]
Code:
```Foam::tmp<Foam::volScalarField>
Foam::viscosityModels::TempCarreauYasuda::calcNu() const
{
const volScalarField& T= U_.mesh().lookupObject<volScalarField>("T");

return max
(
nuInf_,

nu0_ * Foam::exp(beta_ * (1.0/T - 1.0/Tref_) )
*pow(lambda_ * Foam::exp(beta_ * (1.0/T - 1.0/Tref_) ) * strainRate() + scalar(1), (n_ - 1.0)/a_)

);
}```
transportProperties
Code:
```TempCarreauYasudaCoeffs
{
nu0             nu0 [ 0 2 -1 0 0 0 0 ] 7.191; // 5645/rho
nuInf           nuInf [ 0 2 -1 0 0 0 0 ] 1.2739e-03; // 1/rho
lambda          lambda [ 0 0 -1 0 0 0 0 ] 0.28;
n               n [ 0 0 0 0 0 0 0 ] 0.61;
beta            beta [ 0 0 0 1 0 0 0 ] 6330.0;
Tref            Tref [ 0 0 0 1 0 0 0 ] 473.15;
a               a [ 0 0 0 0 0 0 0 ] 2.0; // can omit as will default to 2
}```
Question 1: how can I define
Code:
`Foam::exp(beta_ * (1.0/T - 1.0/Tref_) )`
as a variable to avoid repetition?

Question 2: The code compiles without error. Why is the following error occurring:
Code:
```Selecting incompressible transport model TempCarreauYasuda

--> FOAM FATAL ERROR:
LHS and RHS of + have different dimensions
dimensions : [0 0 -2 0 0 0 0] + [0 0 0 0 0 0 0]

From function operator+(const dimensionSet&, const dimensionSet&)
in file dimensionSet/dimensionSet.C at line 478.

FOAM aborting

#0  Foam::error::printStack(Foam::Ostream&) at ??:?
#1  Foam::error::abort() at ??:?
#2  Foam::operator+(Foam::dimensionSet const&, Foam::dimensionSet const&) at ??:?
#3  Foam::tmp<Foam::GeometricField<double, Foam::fvPatchField, Foam::volMesh> > Foam::operator+<Foam::fvPatchField, Foam::volMesh>(Foam::tmp<Foam::GeometricField<double, Foam::fvPatchField, Foam::volMesh> > const&, Foam::dimensioned<double> const&) at ??:?
#4  Foam::viscosityModels::TempCarreauYasuda::calcNu() const at ??:?
#5  Foam::viscosityModels::TempCarreauYasuda::TempCarreauYasuda(Foam::word const&, Foam::dictionary const&, Foam::GeometricField<Foam::Vector<double>, Foam::fvPatchField, Foam::volMesh> const&, Foam::GeometricField<double, Foam::fvsPatchField, Foam::surfaceMesh> const&) at ??:?
#6  Foam::viscosityModel::adddictionaryConstructorToTable<Foam::viscosityModels::TempCarreauYasuda>::New(Foam::word const&, Foam::dictionary const&, Foam::GeometricField<Foam::Vector<double>, Foam::fvPatchField, Foam::volMesh> const&, Foam::GeometricField<double, Foam::fvsPatchField, Foam::surfaceMesh> const&) at ??:?
#7  Foam::viscosityModel::New(Foam::word const&, Foam::dictionary const&, Foam::GeometricField<Foam::Vector<double>, Foam::fvPatchField, Foam::volMesh> const&, Foam::GeometricField<double, Foam::fvsPatchField, Foam::surfaceMesh> const&) at ??:?
#8  Foam::singlePhaseTransportModel::singlePhaseTransportModel(Foam::GeometricField<Foam::Vector<double>, Foam::fvPatchField, Foam::volMesh> const&, Foam::GeometricField<double, Foam::fvsPatchField, Foam::surfaceMesh> const&) at ??:?
#9  ? at ??:?
#10  __libc_start_main in "/lib/x86_64-linux-gnu/libc.so.6"
#11  ? at ??:?```
It looks like a dimension problem but I'm not sure why.

May 6, 2016, 10:01
#2
New Member

Join Date: Apr 2016
Posts: 13
Rep Power: 6
Question 2 is resolved... I notice that I specified incorrect units in the transportProperties.

The full source code is attached (no guarantees) to help other beginners.

Still looking for guidance with the first question.
Attached Files
 tempCarreauYasuda.tar.gz (2.5 KB, 29 views)

 May 9, 2016, 03:51 #3 Member   Join Date: Sep 2014 Location: Germany Posts: 88 Rep Power: 8 Do you mean something like that? Code: ```Foam::tmp Foam::viscosityModels::TempCarreauYasuda::calcNu() const { const volScalarField& T= U_.mesh().lookupObject("T"); volScalarField test = Foam::exp(beta_ * (1.0/T - 1.0/Tref_) ); return max ( nuInf_, nu0_ * Foam::exp(beta_ * (1.0/T - 1.0/Tref_) ) * pow(lambda_ * test * strainRate() + scalar(1), (n_ - 1.0)/a_) ); }``` I hope it works...

June 21, 2016, 09:35
#4
New Member

Join Date: Apr 2016
Posts: 13
Rep Power: 6
Quote:
 Originally Posted by TobM I hope it works...
Forgot to post back; yes works, and thank you for your help.

 Tags openfoam, temperature, viscosity

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

 Similar Threads Thread Thread Starter Forum Replies Last Post kcgmech Fluent UDF and Scheme Programming 1 November 22, 2016 18:01 vabishek OpenFOAM Programming & Development 3 May 15, 2016 22:05 GregorAlan OpenFOAM Running, Solving & CFD 0 February 11, 2016 06:29 cric92 Fluent UDF and Scheme Programming 0 April 14, 2013 07:31 hennas FLUENT 1 October 31, 2011 18:55

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