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

New viscosity model with an "if/else" condition on the strain rate.

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

Like Tree2Likes
  • 1 Post By Zeppo
  • 1 Post By Zeppo

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   March 17, 2017, 05:39
Default New viscosity model with an "if/else" condition on the strain rate.
  #1
Member
 
Emery
Join Date: Feb 2017
Location: France.
Posts: 33
Rep Power: 9
TemC is on a distinguished road
Morning foamers,

I hope you are all doing well...

I'm trying to adapt the Herschel-Bulkley viscosity model available in OpenFoam.

Basically the original model (attachment 1) states:

" apparentViscosity = min (nu0_, (k_^n + tau0_)/strainRate) "


What I want to do is the following :

" if (strainRate < tau0_/nu0_)
apparentViscosity = nu0_
else
apparentViscosity = (k_^n + tau0_)/strainRate
"

Attachment 2 shows how I'am currently trying to implement it.

When trying to execute the "wmake libso" command, I got the message described in Attachments 3 and 4.

Obvioulsly there is something that I haven't understood yet, but I don't know what.

Any comment/suggestion about what may be uncorrect?

Thanks in advance and have a nice weekend.

Regards.
Attached Images
File Type: png original_HB_model.PNG (45.2 KB, 35 views)
File Type: png adapted_HB_model.PNG (51.3 KB, 33 views)
File Type: jpg Simulation_Message_Part1.jpg (194.0 KB, 31 views)
File Type: jpg Simulation_Message_Part2.jpg (181.7 KB, 18 views)
TemC is offline   Reply With Quote

Old   March 17, 2017, 12:47
Default
  #2
Senior Member
 
Zeppo's Avatar
 
Sergei
Join Date: Dec 2009
Posts: 261
Rep Power: 21
Zeppo will become famous soon enough
First of all please post your code as text not screenshots to save us some efforts in copying/editing it in our replies.

