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

Time dependent properties

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

Like Tree1Likes
  • 1 Post By MartinB

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   May 2, 2011, 13:06
Default Time dependent properties
  #1
Member
 
Michael Rangitsch
Join Date: Mar 2009
Location: Midland, Michigan, USA
Posts: 31
Rep Power: 17
mrangitschdowcom is on a distinguished road
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
mrangitschdowcom is offline   Reply With Quote

Old   May 2, 2011, 13:11
Default
  #2
Senior Member
 
Martin
Join Date: Oct 2009
Location: Aachen, Germany
Posts: 255
Rep Power: 22
MartinB will become famous soon enough
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
MartinB is offline   Reply With Quote

Old   May 3, 2011, 09:13
Default
  #3
Senior Member
 
Martin
Join Date: Oct 2009
Location: Aachen, Germany
Posts: 255
Rep Power: 22
MartinB will become famous soon enough
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
MartinB is offline   Reply With Quote

Old   May 9, 2011, 11:21
Default Time dependent viscosity....
  #4
Member
 
Michael Rangitsch
Join Date: Mar 2009
Location: Midland, Michigan, USA
Posts: 31
Rep Power: 17
mrangitschdowcom is on a distinguished road
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?
mrangitschdowcom is offline   Reply With Quote

Old   May 10, 2011, 06:22
Default
  #5
Senior Member
 
Martin
Join Date: Oct 2009
Location: Aachen, Germany
Posts: 255
Rep Power: 22
MartinB will become famous soon enough
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 new field with name "age" in your time folder must be inserted, i.e. "0/age". Boundary condition for inlet is fixedValue 0, rest of the patches get zeroGradient.

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();
}
Then derive your new viscosity model from one of the existing transportModels. Add the new coefficients to the yourNewTransportModel.H file, and read the values for them in the read() method of yourNewTransportModel.C. In the calcNu() method you have access to the time field with
Code:
    const volScalarField& residenceTime = U_.mesh().lookupObject<volScalarField>("age");
To write the fields of interest, make a new file "write.H" and call it like this
Code:
    if (runTime.outputTime())
#       include "write.H"
just before the runTime.write() call of interFoam.

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();
}
Depending on your version of OpenFOAM the definition of strainRate, which is used in the transportModels for shear thinning models, varies. Therefor to verify your implementation you should check your exact definition of strainRate.

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()
	);
and update it before calling twoPhaseProperties.correct(); in interFoam.C with
Code:
visco_old == twoPhaseProperties.nu();
Well, these hints are not tested, so use with care!

Martin
Roozbeh_Sa likes this.
MartinB 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
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


All times are GMT -4. The time now is 10:30.