|
[Sponsors] |
June 10, 2010, 06:14 |
Piecewise viscosity model
|
#1 |
Member
Jitao Liu
Join Date: Mar 2009
Location: Jinan , China
Posts: 64
Rep Power: 17 |
Dear foamers,
I'd like to create a piecewise viscosity model described as following: (1) when T<Tg, viscosity is equal to a constant: nu = nu0; (2) when T>=Tg, viscosity varies with temperature, pressure and strain rate: nu= (B_*exp(B1_*pd)*exp(Tb_/T))/(RHO_*(scalar(1)+pow((B_*exp(B1_*pd)*exp(Tb_/T))*strainRate()/t1_, scalar(1)-n_))); where B, B1, Tb, t1, n are material constants. How to define this piecewise function in calcNu() in user-defined viscosity model? Best regards, Jitao |
|
June 10, 2010, 07:12 |
|
#2 |
Member
Jitao Liu
Join Date: Mar 2009
Location: Jinan , China
Posts: 64
Rep Power: 17 |
The modefied NewCrossArrhenius.C:
#include "NewCrossArrhenius.H" //#include "twoPhaseMixture.H" #include "addToRunTimeSelectionTable.H" #include "surfaceFields.H" // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // namespace Foam { namespace viscosityModels { defineTypeNameAndDebug(NewCrossArrhenius, 0); addToRunTimeSelectionTable ( viscosityModel, NewCrossArrhenius, dictionary ); } } // * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * * // Foam::tmp<Foam::volScalarField> Foam::viscosityModels::NewCrossArrhenius::calcNu() const { const volScalarField& T=U_.mesh().lookupObject<volScalarField>("T"); const volScalarField& pd=U_.mesh().lookupObject<volScalarField>("pd"); forAll(T, cell) { if ( T [cell]<Tg_) return INF_; else return (B_*exp(B1_*pd)*exp(Tb_/T))/(RHO_*(scalar(1)+pow((B_*exp(B1_*pd)*exp(Tb_/T))*strainRate()/t1_, scalar(1)-n_))); } } // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // Foam::viscosityModels::NewCrossArrhenius::NewCross Arrhenius ( const word& name, const dictionary& viscosityProperties, const volVectorField& U, const surfaceScalarField& phi ) : viscosityModel(name, viscosityProperties, U, phi), NewCrossArrheniusCoeffs_(viscosityProperties.subDi ct(typeName + "Coeffs")), B_(NewCrossArrheniusCoeffs_.lookup("B")), B1_(NewCrossArrheniusCoeffs_.lookup("B1")), Tb_(NewCrossArrheniusCoeffs_.lookup("Tb")), t1_(NewCrossArrheniusCoeffs_.lookup("t1")), n_(NewCrossArrheniusCoeffs_.lookup("n")), RHO_(NewCrossArrheniusCoeffs_.lookup("RHO")), INF_(NewCrossArrheniusCoeffs_.lookup("INF")), Tg_(NewCrossArrheniusCoeffs_.lookup("Tg")), nu_ ( IOobject ( name, U_.time().timeName(), U_.db(), IOobject::NO_READ, IOobject::AUTO_WRITE ), calcNu() ) {} // * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * // bool Foam::viscosityModels::NewCrossArrhenius::read ( const dictionary& viscosityProperties ) { viscosityModel::read(viscosityProperties); NewCrossArrheniusCoeffs_ = viscosityProperties.subDict(typeName + "Coeffs"); NewCrossArrheniusCoeffs_.lookup("B") >> B_; NewCrossArrheniusCoeffs_.lookup("B1") >> B1_; NewCrossArrheniusCoeffs_.lookup("Tb") >> Tb_; NewCrossArrheniusCoeffs_.lookup("t1") >> t1_; NewCrossArrheniusCoeffs_.lookup("n") >> n_; NewCrossArrheniusCoeffs_.lookup("RHO") >> RHO_; NewCrossArrheniusCoeffs_.lookup("INF") >> INF_; NewCrossArrheniusCoeffs_.lookup("Tg") >> Tg_; return true; } // ************************************************** *********************** // The compilation of this visocosity model ended up with following errors : viscosityModels/NewCrossArrhenius/NewCrossArrhenius.C:81: error: no match for ‘operator<’ in ‘((const Foam::volScalarField*)T)->Foam::GeometricField<double,Foam::fvPatchField, Foam::volMesh>::<anonymous>.Foam:imensionedField <double, Foam::volMesh>::<anonymous>.Foam::Field<double>::< anonymous>.Foam::List<double>::<anonymous>.Foam::U List<T>:perator[] [with T = double](cell) < ((const Foam::viscosityModels::NewCrossArrhenius*)this)->Foam::viscosityModels::NewCrossArrhenius::Tg_’ viscosityModels/NewCrossArrhenius/NewCrossArrhenius.C:83: error: conversion from ‘const Foam::dimensionedScalar’ to non-scalar type ‘Foam::tmp<Foam::GeometricField<double, Foam::fvPatchField, Foam::volMesh> >’ requested |
|
June 11, 2010, 14:55 |
|
#3 |
New Member
Dan Gadensgaard
Join Date: Apr 2010
Posts: 13
Rep Power: 15 |
Hi..
I have just recently had similar problems in implementing a frozen layer. I did not succeed as it showed som strange results, however i did get a working compilation. When comparing a cell value (T[cell]) with a constant (Tg_) i found that it was neccessary to do it with the suffix .value() on the constant, as shown below: ... if ( T [cell]<Tg_.value()) ... Hope that works! |
|
June 22, 2010, 00:10 |
|
#4 | |
Member
Jitao Liu
Join Date: Mar 2009
Location: Jinan , China
Posts: 64
Rep Power: 17 |
Quote:
Thank you very much. I have compiled this Piecewise viscosity model. When running a case using this model, the calculation always stopped due divergence. And the claculated temperature field is strange. Have you successed in implementing the frozen layer? Please give me some suggections. Thanks in advance. Kind regards, Jitao |
||
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Implementing new viscosity model | prjohnston | OpenFOAM Running, Solving & CFD | 6 | July 3, 2015 05:26 |
Yielding viscosity for Herschel Bulkley model | Godwin | FLUENT | 1 | December 12, 2011 06:42 |
How to modify the viscosity model | mpml | OpenFOAM Running, Solving & CFD | 4 | October 13, 2010 08:44 |
about compresive phase | James | CFX | 10 | September 12, 2006 04:16 |
Frictional viscosity in granular model | Hp | FLUENT | 4 | June 1, 2004 21:42 |