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

How to implement non-Newtonian fluid behaviour in sonicLiquidFoam

Register Blogs Community New Posts Updated Threads Search

Like Tree1Likes
  • 1 Post By user_of_cfx

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   November 30, 2015, 11:06
Default How to implement non-Newtonian fluid behaviour in sonicLiquidFoam
  #1
Member
 
Christa
Join Date: Apr 2011
Posts: 53
Rep Power: 15
user_of_cfx is on a distinguished road
Hi,

I am trying to set up a simulation which can model a fluid which is:

- non-Newtonian liquid (specifically pseudoplastic fluid)
- compressible (I am interested in the pressure waves traveling up and down the domain)

From what I can see, there is no compressible non Newtonian single phase model within OF. The closest I can find is sonicLiquidFoam. The file structure looks pretty straightforward to me. Essentially it looks like the only thing I need to change is to make mu from a scalar to a volScalarField calcMu() -calculated by my viscosity model of choice- and maybe also modify the mu term of the UEqn?

fvVectorMatrix UEqn
(
fvm::ddt(rho, U)
+ fvm::div(phi, U)
- fvm::laplacian(mu, U)
);


As I am a complete novice in OF and C++, any advice, links, resources, tips, tricks and information of any kind will be greatly appreciated.

Many thanks,

Christa
user_of_cfx is offline   Reply With Quote

Old   November 30, 2015, 13:51
Default
  #2
Member
 
ali alkebsi
Join Date: Jan 2012
Location: Strasbourg, France
Posts: 82
Rep Power: 14
kebsiali is on a distinguished road
Hello

I think the choice of the solver to use depends on the case you try to reproduce
a list of compressible Solvers available within openfoam is provided in this link
http://www.openfoam.org/features/standard-solvers.php

there are many viscosity models and these can be chosen from within the case folder, available in the following link

http://www.openfoam.org/features/transport.php

in case you want to create your own viscosity model or rheology law this has nothing to do with the solver itself
you need to create a new viscosity class in the libraries
this can be cleared out following this link
http://www.tfd.chalmers.se/~hani/kur...nFoam%20v2.pdf
kebsiali is offline   Reply With Quote

Old   December 1, 2015, 04:57
Default
  #3
Member
 
Christa
Join Date: Apr 2011
Posts: 53
Rep Power: 15
user_of_cfx is on a distinguished road
Hi Ali,

Thank you very much for replying to me. I have done quite a bit of research and so far I can run a compressible Newtonian fluid case using rhoPimpleFoam and sonicLiquidFoam, and I have successfully implemented my own transport model (Bingham plastic) in nonNewtonianIcoFoam.

My problem is that all transport models are available for incompressible flows, but what I want to model is very clearly a compressible flow, and assuming incompressibility will just not work.

I believe sonicLiquidFoam is exactly the base solver I need for what I am trying to do, but I need some advice on how to implement the transport models, which are so far only available for incompressible solvers, into the compressible sonicLiquidFoam model.

To be a bit more precise, here is a list of the challenges I am trying to figure out:

1. How can I change mu from a scalar to a volScalarField for use with sonicLiquidFoam?
2. Are there any modifications I need to make to the transport model H and C files so it will run with compressible solvers?
3. How to link the transport model to the compressible solver. i.e. is it enough to include the right header files, or are there more modifications required?

I am currently reading through this document:
http://foam.sourceforge.net/docs/Gui...mmersGuide.pdf

but my limited knowledge of C++ makes this a bit hard for me.

Thanks,

Christa

Edit: I dug around and found this base class for compressible transport models:
https://github.com/OpenFOAM/OpenFOAM...s/compressible
Looks like a good place to start. Still, any help will be appreciated. Cheers, C
user_of_cfx is offline   Reply With Quote

Old   December 10, 2015, 08:47
Default
  #4
Member
 
Christa
Join Date: Apr 2011
Posts: 53
Rep Power: 15
user_of_cfx is on a distinguished road
In case anyone wondered, it was quite easy to implement after all.

I modified sonicLiquidFoam.C to call a function fluid.mu() instead of a single scalar mu, with fluid being defined within createFields.H. The dynamic viscosity is calculated in a function calcMu(). I used the SinglePhaseTransportModel.H as guide to build my compessible version (which I imaginatively called compressibleSinglePhaseTransportModel.H) as well as the necessary transportModel and viscosityModel classes and individual vicosity models (I created a Bingham plastic for a start).

