|
[Sponsors] |
May 2, 2011, 13:06 |
Time dependent properties
|
#1 |
Member
Michael Rangitsch
Join Date: Mar 2009
Location: Midland, Michigan, USA
Posts: 31
Rep Power: 17 |
Hi all,
I need to implement a time dependent viscosity -- my fluid viscosity increases as time advances. I can't convince the viscosity models to access the run time (says runTime is out of scope). I'm not a good c++ programmer, does anyone have some guidance on how to implement something like this? Thanks in advance! Mike Rangitsch |
|
May 2, 2011, 13:11 |
|
#2 |
Senior Member
Martin
Join Date: Oct 2009
Location: Aachen, Germany
Posts: 255
Rep Power: 22 |
Hi Michael,
you might have a look to my proposal in this thread: http://www.cfd-online.com/Forums/ope...time-loop.html There is access to the current time step... Martin |
|
May 3, 2011, 09:13 |
|
#3 |
Senior Member
Martin
Join Date: Oct 2009
Location: Aachen, Germany
Posts: 255
Rep Power: 22 |
Hi Mike,
just out of curiosity, could post your viscosity model? It just came to my mind that not the run time is the important feature for your viscosity model, but the residential time in your fluid domain... this would imply to calculate an aging process of the fluid. Since "old" fluid near an outlet would get another viscosity than "fresh" fluid from an inlet... Martin |
|
May 9, 2011, 11:21 |
Time dependent viscosity....
|
#4 |
Member
Michael Rangitsch
Join Date: Mar 2009
Location: Midland, Michigan, USA
Posts: 31
Rep Power: 17 |
Hi Martin,
Sorry for the delay. Unfortunately I can't share the viscosity model (customer says no). You're right, it is about the age of the fluid. The viscosity behavior changes as it ages. I'd like one more piece of advice, though. I'd like to save the viscosity and shearRate fields during the calculations and then use the previous iterations' values to under-relax the viscosity I put into the main iteration loop. I can create a field (viscosity_old), but I can't figure out how to access it from the viscosity calculation code (again, it complains about not being in scope). I'm also not sure where to put the read/write of the viscosity values. If I do it before the PISO loop (in interFoam), at least it seems to read in the viscosity values I specify (but won't write the shearRate field), if I put it just before the runtime.Write statement it fails... Any suggestions? |
|
May 10, 2011, 06:22 |
|
#5 |
Senior Member
Martin
Join Date: Oct 2009
Location: Aachen, Germany
Posts: 255
Rep Power: 22 |
Hi Mike,
this is how I would start: - Adding residential time as a volScalarField to interFoam. So in createFields.H you add Code:
// check if age exists switch ageExist(false); IOobject ageHeader ( "age", runTime.timeName(), mesh, IOobject::NO_READ ); volScalarField* age; if (ageHeader.headerOk()) { ageExist = true; Info<< "Reading field age\n" << endl; age = new volScalarField ( IOobject ( "age", runTime.timeName(), mesh, IOobject::MUST_READ, IOobject::AUTO_WRITE ), mesh ); } A transport equation for the residential time must be solved, for example after UEqn.H: Code:
if (ageExists) { fvScalarMatrix ageEqn ( fvm::ddt(*age) + fvm::div(phi, *age) - fvm::laplacian(turbulence->nuEff(), *age) == dimensionedScalar("ageSource", *age.dimensions()*dimensionSet(0,0,-1,0,0), runTime.deltaT().value()) //dimensionedScalar("ageSource", (*age).dimensions()*dimensionSet(0,0,-1,0,0), 1) // steady state ); ageEqn.solve(); } Code:
const volScalarField& residenceTime = U_.mesh().lookupObject<volScalarField>("age"); Code:
if (runTime.outputTime()) # include "write.H" The file "write.H" can look like this: Code:
{ volScalarField shearRate ( IOobject ( "shearRate", runTime.timeName(), mesh, IOobject::NO_READ, IOobject::AUTO_WRITE ), mag(fvc::grad(U)) ); shearRate.write(); volScalarField strainRate ( IOobject ( "strainRate", runTime.timeName(), mesh, IOobject::NO_READ, IOobject::AUTO_WRITE ), Foam::sqrt(2.0)*mag(symm(fvc::grad(U))) ); strainRate.write(); volScalarField nu ( IOobject ( "nu", runTime.timeName(), mesh, IOobject::NO_READ, IOobject::AUTO_WRITE ), twoPhaseProperties.nu() ); nu.write(); } I would not do an underrelaxation of the viscosity. It doesn't seems useful for me for a PISO algorithm, it seems to be even wrong... so you don't need an viscosity_old field, I suppose. If you do need it for some other reasons, you can define in createFields.H at the end of the file: Code:
volScalarField viscosity_old ( IOobject ( "visco_old", runTime.timeName(), mesh, IOobject::NO_READ, IOobject::AUTO_WRITE ), twoPhaseProperties.nu() ); Code:
visco_old == twoPhaseProperties.nu(); Martin |
|
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Transient simulation not converging | skabilan | OpenFOAM Running, Solving & CFD | 14 | December 17, 2019 00:12 |
How to write k and epsilon before the abnormal end | xiuying | OpenFOAM Running, Solving & CFD | 8 | August 27, 2013 16:33 |
Full pipe 3D using icoFoam | cyberbrain | OpenFOAM | 4 | March 16, 2011 10:20 |
Differences between serial and parallel runs | carsten | OpenFOAM Bugs | 11 | September 12, 2008 12:16 |
Modeling in micron scale using icoFoam | m9819348 | OpenFOAM Running, Solving & CFD | 7 | October 27, 2007 01:36 |