CFD Online Discussion Forums (http://www.cfd-online.com/Forums/)
-   OpenFOAM (http://www.cfd-online.com/Forums/openfoam/)
-   -   Declaration of the function TH() (http://www.cfd-online.com/Forums/openfoam/105521-declaration-function-th.html)

 Tobi August 1, 2012 17:15

Declaration of the function TH()

Hi all,

I am trying to find the place where the temperature is derived from the enthalpy.

- Solver: rhoSimpleFoam
- thermodynamics: hPsiThermo
- transport: hConstTransport

Therefor I had a look at the solver and the enthalpy equation h:

Code:

```{     fvScalarMatrix hEqn     (         fvm::div(phi, h)       - fvm::Sp(fvc::div(phi), h)       - fvm::laplacian(turbulence->alphaEff(), h)     ==       - fvc::div(phi, 0.5*magSqr(U), "div(phi,K)")     );     hEqn.relax();     hEqn.solve();     thermo.correct();```
Here I think the step I am searching is in the function "correct".
That leads me to the thermomodel -> hPsiThermo.C.

From the correct() function you get into the calculate() function. And there (I think) you get the temperature derived from the enthalpy. Its described in the *.H file that T is calculated there.

I found that function:

Code:

`        TCells[celli] = mixture_.TH(hCells[celli], TCells[celli]);`
And would find the definition of that function. With grep I get into the specieThermo.H file. Here I found that:
Code:

```        // Energy->temperature  inversion functions             //- Temperature from Enthalpy given an initial temperature T0             inline scalar TH(const scalar H, const scalar T0) const;```
So I am very sure that I am on the right way. But thats just a function prototype and not a function declaration. I searched everywhere but do not find the definition of that function.

Where can i find it?
Can someone give me an advice?

Tobi

 Tobi August 1, 2012 17:30

I should have a look at the specieThermoI.H
So solved :) Thanks for reading

 mturcios777 August 1, 2012 17:50

If you look in specieThermoI.H you will find the function TH. Looking at it you will see that the template is calling another function T and feeding it the proper coefficients (whether its enthalpy or energy you are inverting).

The function T is also in the file, near the very beginning. Here is where temperature is obtained by inverting the enthalpy/energy based on the the species thermo (its a simple Newton's method if I read the code right).

EDIT: Hehe Tobi, you must have been thinking while I was typing ;-)

 Tobi August 1, 2012 17:56

Hihi,

well, nevertheless thanks for reading and anwering :)
You are right. After I read the specieThermoI.H file I saw that TH is calling a other function T() and thats defined in the beginning of the thermo model :)

Wow .. cool ... hihi. I am getting familiar and familiar with OF code.

 sihaqqi August 28, 2013 03:42

1 Attachment(s)
Quote:
 Originally Posted by Tobi (Post 374930) Hihi, well, nevertheless thanks for reading and anwering :) You are right. After I read the specieThermoI.H file I saw that TH is calling a other function T() and thats defined in the beginning of the thermo model :) Wow .. cool ... hihi. I am getting familiar and familiar with OF code.
Hello Tobias and Marcos,

I have this same type of problem but like you I am not a very senior CFD specialist. I was trying to follow your comments but I do not understand how to resolve this issue. I have recently enrolled in postgrad by research student this is my first time with CFD and openfoam. I am solving for air flow in a pipe. Air is taken as compressible. So I am using rhoPimpleFoam. Can you please advise how I can get rid of this error.

I have applied following strategies

1. With small number of cells (coarse mesh), as rhoMax increases, number of time steps increase before solution fails.2. As number of cells increase, as rhoMax increases, number of time steps decrease against the same number of rhoMax.

I have tried this strategy on cell size 13000, 26000 and 85000 for 8 trial cases for rhoMax 2, Pressure 100,000 and Temperature 300.

I have tried to increase pressure and temperatures also.

Upon increasing value of pressure to 200,000, error was produced at 0.0184 against 0.0181 at 100,000. The error came after only three more steps. Cell number is 13000. Value of rhoMax was kept as 2.