The error localizes in this line
Code:
if (sr() < tau0_/nu0_)
{
    ...
Replace it with
Code:
if (sr() < List<dimensionedScalar>(sr().size(), tau0_/nu0_))
{
    ...
or
Code:
forAll(sr(), i)
{
    if (sr()[i] < tau0_/nu0_)
    {
        ...
https://cpp.openfoam.org/v3/a07619_source.html
Farid likes this.

Last edited by Zeppo; March 17, 2017 at 15:11.
Zeppo is offline   Reply With Quote

Old   March 17, 2017, 14:18
Default
  #3
Member
 
Emery
Join Date: Feb 2017
Location: France.
Posts: 33
Rep Power: 9
TemC is on a distinguished road
Sir thank you very much for your reply

I made the modifications as you suggested. The first attachment is my file ''newModel.C" . The second one is the new message I get while trying to compile. Should I change another line of code?

Thanks again for time.

Regards.
Attached Images
File Type: jpg Compilation_Message.jpg (136.0 KB, 18 views)
Attached Files
File Type: c ImpHerschelBulkley.C (3.9 KB, 17 views)
TemC is offline   Reply With Quote

Old   March 17, 2017, 15:12
Default
  #4
Senior Member
 
Zeppo's Avatar
 
Sergei
Join Date: Dec 2009
Posts: 261
Rep Power: 21
Zeppo will become famous soon enough
Code:
if (sr() < List<dimensionedScalar>(sr().size(), tau0_/nu0_))
{
    ...
Zeppo is offline   Reply With Quote

Old   February 27, 2020, 14:09
Default
  #5
New Member
 
tooran
Join Date: Nov 2016
Posts: 23
Rep Power: 9
tooran is on a distinguished road
Quote:
Originally Posted by Zeppo View Post
First of all please post your code as text not screenshots to save us some efforts in copying/editing it in our replies.

The error localizes in this line
Code:
if (sr() < tau0_/nu0_)
{
    ...
Replace it with
Code:
if (sr() < List<dimensionedScalar>(sr().size(), tau0_/nu0_))
{
    ...
or
Code:
forAll(sr(), i)
{
    if (sr()[i] < tau0_/nu0_)
    {
         ...
https://cpp.openfoam.org/v3/a07619_source.html

















Hi,
I want to change the HerschelBulkley viscosity model . I want to add a if-condition as follows:
if strain rate is greater than gama (gama is a variable which read from the input) then calculate viscosity according to ....
so I write the following code :


//*************************************

if (sr() < List<dimensionedScalar>(sr().size(), gama_))
{
return...






MyHerschelBulkley.C

MyHerschelBulkley.HMyHerschelBulkley.C

MyHerschelBulkley.H





When I write "wmake libso" it shows me the following error :


error: no match for ‘operator<’ (operand types are ‘const Foam::GeometricField<double, Foam::fvPatchField, Foam::volMesh>’ and ‘Foam::List<Foam::dimensioned<double> >’)
if (sr() < List<dimensionedScalar>(sr().size(), gama_))





Could you please help me?
tooran is offline   Reply With Quote

Old   February 27, 2020, 14:12
Default
  #6
New Member
 
tooran
Join Date: Nov 2016
Posts: 23
Rep Power: 9
tooran is on a distinguished road
Hi,
I want to change the HerschelBulkley viscosity model . I want to add a if-condition as follows:
if strain rate is greater than gama (gama is a variable which read from the input) then calculate viscosity according to ....
so I write the following code :


//*************************************

if (sr() < List<dimensionedScalar>(sr().size(), gama_))
{
return...









When I write "wmake libso" it shows me the following error :


error: no match for ‘operator<’ (operand types are ‘const Foam::GeometricField<double, Foam::fvPatchField, Foam::volMesh>’ and ‘Foam::List<Foam::dimensioned<double> >’)
if (sr() < List<dimensionedScalar>(sr().size(), gama_))





Could you please help me?


MyHerschelBulkley.C

MyHerschelBulkley.H
tooran is offline   Reply With Quote

Old   March 28, 2020, 09:14
Default
  #7
Senior Member
 
Zeppo's Avatar
 
Sergei
Join Date: Dec 2009
Posts: 261
Rep Power: 21
Zeppo will become famous soon enough
Code:
if (sr() < List<scalar>(sr().size(), gama_))
{
tooran likes this.
Zeppo is offline   Reply With Quote

Old   March 29, 2020, 18:15
Default
  #8
New Member
 
tooran
Join Date: Nov 2016
Posts: 23
Rep Power: 9
tooran is on a distinguished road
Thanks for your comment
I used your words and add following lines.

tmp<volScalarField> tmpEtat = min(
nu0_,
(tau0_ + k_*rtone*pow(tone*sr(), n_))
/(max(sr(), dimensionedScalar ("vSmall", dimless/dimTime, VSMALL)))
);


forAll (sr(), cellI) //loop through cell centres


if (sr() < List<scalar>(sr().size(), gama_.value()))
{


tmpEtat.ref()[cellI] =
min
(
nu0_.value(),
(tau0_.value() + k_.value()*rtone.value()*pow(tone.value()*sr.ref()[cellI], n_.value()))
/(max(sr()[cellI], 0.0002))
);
}

else {
tmpEtat.ref()[cellI] =
min
(
nu0_.value(),
(tau0ll_.value() + kll_.value()*rtone.value()*pow(tone.value()*sr.ref ()[cellI], n_.value()))
/(max(sr()[cellI], 0.0002))
);
}


return tmpEtat;


The library compiled but the results are strange at the outlet boundary.
tooran is offline   Reply With Quote

Old   March 29, 2020, 18:45
Default
  #9
Senior Member
 
Zeppo's Avatar
 
Sergei
Join Date: Dec 2009
Posts: 261
Rep Power: 21
Zeppo will become famous soon enough
Go for this:
Code:
forAll(sr(), cellI)
{
    tmpEtat.ref()[cellI] = min
    (
        nu0_.value(),
        tau0_.value() +
        (sr()[cellI] < gama_.value() ? k_.value() : kll_.value())
      * rtone.value()*pow(tone.value()*sr.ref()[cellI], n_.value())
      / max(sr()[cellI], 0.0002)
    );
}
Zeppo is offline   Reply With Quote

Old   March 29, 2020, 18:57
Default
  #10
New Member
 
tooran
Join Date: Nov 2016
Posts: 23
Rep Power: 9
tooran is on a distinguished road
Quote:
Originally Posted by Zeppo View Post
Go for this:
Code:
forAll(sr(), cellI)
{
    tmpEtat.ref()[cellI] = min
    (
        nu0_.value(),
        tau0_.value() +
        (sr()[cellI] < gama_.value() ? k_.value() : kll_.value())
      * rtone.value()*pow(tone.value()*sr.ref()[cellI], n_.value())
      / max(sr()[cellI], 0.0002)
    );
}


Thanks for your replying ,But I should use tau0_ll too.
I think the code does not aply zero geadient condition for tmpEta at outlet
tooran is offline   Reply With Quote

Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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
Discrete Phase Model, outlet mass flow rate does not fit edu_aero FLUENT 29 February 3, 2020 09:38
Adding new temperature dependent viscosity model vabishek OpenFOAM Programming & Development 3 May 15, 2016 22:05
Wrong flow in ratating domain problem Sanyo CFX 17 August 15, 2015 07:20
Superlinear speedup in OpenFOAM 13 msrinath80 OpenFOAM Running, Solving & CFD 18 March 3, 2015 06:36
Power - Law Viscosity Model for Polymers NickolasPl OpenFOAM 2 August 12, 2011 09:26


All times are GMT -4. The time now is 20:13.