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

Add a scalar "transport" equation to BuoyantBoussinesqPimpleFoam

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   June 2, 2017, 11:21
Default Add a scalar "transport" equation to BuoyantBoussinesqPimpleFoam
  #1
Member
 
Lilian Chabannes
Join Date: Apr 2017
Posts: 58
Rep Power: 9
Lookid is on a distinguished road
Hello everyone,

I'm trying to implement the calculation of a scalar "sumti" in BuoyantBoussinesqPimpleFoam

The goal is to calculate the induction time in a liquid silicone rubber flow. Silicone goes from liquid (or rubber) to solid with a chemical reaction, and the induction time is the time before the reaction occurs when the silicone is heated.

So, for a constant temperature the induction time is :
t_{i}=t_{0}exp(\frac{T{_{0}}^{}}{T}), t0 and T0 are constant.

And because the process is non-isothermal :
sumti=\sum \frac{dt}{t_{i}}

When sumti = 1, the induction is over.

I don't understand how to implement this in the solver. When I just implement
Code:
volScalarField ti(t0*Foam::exp(T0/T));
sumti += runTime.deltaT()/ti;
the calculation is made for a fixed point and take in account the temperature of the fluid crossing it, instead of being transported with the fluid.

I understand this is doing the calculation like that with the implementation I did, but I don't know how to transport the value with the flow.

I hope I'm clear.

Lilian
Lookid is offline   Reply With Quote

Old   June 4, 2017, 06:15
Default
  #2
Super Moderator
 
Tobi's Avatar
 
Tobias Holzmann
Join Date: Oct 2010
Location: Tussenhausen
Posts: 2,708
Blog Entries: 6
Rep Power: 51
Tobi has a spectacular aura aboutTobi has a spectacular aura aboutTobi has a spectacular aura about
Send a message via ICQ to Tobi Send a message via Skype™ to Tobi
Hi Lilian,

your quantity is not been transported in the way you are talking about (by advection) based on the fact that we do not solve any kind of equation. The only thing that - somhow - transport this quantity is related to the temperature field T because this one can be advected. If you would like to transport your quantity based on the flow, you have to make sure to solve an equation for that, like:

Code:
fvScalarMatrix sumLiEqn
(
    fvm::ddt(sumLi) 
 + fvm::div(phi,sumLi)
);

sumLiEqn.relax();
sumLiEqn.solve();
I have no idea about your equation but here you would transport the quantity sumLi by the flow. If this would be correct in your case, I do not know. And yes, you are right. The calculation you make will calculate everything locally for each point without moving anything.
__________________
Keep foaming,
Tobias Holzmann
Tobi is offline   Reply With Quote

Old   June 6, 2017, 05:49
Default
  #3
Member
 
Lilian Chabannes
Join Date: Apr 2017
Posts: 58
Rep Power: 9
Lookid is on a distinguished road
Hi Tobi,

I tried this before and had a problem when trying to run the calculation :
Code:
--> FOAM FATAL ERROR: 
cannot be called for a calculatedFvPatchField
    on patch inlet of field sumti in file "/home/lilian/OpenFOAM/lilian-4.1/run/mybuoyantBoussinesqPimpleFoam/tip2D/0/sumti"
    You are probably trying to solve for a field with a default boundary condition.

    From function Foam::tmp<Foam::Field<Type> > Foam::calculatedFvPatchField<Type>::valueInternalCoeffs(const Foam::tmp<Foam::Field<double> >&) const [with Type = double]
    in file fields/fvPatchFields/basic/calculated/calculatedFvPatchField.C at line 150.

FOAM aborting
When I searched about it, it seems that the problem come from the fact I calculate sumti before so something is wrong. Maybe it just comes from the BCs but I tried many and the problem is always the same.