Upon increasing the value of temperature to 400, error was produced at 0.0458 against 0.0341 at 300. Cell number is 13000. Value of rhoMax was kept as 2.

I shall be very grateful.

Regards

 sihaqqi August 28, 2013 03:43

Quote:
 Originally Posted by Tobi (Post 374930) Hihi, well, nevertheless thanks for reading and anwering :) You are right. After I read the specieThermoI.H file I saw that TH is calling a other function T() and thats defined in the beginning of the thermo model :) Wow .. cool ... hihi. I am getting familiar and familiar with OF code.
Hello Tobias and Marcos,

I have this same type of problem but like you I am not a very senior CFD specialist. I was trying to follow your comments but I do not understand how to resolve this issue. I have recently enrolled in postgrad by research student this is my first time with CFD and openfoam. I am solving for air flow in a pipe. Air is taken as compressible. So I am using rhoPimpleFoam. Can you please advise how I can get rid of this error.

I have applied following strategies

1. With small number of cells (coarse mesh), as rhoMax increases, number of time steps increase before solution fails.

2. As number of cells increase, as rhoMax increases, number of time steps decrease against the same number of rhoMax.

I have tried this strategy on cell size 13000, 26000 and 85000 for 8 trial cases for rhoMax 2, Pressure 100,000 and Temperature 300.

I have tried to increase pressure and temperatures also.

Upon increasing value of pressure to 200,000, error was produced at 0.0184 against 0.0181 at 100,000. The error came after only three more steps. Cell number is 13000. Value of rhoMax was kept as 2.

Upon increasing the value of temperature to 400, error was produced at 0.0458 against 0.0341 at 300. Cell number is 13000. Value of rhoMax was kept as 2.

I shall be very grateful.

Regards

 sihaqqi August 28, 2013 03:44

1 Attachment(s)
[QUOTE=sihaqqi;448455]

Hello Tobias and Marcos,

I have this same type of problem but like you I am not a very senior CFD specialist. I was trying to follow your comments but I do not understand how to resolve this issue. I have recently enrolled in postgrad by research student this is my first time with CFD and openfoam. I am solving for air flow in a pipe. Air is taken as compressible. So I am using rhoPimpleFoam. Can you please advise how I can get rid of this error.

I have applied following strategies

1. With small number of cells (coarse mesh), as rhoMax increases, number of time steps increase before solution fails.

2. As number of cells increase, as rhoMax increases, number of time steps decrease against the same number of rhoMax.

I have tried this strategy on cell size 13000, 26000 and 85000 for 8 trial cases for rhoMax 2, Pressure 100,000 and Temperature 300.

I have tried to increase pressure and temperatures also.

Upon increasing value of pressure to 200,000, error was produced at 0.0184 against 0.0181 at 100,000. The error came after only three more steps. Cell number is 13000. Value of rhoMax was kept as 2.

Upon increasing the value of temperature to 400, error was produced at 0.0458 against 0.0341 at 300. Cell number is 13000. Value of rhoMax was kept as 2.

I shall be very grateful.

Regards

 sihaqqi August 28, 2013 04:18

1 Attachment(s)
Fellows

My image was very vague last time. I have reattached it so you may see the error.

Regards

 Vito31388 August 28, 2013 11:57

Hi foamers, I'd like to understand how temperature is calculated in library hhuMixtureThermo.C because as you' ve explained in previous posts temperature is obtained from TH() function. However in hhuMixtureThermo library there are 3 functions to calculate unburnt(Tu) and burnt gas(Tb), mixture(T) temperature. It's clear how Tu and Tb are calculated:
Code:

```      TuCells[celli] = this->cellReactants(celli).TH(huCells[celli], TuCells[celli]);       TbCells[celli] = this->cellProducts(celli).TH(hCells[celli], TCells[celli]);```
Is mixture calculated from this function:

Code:

``` TCells[celli] = mixture_.TH(hCells[celli], TCells[celli]);```
or based upon Tu and Tb ?