CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   OpenFOAM Community Contributions (https://www.cfd-online.com/Forums/openfoam-community-contributions/)
-   -   [Other] real gas model implementation for thermophysicalModels library (https://www.cfd-online.com/Forums/openfoam-community-contributions/241110-real-gas-model-implementation-thermophysicalmodels-library.html)

danhnam February 9, 2022 04:04

real gas model implementation for thermophysicalModels library
 
Hi everyone!

I would like to share the OpenFOAM-based real-fluid thermophysicalModels library that we developed for reacting flow simulation at high-pressure.

The detail development is described in here https://doi.org/10.1016/j.cpc.2021.108264

You can freely download the source code here: https://github.com/danhnam11/realFlu...ysicalModels-6

Should you find bugs or have suggestions on how to make the code better, please post on this thread.

Greetings, Danh Nam

(This thread is posted on the Programming& Development topic but I realize that it's the wrong place. So that I post this thread again here :) ).

Lehaibmo March 15, 2022 05:07

3D and high velocity
 
is it good for 3D runs and high velocity applications?

danhnam March 17, 2022 20:38

Quote:

Originally Posted by Lehaibmo (Post 824109)
is it good for 3D runs and high velocity applications?

Hi Lehaibmo.

I think you should give it a try. Our library provides only calculations of real-fluid thermophysical properties. It doesn't depend on high or low velocity.

Danh Nam!

onofrio April 8, 2022 05:32

EOS - Peng Robinson
 
Good morning,

I found that, in PengRobinson equationOfState model, the M term, present in both Cp and CpMCv functions, is the same as in the soaveRedlichKwong model when actually it is not so (as you can see in the original PengRobinsonGas formulation). This fact leads to negative Cp (I’m dealing with nitrogen at cryogenic conditions).
If you substitute back the original formulation for the M term everything works fine.

Nicola

danhnam April 14, 2022 22:20

Quote:

Originally Posted by onofrio (Post 825824)
Good morning,

I found that, in PengRobinson equationOfState model, the M term, present in both Cp and CpMCv functions, is the same as in the soaveRedlichKwong model when actually it is not so (as you can see in the original PengRobinsonGas formulation). This fact leads to negative Cp (I’m dealing with nitrogen at cryogenic conditions).
If you substitute back the original formulation for the M term everything works fine.

Nicola

Hi Nicola!

Thank you so much for your bug finding. I will check it and update in our source code again.

have a nice day :)
Danh Nam.

Major0412 June 30, 2022 09:06

Hi danhnam:
Your work is outstanding. I have a question, can it be used to calculate trans-/supercritical spray? eg ECN Spray A (Tinj=363K, Pamb=6MPa)

danhnam June 30, 2022 09:17

Quote:

Originally Posted by Major0412 (Post 830778)
Hi danhnam:
Your work is outstanding. I have a question, can it be used to calculate trans-/supercritical spray? eg ECN Spray A (Tinj=363K, Pamb=6MPa)

Hi Ma Jie!

Yes, the implemented real-gas models can be used for a wide range of T and p. We already tested from 1 to 300 atm against NIST data, covering your conditions. If you get any problems with this library, we can discuss it together.

Danh Nam.

Major0412 June 30, 2022 09:24

Quote:

Originally Posted by danhnam (Post 830780)
Hi Ma Jie!

Yes, the implemented real-gas models can be used for a wide range of T and p. We already tested from 1 to 300 atm against NIST data, covering your conditions. If you get any problems with this library, we can discuss it together.

Danh Nam.

Very honored to receive your reply so quickly! Currently I'm simulating ECN Spray A, but I'm running into a problem where the real gas equation of state causes a negative pressure during the simulation(entering the mechanical spinodal or two phase region), which makes the simulation diverge, I don't know if your solver can solve this problem?

danhnam June 30, 2022 09:59

I think your problem belongs to the solver problem. Our work only focus on the library which means the calculations of thermophysical properties. The solver named realFluidReactingFoam used in our work is only for laminar flame. Your problem may come from the nature of the solver you are using, for instance psi- or rho-based, or the algorithm you are using.
Which solver you are using now?

Major0412 June 30, 2022 10:05

Quote:

Originally Posted by danhnam (Post 830785)
I think your problem belongs to the solver problem. Our work only focus on the library which means the calculations of thermophysical properties. The solver named realFluidReactingFoam used in our work is only for laminar flame. Your problem may come from the nature of the solver you are using, for instance psi- or rho-based, or the algorithm you are using.
Which solver you are using now?

Hi danhnam! I'm currently using a self-written solver, based on rhoPimpleFoam, which also uses the real gas library. Have you tested ECN Spray A with your solver? If yes, can I add you as a friend? (WeChat/Telegram or others)

danhnam June 30, 2022 10:11

I have not run spray A problem before. But I think we could have a further discussion. You can email me via danhnam11@gmail.com. I will reply you tomorrow because it is quite late now.
Hopefully I can help you to solve your problem.

Major0412 June 30, 2022 10:13

Quote:

Originally Posted by danhnam (Post 830789)
I have not run spray A problem before. But I think we could have a further discussion. You can email me via danhnam11@gmail.com. I will reply you tomorrow because it is quite late now.
Hopefully I can help you to solve your problem.

Thank you very much! Then I will contact you tomorrow! Thank you again!

xubonan August 17, 2022 03:40

Dear danhnam:
When I use this library, I found a error when utilizing nitrogen as working fluid in the temperature range 120-300 under the pressure of 5MPa
FOAM FATAL ERROR:
Maximum number of iterations exceeded: 100,
in file /home/user/OpenFOAM/realfluids/realFluidThermophysicalModels-6/src//thermophysicalModels/specie/lnInclude/thermoI.H at line 73.

I guess there are some issues when solving temperature.

danhnam August 18, 2022 22:18

Dear xubonnan!

Thank you for letting me know that error. Could you provide more information such as which solver you are using, which real-gas models you are using, etc., . And it would be better if you can include the whole error message. It can help me understand your problem more.

Danh Nam,

xubonan August 18, 2022 22:33

Quote:

Originally Posted by danhnam (Post 834085)
Dear xubonnan!

Thank you for letting me know that error. Could you provide more information such as which solver you are using, which real-gas models you are using, etc., . And it would be better if you can include the whole error message. It can help me understand your problem more.

Danh Nam,

Dear Nam
I just change the tutorial case to pure nitrogen, and the pressure is 5MPa, initial internal temperature is 300K, the temperature of two inlet is 130 and 300K respectively. I think its not due to the bugs of code, its because of the effect of quickly change and nonlinearity of thermodynamic properties of fluids.

danhnam August 18, 2022 22:50

Quote:

Originally Posted by xubonan (Post 834086)
Dear Nam
I just change the tutorial case to pure nitrogen, and the pressure is 5MPa, initial internal temperature is 300K, the temperature of two inlet is 130 and 300K respectively. I think its not due to the bugs of code, its because of the effect of quickly change and nonlinearity of thermodynamic properties of fluids.

Dear xubonan!

I think so. The error would come from the nature of your problem (not a bug of code). Hopefully, you can use our library for your work.

Danh Nam,

eliotfoss November 21, 2022 03:07

Quote:

Originally Posted by xubonan (Post 833953)
Dear danhnam:
When I use this library, I found a error when utilizing nitrogen as working fluid in the temperature range 120-300 under the pressure of 5MPa
FOAM FATAL ERROR:
Maximum number of iterations exceeded: 100,
in file /home/user/OpenFOAM/realfluids/realFluidThermophysicalModels-6/src//thermophysicalModels/specie/lnInclude/thermoI.H at line 73.

I guess there are some issues when solving temperature.

This is true, in the thermoI.H file the T function near the beginning of the file uses the newton method to solve for Temperature. This method is not always successful, especially near the critical point, and the temperature will diverge. I am going to edit this method to allow for a different root finding method (like bisecting method) to take over if it sees the temperatures start to diverge.

danhnam November 22, 2022 21:19

Quote:

Originally Posted by eliotfoss (Post 839739)
This is true, in the thermoI.H file the T function near the beginning of the file uses the newton method to solve for Temperature. This method is not always successful, especially near the critical point, and the temperature will diverge. I am going to edit this method to allow for a different root finding method (like bisecting method) to take over if it sees the temperatures start to diverge.

Yes, you are right.
To overcome that problem, we already implemented Newton+bisection method to retrieve T from enthalpy. But that code has not been published yet. However, to run the simulations with real-gas models at near the critical point, you not only need to overcome that problem but also you need to apply a modified PIMPLE algorithm for your system of the governing equations. We already finished all of them and the source code would be available for everyone soon after our paper is being accepted.

Danh Nam,

eliotfoss November 27, 2022 22:27

Thanks for your reply, I see, I did not realize there would be a problem with the pimple loop itself, I hope that you can share you findings soon!

I had another question, in your paper, you define the strain rate for the counterflow non-premixed flame with a multiplying factor of 2. In the textbooks I've read this 2 is not included in the definition. Is this due to a lack of standardization for the definition, or some other reason?

Thank you for your time!

rmishra January 6, 2023 11:28

Real Gas Jacobian
 
In reference to the following file:

src/thermophysicalModels/specie/thermo/rfJanaf/rfJanafThermoI.H (Lines 286-295)

The dcpdT term is ideal. Since we are dealing with real gas combustion we need to solve for real gas Jacobian. So the temperature derivative will also include the derivative of departure function apart from the ideal gas part.

Please let me know if you have time to discuss this.


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