Here is the .C file :
Code:
    Info<< "\nStarting time loop\n" << endl;

    while (runTime.run())
    {
        #include "readTimeControls.H"
        #include "CourantNo.H"
        #include "setDeltaT.H"

        runTime++;

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

        // --- Pressure-velocity PIMPLE corrector loop
        while (pimple.loop())
        {
            #include "UEqn.H"
            #include "TEqn.H"

            // --- Pressure corrector loop
            while (pimple.correct())
            {
                #include "pEqn.H"
            }

            if (pimple.turbCorr())
            {
                laminarTransport.correct();
                turbulence->correct();
            }
        }

//added
        volScalarField ti(t0*Foam::exp(T0/T));
        sumti += runTime.deltaT()/ti;

    fvScalarMatrix sumtiEqn
    (
        fvm::ddt(sumti)
        + fvm::div(phi, sumti)
    );

    sumtiEqn.relax();
    sumtiEqn.solve();
//endadded



        runTime.write();

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

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

    return 0;
}
I tried to put this expression everywhere in the file and the problem is the same. So probably it's not right to assign a value to sumti and then solve the Matrix.
Lookid is offline   Reply With Quote

Old   June 6, 2017, 05:55
Default
  #4
Super Moderator
 
Tobi's Avatar
 
Tobias Holzmann
Join Date: Oct 2010
Location: Tussenhausen
Posts: 2,708
Blog Entries: 6
Rep Power: 51
Tobi has a spectacular aura aboutTobi has a spectacular aura aboutTobi has a spectacular aura about
Send a message via ICQ to Tobi Send a message via Skype™ to Tobi
This problem is related to the boundary condition. You cannot solve the system with calculated. Normally this BC is used if one calculate this field based on other (without solving any equation; e.g. p in bouyancy solver -> here we solve for p_rgh and build p based on that field.
__________________
Keep foaming,
Tobias Holzmann
Tobi is offline   Reply With Quote

Old   June 6, 2017, 06:01
Default
  #5
Member
 
Lilian Chabannes
Join Date: Apr 2017
Posts: 58
Rep Power: 9
Lookid is on a distinguished road
I'm not using the "calculated" BC. I put zeroGradient everywhere (this works fine if I don't add the Matrix in the solver), and tried with fixedvalue or even calculated to see what happens but the the same error appears everytime.

Isn't the problem in the .C file ?
Lookid is offline   Reply With Quote

Old   June 7, 2017, 02:31
Default
  #6
Senior Member
 
Alexey Matveichev
Join Date: Aug 2011
Location: Nancy, France
Posts: 1,930
Rep Power: 38
alexeym has a spectacular aura aboutalexeym has a spectacular aura about
Send a message via Skype™ to alexeym
Hi all,

@Lookid

With high probability your sumti field uses default BC, which is calculated. How do you construct sumti?
alexeym is offline   Reply With Quote

Old   June 7, 2017, 02:38
Default
  #7
Member
 
Lilian Chabannes
Join Date: Apr 2017
Posts: 58
Rep Power: 9
Lookid is on a distinguished road
Hello alexeym,

sumti is constructed like that :
Code:
    volScalarField sumti
    (
        IOobject
        (
            "sumti",
            runTime.timeName(),
            mesh,
            IOobject::MUST_READ,
            IOobject::AUTO_WRITE
        ),
        mesh,
        dimensionedScalar("sumti", dimless, 0.0)
    );
And in the .C file :
Code:
    Info<< "\nStarting time loop\n" << endl;

    while (runTime.run())
    {
        #include "readTimeControls.H"
        #include "CourantNo.H"
        #include "setDeltaT.H"

        runTime++;

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

        // --- Pressure-velocity PIMPLE corrector loop
        while (pimple.loop())
        {
            #include "UEqn.H"
            #include "TEqn.H"

            // --- Pressure corrector loop
            while (pimple.correct())
            {
                #include "pEqn.H"
            }

            if (pimple.turbCorr())
            {
                laminarTransport.correct();
                turbulence->correct();
            }
        }

//added
        volScalarField ti(t0*Foam::exp(T0/T));
        sumti += runTime.deltaT()/ti;

    fvScalarMatrix sumtiEqn
    (
        fvm::ddt(sumti)
        + fvm::div(phi, sumti)
    );

    sumtiEqn.relax();
    sumtiEqn.solve();
//endadded



        runTime.write();

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

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

    return 0;
}
Lookid is offline   Reply With Quote

