|
[Sponsors] |
New viscosity model with an "if/else" condition on the strain rate. |
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
March 17, 2017, 05:39 |
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 |
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. |
|
March 17, 2017, 12:47 |
|
#2 |
Senior Member
Sergei
Join Date: Dec 2009
Posts: 261
Rep Power: 21 |
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_) { ... Code:
if (sr() < List<dimensionedScalar>(sr().size(), tau0_/nu0_)) { ... Code:
forAll(sr(), i) { if (sr()[i] < tau0_/nu0_) { ... Last edited by Zeppo; March 17, 2017 at 15:11. |
|
March 17, 2017, 14:18 |
|
#3 |
Member
Emery
Join Date: Feb 2017
Location: France.
Posts: 33
Rep Power: 9 |
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. |
|
March 17, 2017, 15:12 |
|
#4 |
Senior Member
Sergei
Join Date: Dec 2009
Posts: 261
Rep Power: 21 |
Code:
if (sr() < List<dimensionedScalar>(sr().size(), tau0_/nu0_)) { ... |
|
February 27, 2020, 14:09 |
|
#5 | |
New Member
tooran
Join Date: Nov 2016
Posts: 23
Rep Power: 9 |
Quote:
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? |
||
February 27, 2020, 14:12 |
|
#6 |
New Member
tooran
Join Date: Nov 2016
Posts: 23
Rep Power: 9 |
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 |
|
March 28, 2020, 09:14 |
|
#7 |
Senior Member
Sergei
Join Date: Dec 2009
Posts: 261
Rep Power: 21 |
Code:
if (sr() < List<scalar>(sr().size(), gama_)) { |
|
March 29, 2020, 18:15 |
|
#8 |
New Member
tooran
Join Date: Nov 2016
Posts: 23
Rep Power: 9 |
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. |
|
March 29, 2020, 18:45 |
|
#9 |
Senior Member
Sergei
Join Date: Dec 2009
Posts: 261
Rep Power: 21 |
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) ); } |
|
March 29, 2020, 18:57 |
|
#10 | |
New Member
tooran
Join Date: Nov 2016
Posts: 23
Rep Power: 9 |
Quote:
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 |
||
Thread Tools | Search this Thread |
Display Modes | |
|
|
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 |