|
[Sponsors] |
September 15, 2021, 20:26 |
Error in compiling new viscosity model
|
#1 | |
Member
Venkat Ganesh
Join Date: May 2020
Location: Cincinnati, Ohio
Posts: 49
Rep Power: 5 |
Hey I'm trying to compile a new viscosity model (the equation is attached in the image).
I'm modifying the cross power law model and changing the calcNu() function as below. Code:
Foam::tmp<Foam::volScalarField> Foam::viscosityModels::APL::calcNu() const { if (strainRate() <= 0) { return pow(pow(mu0_,p_)+pow(K_*pow(scalar(0.00000000001),(n_-1)),p_),pow(p_,-1))/density_; } else { return pow(pow(mu0_,p_)+pow(K_*pow(dimensionedScalar("one", dimTime, 1.0)*strainRate(),(n_-1)),p_),pow(p_,-1))/density_; } } The issue I'm facing is that I don't understand how to implement the if loop for the volVectorField of strainRate and I'm getting the below error. Could someone suggest a workaround or way to do this? Quote:
|
||
September 16, 2021, 05:52 |
|
#2 | |
New Member
Mathias Poulsen
Join Date: Feb 2018
Location: Denmark
Posts: 9
Rep Power: 8 |
Hi.
From the error you can see that you are trying compare an entire field to a single integer value. One way to solve the problem is to use neg0 and pos to differentiate between the negative and positive strain rate. Code:
Foam::viscosityModels::APL::calcNu() const { const volScalarField& sRate = strainRate(); return( neg0(sRate) * ( pow(pow(mu0_,p_)+pow(K_*pow(scalar(0.00000000001),(n_-1)),p_),pow(p_,-1))/density_ ) * pos(sRate)* ( pow(pow(mu0_,p_)+pow(K_*pow(dimensionedScalar("one", dimTime, 1.0)*sRate,(n_-1)),p_),pow(p_,-1))/density_ ) ); } Mathias Quote:
|
||
September 16, 2021, 13:04 |
|
#3 | |
Member
Venkat Ganesh
Join Date: May 2020
Location: Cincinnati, Ohio
Posts: 49
Rep Power: 5 |
Quote:
I compiled the code as below and identified that the issue is when the strain rate values are 0. All I need right now is a way to replace the strain rate by a very small positive value (say 1.0E-17) in the equation wherever it is 0. Code:
Foam::tmp<Foam::volScalarField> Foam::viscosityModels::APL::calcNu() const { return pow(pow(mu0_,p_)+pow(K_*pow(dimensionedScalar("one", dimTime, 1.0)*strainRate(),(n_-1)),p_),pow(p_,-1))/density_; } |
||
September 16, 2021, 13:30 |
|
#4 |
New Member
Mathias Poulsen
Join Date: Feb 2018
Location: Denmark
Posts: 9
Rep Power: 8 |
You should be able to use:
Code:
return pow(pow(mu0_,p_)+pow(K_*pow(dimensionedScalar("one", dimTime, 1.0)*max(strainRate(),vSmall),(n_-1)),p_),pow(p_,-1))/density_; |
|
September 16, 2021, 14:46 |
|
#5 |
Member
Venkat Ganesh
Join Date: May 2020
Location: Cincinnati, Ohio
Posts: 49
Rep Power: 5 |
Thanks a lot. I just had to replace vSmall with a dimensionedscalar with the units of strainrate and it's running perfectly.
|
|
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
[IHFOAM] The IHFOAM Thread | Phicau | OpenFOAM Community Contributions | 392 | September 8, 2023 18:10 |
interFoam wave propagation and explosion of Courant number and residuals | ChiaraViola | OpenFOAM Running, Solving & CFD | 1 | June 26, 2019 05:36 |
New Viscosity Model - Best Practice for Temporary Values | MaSch | OpenFOAM Programming & Development | 6 | March 16, 2018 03:51 |
Using a new implemented viscosity model with simpleFoam | TemC | OpenFOAM Running, Solving & CFD | 6 | March 8, 2017 03:07 |
Time constant in Herschel-Bulkley viscosity model | Mikel6 | Main CFD Forum | 0 | October 17, 2016 04:52 |