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

Temperature dependent Viscosity using Power-Law

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   November 6, 2014, 19:37
Default Temperature dependent Viscosity using Power-Law
  #1
New Member
 
Nara Shikamaru
Join Date: Apr 2012
Posts: 22
Rep Power: 14
shikamaru is on a distinguished road
Hello,

I am working on a problem where I have to take into account the temperature dependent viscosity of non-Newtonian fluids. I modified the solver to account for energy equation (similar to posts available in the forum) and tried to implement the power-law model available in FLUENT (http://aerojet.engr.ucdavis.edu/flue...ug/node340.htm).

I modified everything similar to work done here (http://www.tfd.chalmers.se/~hani/kur...nFoam%20v2.pdf), except to make it similar to the FLUENT implementation, I changed the part of the viscosity model equation.

The pdf file attached has the form in powerLaw.C file for CalcNu() function

Code:
Foam::tmp<Foam::volScalarField>
Foam::viscosityModels::powerLawTemp::calcNu() const
{
const volScalarField& T=U_.mesh().lookupObject<volScalarField>("T");

    return max
    (
        nuMin_,
        min
        (
            nuMax_,
            (k_-ko_*(T-To_))*pow
            (
                max
                (
                    dimensionedScalar("one", dimTime, 1.0)*strainRate(),
                    dimensionedScalar("VSMALL", dimless, VSMALL)
                ),
                n_.value() - scalar(1.0)
            )
        )
    );
}

I just modified it to the following form to match FLUENT's formulation-

Code:
Foam::tmp<Foam::volScalarField>
Foam::viscosityModels::powerLawTemp2::calcNu() const
{
const volScalarField& T=U_.mesh().lookupObject<volScalarField>("T");

    return max
    (
        nuMin_,
        min
        (
            nuMax_,
            (k_*exp(T/To_))*pow
            (
                max
                (
                    dimensionedScalar("one", dimTime, 1.0)*strainRate(),
                    dimensionedScalar("VSMALL", dimless, VSMALL)
                ),
                n_.value() - scalar(1.0)
            )
        )
    );
}

The 1st implementation works fine but for the second one I am getting errors that I can not resolve or understand why its happening. T is a volScalarField and To a scalar taken as input. I thought the exp() should be able to handle that. Here is the error log -

Code:
Create time

Create mesh for time = 0

Reading setFieldsDict

Setting field default values
    Setting internal values of volScalarField alpha.water
    Setting internal values of volScalarField T

Setting field region values
    Adding cells with center within boxes 1((0 0 -1) (0.1461 0.292 1))
    Setting internal values of volScalarField alpha.water
    Adding cells with center within boxes 1((0.2 0.3 -1) (0.3 0.4 1))
    Setting internal values of volScalarField T

End

#0  Foam::error::printStack(Foam::Ostream&) in "/projects/OpenFOAM/OpenFOAM-2.3.0/platforms/linux64GccDPOpt/lib/libOpenFOAM.so"
#1  Foam::sigFpe::sigHandler(int) in "/projects/OpenFOAM/OpenFOAM-2.3.0/platforms/linux64GccDPOpt/lib/libOpenFOAM.so"
#2   in "/lib64/libc.so.6"
#3   in "/lib64/libm.so.6"
#4  exp in "/lib64/libm.so.6"
#5  Foam::exp(Foam::Field<double>&, Foam::UList<double> const&) in "/projects/OpenFOAM/OpenFOAM-2.3.0/platforms/linux64GccDPOpt/lib/libOpenFOAM.so"
#6  void Foam::exp<Foam::fvPatchField, Foam::volMesh>(Foam::GeometricField<double, Foam::fvPatchField, Foam::volMesh>&, Foam::GeometricField<double, Foam::fvPatchField, Foam::volMesh> const&) in "/home/OpenFOAM/2.3.0/platforms/linux64GccDPOpt/lib/libmyIncompressibleTransportModels.so"
#7  Foam::tmp<Foam::GeometricField<double, Foam::fvPatchField, Foam::volMesh> > Foam::exp<Foam::fvPatchField, Foam::volMesh>(Foam::tmp<Foam::GeometricField<double, Foam::fvPatchField, Foam::volMesh> > const&) in "/home/OpenFOAM/2.3.0/platforms/linux64GccDPOpt/lib/libmyIncompressibleTransportModels.so"
#8  Foam::viscosityModels::powerLawTemp2::calcNu() const in "/home/OpenFOAM/2.3.0/platforms/linux64GccDPOpt/lib/libmyIncompressibleTransportModels.so"
#9  Foam::viscosityModels::powerLawTemp2::correct() in "/home/OpenFOAM/2.3.0/platforms/linux64GccDPOpt/lib/libmyIncompressibleTransportModels.so"
#10  Foam::incompressibleTwoPhaseMixture::calcNu() in "/home/OpenFOAM/2.3.0/platforms/linux64GccDPOpt/lib/libmyIncompressibleTransportModels.so"
#11  
 at /projects/OpenFOAM/OpenFOAM-2.3.0/src/OpenFOAM/lnInclude/Switch.H:187
#12  __libc_start_main in "/lib64/libc.so.6"
#13  
 in "/home/OpenFOAM/2.3.0/platforms/linux64GccDPOpt/bin/interTempFoamV2"
Allrun.sh: line 8: 17499 Floating point exceptioninterTempFoamV2 > log.txt

I can see errors are coming from the calcNu() function but I cant figure out why. Would really appreciate some help if anyone has experience dealing with this before.

Regards
shikamaru is offline   Reply With Quote

Old   November 8, 2014, 10:20
Default
  #2
Senior Member
 
Joachim Herb
Join Date: Sep 2010
Posts: 650
Rep Power: 22
jherb is on a distinguished road
The error message shows that the problem is somehow related to the exp() function call. So search this site for help:
https://www.google.de/search?q=site%...foam+%22exp%22
Here are two threads, which might help:
http://www.cfd-online.com/Forums/ope...t-working.html
http://www.cfd-online.com/Forums/ope...ut-scalar.html
jherb is offline   Reply With Quote

Old   November 8, 2014, 19:37
Default
  #3
New Member
 
Nara Shikamaru
Join Date: Apr 2012
Posts: 22
Rep Power: 14
shikamaru is on a distinguished road
Thank you for the references, I will look them up.
shikamaru is offline   Reply With Quote

Old   January 6, 2015, 02:47
Exclamation Error while building a new viscosity model..
  #4
Senior Member
 
Himanshu Sharma
Join Date: Jul 2012
Posts: 101
Rep Power: 14
himanshu28 is on a distinguished road
Hi ,
I am trying to built a new viscosity model based on some scalar like alpha(concentration),T (Temperature)
I have tried the following approach given below
Code:
/*---------------------------------------------------------------------------*\
  =========                 |
  \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
   \\    /   O peration     |
    \\  /    A nd           | Copyright (C) 2011 OpenFOAM Foundation
     \\/     M anipulation  |
-------------------------------------------------------------------------------
License
    This file is part of OpenFOAM.

    OpenFOAM is free software: you can redistribute it and/or modify it
    under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
    ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
    for more details.

    You should have received a copy of the GNU General Public License
    along with OpenFOAM.  If not, see <http://www.gnu.org/licenses/>.

\*---------------------------------------------------------------------------*/

#include "alphaTLaw.H"
#include "addToRunTimeSelectionTable.H"
#include "surfaceFields.H"

// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //

namespace Foam
{
namespace viscosityModels
{
    defineTypeNameAndDebug(alphaTLaw, 0);

    addToRunTimeSelectionTable
    (
        viscosityModel,
        alphaTLaw,
        dictionary
    );
}
}


// * * * * * * * * * * * * Private Member Functions  * * * * * * * * * * * * //

Foam::tmp<Foam::volScalarField>
Foam::viscosityModels::alphaTLaw::calcNu() const
{
const volScalarField& T = U_.mesh().lookupObject<volScalarField>("T");
const volScalarField& alpha = U_.mesh().lookupObject<volScalarField>("alpha");


        return ((1/Re_)*exp(alpha*(ln(m_))-T));


}
// * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //

Foam::viscosityModels::alphaTLaw::alphaTLaw
(
    const word& name,
    const dictionary& viscosityProperties,
    const volVectorField& U,
    const surfaceScalarField& phi
)
:
    viscosityModel(name, viscosityProperties, U, phi),
    //alphaTLawCoeffs_(viscosityProperties.subDict(typeName + "Coeffs")),
    Re_(alphaTLawCoeffs_.lookup("Re")),
    m_(alphaTLawCoeffs_.lookup("m")),
    //nuMin_(alphaTLawCoeffs_.lookup("nuMin")),
    //nuMax_(alphaTLawCoeffs_.lookup("nuMax")),

    nu_
    (
        IOobject
        (
            name,
            U_.time().timeName(),
            U_.db(),
            IOobject::NO_READ,
            IOobject::AUTO_WRITE
        ),
        calcNu()
    )
{}

// * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * * //

bool Foam::viscosityModels::alphaTLaw::read
(
    const dictionary& viscosityProperties
)
{
    viscosityModel::read(viscosityProperties);

    alphaTLawCoeffs_ = viscosityProperties.subDict(typeName + "Coeffs");

    alphaTLawCoeffs_.lookup("Re") >> Re_;
    alphaTLawCoeffs_.lookup("m") >> m_;
    //alphaTLawCoeffs_.lookup("nuMin") >> nuMin_;
    //alphaTLawCoeffs_.lookup("nuMax") >> nuMax_;

    return true;
}


// ************************************************************************* //
But I am getting following error in wmake libso.

Code:
Making dependency list for source file alphaTLaw.C
SOURCE=alphaTLaw.C ;  g++ -m64 -Dlinux64 -DWM_DP -Wall -Wextra -Wno-unused-parameter -Wold-style-cast -Wnon-virtual-dtor -O3  -DNoRepository -ftemplate-depth-100 -I/home/himanshu/OpenFOAM/OpenFOAM-2.3.0/src/transportModels/incompressible/lnInclude/ -I.. -I../twoPhaseMixture/lnInclude -I/home/himanshu/OpenFOAM/OpenFOAM-2.3.0/src/finiteVolume/lnInclude -IlnInclude -I. -I/home/himanshu/OpenFOAM/OpenFOAM-2.3.0/src/OpenFOAM/lnInclude -I/home/himanshu/OpenFOAM/OpenFOAM-2.3.0/src/OSspecific/POSIX/lnInclude   -fPIC -c $SOURCE -o Make/linux64GccDPOpt/alphaTLaw.o
alphaTLaw.C: In member function ‘Foam::tmp<Foam::GeometricField<double, Foam::fvPatchField, Foam::volMesh> > Foam::viscosityModels::alphaTLaw::calcNu() const’:
alphaTLaw.C:57:33: error: invalid initialization of reference of type ‘const Foam::fileName&’ from expression of type ‘const dimensionedScalar {aka const Foam::dimensioned<double>}’
  return ((1/Re_)*exp(alpha*ln(m_)-T));
                                 ^
In file included from /home/himanshu/OpenFOAM/OpenFOAM-2.3.0/src/OpenFOAM/lnInclude/regIOobject.H:43:0,
                 from /home/himanshu/OpenFOAM/OpenFOAM-2.3.0/src/OpenFOAM/lnInclude/GeometricField.H:42,
                 from /home/himanshu/OpenFOAM/OpenFOAM-2.3.0/src/OpenFOAM/lnInclude/GeometricScalarField.H:38,
                 from /home/himanshu/OpenFOAM/OpenFOAM-2.3.0/src/OpenFOAM/lnInclude/GeometricFields.H:34,
                 from /home/himanshu/OpenFOAM/OpenFOAM-2.3.0/src/finiteVolume/lnInclude/volFields.H:37,
                 from alphaTLaw.H:40,
                 from alphaTLaw.C:26:
/home/himanshu/OpenFOAM/OpenFOAM-2.3.0/src/OpenFOAM/lnInclude/OSspecific.H:170:6: error: in passing argument 1 of ‘bool Foam::ln(const Foam::fileName&, const Foam::fileName&)’
 bool ln(const fileName& src, const fileName& dst);
      ^
alphaTLaw.C:60:1: warning: control reaches end of non-void function [-Wreturn-type]
 }
 ^
make: *** [Make/linux64GccDPOpt/alphaTLaw.o] Error 1
I not getting any clue why the following error in Bold is appearing.
Thank you
Regards
himanshu28 is offline   Reply With Quote

Reply

Tags
non-newtonian, openfoam, power-low, 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 Off
Trackbacks are Off
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
UDF for Temperature Dependent Energy Source er.mkumar Fluent UDF and Scheme Programming 9 March 14, 2024 05:01
Calculation of the Governing Equations Mihail CFX 7 September 7, 2014 07:27
Temperature dependent material properties stuart230588 CFX 1 November 21, 2013 17:36
Temperature dependent propertys and finalIteration in chtMultiRegionFoam waiter120 OpenFOAM 0 February 20, 2013 06:22
Viscosity - power law HOC Main CFD Forum 1 January 15, 2003 16:17


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