|
[Sponsors] |
August 22, 2021, 16:48 |
Update Viscosity in every time step
|
#1 |
New Member
HH
Join Date: Apr 2019
Posts: 17
Rep Power: 7 |
Hi Foamers,
For an incompressible flow case using a solver based on pimpleFoam, i am trying to update kinematic viscosity (nu()) as a function of temperature. (OpenFOAM version v1806) I created a solver called ExpLaw using powerLaw as a reference. # Code: Foam::tmp<Foam::volScalarField> Foam::viscosityModels::ExpLaw::calcNu() const { const volScalarField& T = U_.mesh().lookupObject<volScalarField>("T"); return k_*exp(-n_*(T - Talpha_)); } # The model compiles and works in the first time step, where viscosity is being calculated using this new model. However, the model then doesn't update and shows the same values. Now, when i stop the simulation and restart it from the last recorded time step, the expLaw is accessed and it calculates the new viscosity values at the first time step. After that, in the consecutive time steps, it again does not update the viscosity. I have looked at a lot of different threads on this forum and spent days to solve this problem but cannot find a way to update the viscosity at each time step based on changes in the temperature field. Please help me solve this issue. i will really appreciate the help. Thanks in advance. Best, HH |
|
August 24, 2021, 03:12 |
|
#2 |
Senior Member
Michael Alletto
Join Date: Jun 2018
Location: Bremen
Posts: 615
Rep Power: 15 |
Did you check if the function is called every time step or not? you can do this by outputting something on the screen.
From the only function you send it is impossible to judge what may be the reason of the behavior of your viscosity model |
|
August 24, 2021, 08:37 |
|
#3 |
New Member
HH
Join Date: Apr 2019
Posts: 17
Rep Power: 7 |
Michael,
@mAlletto Thank you so much for you response. Appreciate you taking the time to help me. I output the values of viscosity using turbulence->nu() and that is how I realized that the values of viscosity are not being updated. I also used a print statement in the function ("entered loop") as you will see in the attached ExpLaw. I only see this print statement on screen at the beginning of the simulation and NOT in every time-step. 1. Are transport properties and viscosityModel called in every time-step or just at the beginning of the simulation? 2. Is there a way to call them in every time step? 3. How can i call the calcNu() function in my runtime loop? Currently, it is using this only in the first time step to calculate the initial nu(). I am attaching the code for ExpLaw for your reference. It is exactly same as the powerLaw except the return value which is now based on an exponential function. Please help me understand how the viscosityModel is called during the simulation and how can it be called at the beginning of each time step to update viscosity based on updated temperature. Thanks in advance. Best, HH |
|
August 27, 2021, 08:08 |
|
#4 |
Senior Member
Michael Alletto
Join Date: Jun 2018
Location: Bremen
Posts: 615
Rep Power: 15 |
Did you have a look at this tutorial: compressible/rhoSimpleFoam/squareBendLiqNoNewtonian/constant/turbulenceProperties
how looks your turbulenceProperties file like? |
|
August 27, 2021, 08:29 |
|
#5 |
Senior Member
Michael Alletto
Join Date: Jun 2018
Location: Bremen
Posts: 615
Rep Power: 15 |
To answer your questions:
TransprotProperties are evaluated at the beginning of the simulation for incompressbile solvers. In the com version you have also viscosity models in $FOAM_SRC/TurbulenceModels/turbulenceModels/laminar/generalizedNewtonian/generalizedNewtonianViscosityModels this are updated evey time step in the turbulence.correct() function |
|
August 27, 2021, 14:21 |
|
#6 |
New Member
HH
Join Date: Apr 2019
Posts: 17
Rep Power: 7 |
Michael,
Thank you for your response. Thanks for pointing me to this tutorial case. I haven't come across this in the past. I just checked my tutorial folder for v1806 and did not find it there. However, i did find it online. I will look at it in detail and try to replicate that for my model. On a side note, i did try another tutorial case and made many setting changes to realize that the nu was not changing and nut was changing when turbulence model was on. Is this how it is because no model was defined for nu in turbulenceProperties file? Extremely thankful for your help. This helps me a lot and gives me a direction to tackle my viscosity issue. I will try to make changes as per your recommendation and let you know how it goes. Thanks, HH |
|
August 27, 2021, 14:44 |
|
#7 |
New Member
HH
Join Date: Apr 2019
Posts: 17
Rep Power: 7 |
Michael,
My turbulenProperties file is simple: # FoamFile { version 2.0; format ascii; class dictionary; location "constant"; object turbulenceProperties; } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // simulationType laminar; # Thanks, HH |
|
August 27, 2021, 14:48 |
|
#8 |
Senior Member
Michael Alletto
Join Date: Jun 2018
Location: Bremen
Posts: 615
Rep Power: 15 |
Ok. Yes the tutorial is actually from OF2012. Maybe you should modify the turbulence property according to the tutorial
|
|
August 27, 2021, 14:52 |
|
#9 |
New Member
HH
Join Date: Apr 2019
Posts: 17
Rep Power: 7 |
Michael,
I will do so. I will first try to modify just the turbulenceProperties file. I wonder if the same works for incompressible flows, as the tutorial is for compressible flows. Thanks, HH |
|
August 29, 2021, 12:35 |
Update
|
#10 |
New Member
HH
Join Date: Apr 2019
Posts: 17
Rep Power: 7 |
Michael,
I tried following the execution of the code and made a few changes to the solver. I realized that this is the statement that calls viscosity model at the start of the simulation: singlePhaseTransportModel laminarTransport(U, phi); So i used this to call the viscosity model in every time step. I also has to updatd one portion in ExpLaw.H. I commented return nu_; and instead wrote: return calcNu() to call the function that calculated the nu based on temperature (calcNu() function is in ExpLaw.C file) # Code //- Return the laminar viscosity virtual tmp<volScalarField> nu() const { return calcNu(); //return nu_; } # These changes worked. Now i am able to update viscosity in every time step. Thanks so much for your help. Best, HH Last edited by user_HH; August 29, 2021 at 15:46. |
|
August 29, 2021, 13:18 |
|
#11 |
Senior Member
Michael Alletto
Join Date: Jun 2018
Location: Bremen
Posts: 615
Rep Power: 15 |
Nice you found a solution
|
|
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
AMI speed performance | danny123 | OpenFOAM | 21 | October 24, 2020 04:13 |
Setting up Lid driven Cavity Benchmark with 1M cells for multiple cores | puneet336 | OpenFOAM Running, Solving & CFD | 11 | April 7, 2019 00:58 |
High Courant Number @ icoFoam | Artex85 | OpenFOAM Running, Solving & CFD | 11 | February 16, 2017 13:40 |
Star cd es-ice solver error | ernarasimman | STAR-CD | 2 | September 12, 2014 00:01 |
Could anybody help me see this error and give help | liugx212 | OpenFOAM Running, Solving & CFD | 3 | January 4, 2006 18:07 |