Old   June 7, 2017, 02:51
Default
  #8
Senior Member
 
Alexey Matveichev
Join Date: Aug 2011
Location: Nancy, France
Posts: 1,930
Rep Power: 38
alexeym has a spectacular aura aboutalexeym has a spectacular aura about
Send a message via Skype™ to alexeym
Hi,

You are using this constructor - https://cpp.openfoam.org/v4/classFoa...0d8f8a5fec0dc8 - to create sumti. As you can see all boundary conditions for the field are set to calculated type.

You can create sumti as

Code:
volScalarField sumti
    (
        IOobject
        (
            "sumti",
            runTime.timeName(),
            mesh,
            IOobject::MUST_READ,
            IOobject::AUTO_WRITE
        ),
        mesh,
        dimensionedScalar("sumti", dimless, 0.0),
        "zeroGradient"
    );
to have zero gradient BCs for the field (instead of string, you can use zeroGradientFvPatchField<scalar>::typeName).

Also solution order is not quite physical. I think you should first transport sumti and then accumulate.
alexeym is offline   Reply With Quote

Old   June 7, 2017, 02:54
Default
  #9
Senior Member
 
Alexey Matveichev
Join Date: Aug 2011
Location: Nancy, France
Posts: 1,930
Rep Power: 38
alexeym has a spectacular aura aboutalexeym has a spectacular aura about
Send a message via Skype™ to alexeym
You are using read constructor. I have missed it.

How sumti is defined in 0 folder?
alexeym is offline   Reply With Quote

Old   June 7, 2017, 03:06
Default
  #10
Member
 
Lilian Chabannes
Join Date: Apr 2017
Posts: 58
Rep Power: 9
Lookid is on a distinguished road
I put zeroGradient on all boundaries and 0 in internalField, but it's already defined in CreateFields, right ?

So I changed it to NO_READ and deleted the 0/sumti file.

It works, thank you very much !
Lookid is offline   Reply With Quote

Old   June 7, 2017, 07:20
Default
  #11
Super Moderator
 
Tobi's Avatar
 
Tobias Holzmann
Join Date: Oct 2010
Location: Tussenhausen
Posts: 2,708
Blog Entries: 6
Rep Power: 51
Tobi has a spectacular aura aboutTobi has a spectacular aura aboutTobi has a spectacular aura about
Send a message via ICQ to Tobi Send a message via Skype™ to Tobi
If removing the MUST_READ option and define the BC explicitly by calling the appropriate constructor will solve your problem, then you did something wrong in the first approach. However, nice to know that it is working now. Good luck.

PS: Maybe you were calling the wrong constructor because your implementation was:

Code:
 volScalarField sumti    
 (         
    Oobject         
    (
             "sumti",
             runTime.timeName(),
             mesh,
             IOobject::MUST_READ,
             IOobject::AUTO_WRITE
    ),
    mesh,
    dimensionedScalar("sumti", dimless, 0.0)      //- Not needed and thus, you might call another constructor which was not reading your 0/sumit file or overwrite the BC you set
);
However, to figure it out, you just can check the BC for the field after construction.
__________________
Keep foaming,
Tobias Holzmann
Tobi 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 the height of the stream in the free channel kevinmccartin CFX 12 October 13, 2022 21:43
How to add a passive scalar to the simpleFoam solver Uyan OpenFOAM Running, Solving & CFD 6 June 22, 2017 17:36
Add Work due to body force in the energy equation for a lagrangian solver mneben OpenFOAM Programming & Development 6 January 19, 2016 05:30
dieselFoam problem!! trying to introduce a new heat transfer model vivek070176 OpenFOAM Programming & Development 10 December 23, 2014 23:48


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