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

Correction of T after TEqn in compressibleInterFoam

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

Like Tree3Likes
  • 3 Post By krikre

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   October 26, 2017, 05:38
Default Correction of T after TEqn in compressibleInterFoam
  #1
Member
 
Kristjan
Join Date: Apr 2017
Location: Slovenia
Posts: 36
Rep Power: 9
krikre is on a distinguished road
Hello everyone!

Why is in compressibleInterFoam T first calculated from the temperature equation TEqn and then again from internal energy he() in heRhoThermo.C with calculate()?

Code:
        TCells[celli] = mixture_.THE
        (
            hCells[celli],
            pCells[celli],
            TCells[celli]
        );
I tried to comment this out and it seemed to impair the calculation of pressure. I'm guessing this piece of code enforces the equation of state? My idea was to eliminate internal energy calculation since temperature is governed by the TEqn. So if T needs to be corrected to enforce the equation of state, could I make this correction without calculating the internal energy and just use the equation of state to correct the temperature? Could I correct pressure instead?
krikre is offline   Reply With Quote

Old   October 27, 2017, 06:08
Default
  #2
Member
 
Martin Aunskjaer
Join Date: Mar 2009
Location: Denmark
Posts: 53
Rep Power: 17
aunola is on a distinguished road
It isn’t.

I am going by memory and it’s been a long time since I’ve been working with OF (2.2.x), so I may we wrong about the details. But as far as I remember the twoPhaseMixtureThermo that compressibleInterFoam uses inherits from basicThermo and this is where the solver gets its p, T fields from. The twoPhaseMixtureThermo has two thermo objects, one for each phase. Each of those also inherit from basicThermo so they both have their own p, T fields as well.

The solver uses the p, T fields of the twoPhaseMixtureThermo. Those fields are not known to the phasic thermo objects. The twoPhaseMixtureThermo in turn doesn’t know how to calculate transport properties of the constituent phases. Only the phasic thermo objects know that.

In the correct() function of twoPhaseMixtureThermo there should for each phase ‘x’ be a line something like this: thermox->he() = thermox->he(p,T). The right hand side creates a new volScalarField with enthalpy initialized from the current p and T fields of the solver (see heThermo). It then assigns that field to the same thermo object. In turn, the correct() function can be called on each of the phasic termo objects to update the transport properties.

You don’t state exactly what you commented out, but if it is the calls to the thermo object correct() functions inside the twoPhaseMixtureThermo then it will not work. The missing update of transport properties – e.g. compressibility used in the pressure equation - leads to field inconsistency. Eventually something will blow up, quite likely pressure.
aunola is offline   Reply With Quote

Old   October 27, 2017, 10:10
Default
  #3
Member
 
Kristjan
Join Date: Apr 2017
Location: Slovenia
Posts: 36
Rep Power: 9
krikre is on a distinguished road
You pointed me in the right direction, thank you!

I then checked the phase temperatures T.air and T.poly and they weren't changing during the calculation, because of the commented code. I wasn't aware of the different temperature objects.

Code:
#include "mojHeRhoThermo.H"

// * * * * * * * * * * * * * Private Member Functions  * * * * * * * * * * * //

template<class BasicPsiThermo, class MixtureType>
void Foam::mojHeRhoThermo<BasicPsiThermo, MixtureType>::calculate()
{
    //const scalarField& hCells = this->he().internalField(); //commented out
    const scalarField& pCells = this->p_.internalField();
    const scalarField& strigCells = this->strig_.internalField();

    scalarField& TCells = this->T_.internalField();
    scalarField& psiCells = this->psi_.internalField();
    scalarField& rhoCells = this->rho_.internalField();
    scalarField& muCells = this->mu_.internalField();
    scalarField& alphaCells = this->alpha_.internalField();

    forAll(TCells, celli)
    {
        const typename MixtureType::thermoType& mixture_ =
            this->cellMixture(celli);

        //TCells[celli] = mixture_.THE //commented out
        //(
        //    hCells[celli],
        //    pCells[celli],
        //    TCells[celli]
        //);
I didn't realize it, but I guess the individual phase temperatures are a feature of the original solver. In my case, only the polymer is to be modeled and air is there just to fill the empty space.

This now allows the phase temperatures to be overridden.
Code:
void Foam::mojTwoPhaseMixtureThermo::correct()
{
    //thermo1_->he() = thermo1_->he(p_, T_);
    thermo1_->T() = T_;
    thermo1_->correct();

    //thermo2_->he() = thermo2_->he(p_, T_);
    thermo2_->T() = T_;
    thermo2_->correct();
hwangpo, mikulo and JuRe09 like this.
krikre is offline   Reply With Quote

Old   June 26, 2022, 23:07
Default
  #4
Member
 
Join Date: Nov 2020
Posts: 53
Rep Power: 5
mikulo is on a distinguished road
Quote:
Originally Posted by krikre View Post
You pointed me in the right direction, thank you!

I then checked the phase temperatures T.air and T.poly and they weren't changing during the calculation, because of the commented code. I wasn't aware of the different temperature objects.

Code:
#include "mojHeRhoThermo.H"

// * * * * * * * * * * * * * Private Member Functions  * * * * * * * * * * * //

template<class BasicPsiThermo, class MixtureType>
void Foam::mojHeRhoThermo<BasicPsiThermo, MixtureType>::calculate()
{
    //const scalarField& hCells = this->he().internalField(); //commented out
    const scalarField& pCells = this->p_.internalField();
    const scalarField& strigCells = this->strig_.internalField();

    scalarField& TCells = this->T_.internalField();
    scalarField& psiCells = this->psi_.internalField();
    scalarField& rhoCells = this->rho_.internalField();
    scalarField& muCells = this->mu_.internalField();
    scalarField& alphaCells = this->alpha_.internalField();

    forAll(TCells, celli)
    {
        const typename MixtureType::thermoType& mixture_ =
            this->cellMixture(celli);

        //TCells[celli] = mixture_.THE //commented out
        //(
        //    hCells[celli],
        //    pCells[celli],
        //    TCells[celli]
        //);
I didn't realize it, but I guess the individual phase temperatures are a feature of the original solver. In my case, only the polymer is to be modeled and air is there just to fill the empty space.

This now allows the phase temperatures to be overridden.
Code:
void Foam::mojTwoPhaseMixtureThermo::correct()
{
    //thermo1_->he() = thermo1_->he(p_, T_);
    thermo1_->T() = T_;
    thermo1_->correct();

    //thermo2_->he() = thermo2_->he(p_, T_);
    thermo2_->T() = T_;
    thermo2_->correct();
Hello,

Can you please explain what are your goals here and why you commented on some lines? I can barely follow what you did. I need to understand more since I want to modify the TEqn also to my purpose.

Regards,
Mike
mikulo 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
Floating point exception error Alan OpenFOAM Running, Solving & CFD 11 July 1, 2021 22:51
SIMPLE algorithm does not converge when using old pressure (correction) values andreasp Main CFD Forum 3 February 9, 2016 22:18
Production correction or curvature correction in the SST model Ang CFX 2 May 20, 2014 21:50
Star ccm 9.02 - unsteady flux dissipation correction fivos STAR-CCM+ 4 April 28, 2014 10:37
Pressure correction problem richard_larson OpenFOAM Running, Solving & CFD 8 October 30, 2008 09:48


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