So long as one follows the right folder structure for the classes and the Make files and options, which can be found here, it is just a matter of making the relevant changes (such as using dynamic instead of kinematic viscosity) and modifying the units accordingly.

This is what the new solver code looks like:

Code:
#include "fvCFD.H"
#include "pimpleControl.H"
#include "compressibleSinglePhaseTransportModel.H" 

// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

int main(int argc, char *argv[])
{
    #include "setRootCase.H"
    #include "createTime.H"
    #include "createMesh.H"

    pimpleControl pimple(mesh);

    #include "readThermodynamicProperties.H"
  //"readTransportProperties.H"
    #include "createFields.H"
    #include "initContinuityErrs.H"

    // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

    Info<< "\nStarting time loop\n" << endl;

    while (runTime.loop())
    {
        Info<< "Time = " << runTime.timeName() << nl << endl;

        #include "readTimeControls.H"
        #include "compressibleCourantNo.H"

        fluid.correct();

        solve(fvm::ddt(rho) + fvc::div(phi));

        // --- Pressure-velocity PIMPLE corrector loop
        while (pimple.loop())
        {
            fvVectorMatrix UEqn
            (
                fvm::ddt(rho, U)
              + fvm::div(phi, U)
              - fvm::laplacian(fluid.mu(), U)
            );

            solve(UEqn == -fvc::grad(p));

            // --- Pressure corrector loop
            while (pimple.correct())
            {
                volScalarField rAU("rAU", 1.0/UEqn.A());
                surfaceScalarField rhorAUf
                (
                    "rhorAUf",
                    fvc::interpolate(rho*rAU)
                );

                U = rAU*UEqn.H();

                surfaceScalarField phid
                (
                    "phid",
                    psi
                   *(
                       (fvc::interpolate(U) & mesh.Sf())
                     + rhorAUf*fvc::ddtCorr(rho, U, phi)/fvc::interpolate(rho)
                    )
                );

                phi = (rhoO/psi)*phid;

                fvScalarMatrix pEqn
                (
                    fvm::ddt(psi, p)
                  + fvc::div(phi)
                  + fvm::div(phid, p)
                  - fvm::laplacian(rhorAUf, p)
                );

                pEqn.solve();

                phi += pEqn.flux();

                solve(fvm::ddt(rho) + fvc::div(phi));
                #include "compressibleContinuityErrs.H"

                U -= rAU*fvc::grad(p);
                U.correctBoundaryConditions();
            }
        }

        rho = rhoO + psi*p;

        runTime.write();

        Info<< "ExecutionTime = " << runTime.elapsedCpuTime() << " s"
            << "  ClockTime = " << runTime.elapsedClockTime() << " s"
            << nl << endl;
    }

    Info<< "End\n" << endl;

    return 0;
}


// ************************************************************************* //
After doing this I thought it is incredibly easy, but that's not how I felt when I started. So don't be intimidated, there is enough information in the standard OF solvers to use as basis for most modification you may want to make.

Cheers,

Christa
sourav90 likes this.
user_of_cfx is offline   Reply With Quote

Old   October 18, 2018, 11:30
Default similar Problem but multiphase
  #5
New Member
 
Stefan
Join Date: Oct 2015
Posts: 24
Rep Power: 10
StefanW is on a distinguished road
Hi Christa,

good work you did here!

I am facing now a similar problem.
I want to implement nonNewtonian Fluids in a compressible multiphase solver (compressibleInterFoam) and so far my knowledge of C++ is still upgradable.

Therefore I want to ask if you would mind to publish the whole solver and openFoam parts you had to change.
So I could compare 1 by 1 to the original one you used and may understand what I have to change in the multiphase case.

Did you got any convergence probs with your solver?

It would be great if you could help!

Best Regards

Stefan
StefanW is offline   Reply With Quote

Reply


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
Setting rotating frame of referece. RPFigueiredo CFX 3 October 28, 2014 04:59
Overflow Error in Multiphase Modelling with Two Continuous Fluids ashtonJ CFX 6 August 11, 2014 14:32
Intl Conf Computational Methods in Fluid Power Jacek Stecki Main CFD Forum 0 November 10, 2002 05:49
My Revised "Time Vs Energy" Article For Review Abhi Main CFD Forum 2 July 9, 2002 09:08
Terrible Mistake In Fluid Dynamics History Abhi Main CFD Forum 12 July 8, 2002 09:11


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