CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Software User Forums > OpenFOAM > OpenFOAM Community Contributions

[Other] real gas model implementation for thermophysicalModels library

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

Like Tree6Likes

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   February 9, 2022, 05:04
Default real gas model implementation for thermophysicalModels library
  #1
New Member
 
Nam Danh Nguyen
Join Date: Feb 2020
Location: UNIST-Ulsan-Korea
Posts: 29
Rep Power: 6
danhnam is on a distinguished road
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 ).

Last edited by danhnam; February 9, 2022 at 05:07. Reason: fix the github link
danhnam is offline   Reply With Quote

Old   March 15, 2022, 06:07
Default 3D and high velocity
  #2
New Member
 
Join Date: Apr 2019
Posts: 10
Rep Power: 7
Lehaibmo is on a distinguished road
is it good for 3D runs and high velocity applications?
Lehaibmo is offline   Reply With Quote

Old   March 17, 2022, 21:38
Default
  #3
New Member
 
Nam Danh Nguyen
Join Date: Feb 2020
Location: UNIST-Ulsan-Korea
Posts: 29
Rep Power: 6
danhnam is on a distinguished road
Quote:
Originally Posted by Lehaibmo View Post
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!
danhnam is offline   Reply With Quote

Old   April 8, 2022, 06:32
Default EOS - Peng Robinson
  #4
New Member
 
Nicola
Join Date: Dec 2018
Location: Sestri Levante, Italy
Posts: 1
Rep Power: 0
onofrio is on a distinguished road
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 likes this.
onofrio is offline   Reply With Quote

Old   April 14, 2022, 23:20
Default
  #5
New Member
 
Nam Danh Nguyen
Join Date: Feb 2020
Location: UNIST-Ulsan-Korea
Posts: 29
Rep Power: 6
danhnam is on a distinguished road
Quote:
Originally Posted by onofrio View Post
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.
danhnam is offline   Reply With Quote

Old   June 30, 2022, 10:06
Default
  #6
New Member
 
Ma Jie
Join Date: Aug 2020
Posts: 7
Rep Power: 6
Major0412 is on a distinguished road
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)
Major0412 is offline   Reply With Quote

Old   June 30, 2022, 10:17
Default
  #7
New Member
 
Nam Danh Nguyen
Join Date: Feb 2020
Location: UNIST-Ulsan-Korea
Posts: 29
Rep Power: 6
danhnam is on a distinguished road
Quote:
Originally Posted by Major0412 View Post
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.
danhnam is offline   Reply With Quote

Old   June 30, 2022, 10:24
Default
  #8
New Member
 
Ma Jie
Join Date: Aug 2020
Posts: 7
Rep Power: 6
Major0412 is on a distinguished road
Quote:
Originally Posted by danhnam View Post
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?
Major0412 is offline   Reply With Quote

Old   June 30, 2022, 10:59
Default
  #9
New Member
 
Nam Danh Nguyen
Join Date: Feb 2020
Location: UNIST-Ulsan-Korea
Posts: 29
Rep Power: 6
danhnam is on a distinguished road
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?
danhnam is offline   Reply With Quote

Old   June 30, 2022, 11:05
Default
  #10
New Member
 
Ma Jie
Join Date: Aug 2020
Posts: 7
Rep Power: 6
Major0412 is on a distinguished road
Quote:
Originally Posted by danhnam View Post
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)
Major0412 is offline   Reply With Quote

Old   June 30, 2022, 11:11
Default
  #11
New Member
 
Nam Danh Nguyen
Join Date: Feb 2020
Location: UNIST-Ulsan-Korea
Posts: 29
Rep Power: 6
danhnam is on a distinguished road
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.
danhnam is offline   Reply With Quote

Old   June 30, 2022, 11:13
Default
  #12
New Member
 
Ma Jie
Join Date: Aug 2020
Posts: 7
Rep Power: 6
Major0412 is on a distinguished road
Quote:
Originally Posted by danhnam View Post
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!
Major0412 is offline   Reply With Quote

Old   August 17, 2022, 04:40
Default
  #13
New Member
 
xubonan
Join Date: Mar 2019
Posts: 2
Rep Power: 0
xubonan is on a distinguished road
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.
xubonan is offline   Reply With Quote

Old   August 18, 2022, 23:18
Default
  #14
New Member
 
Nam Danh Nguyen
Join Date: Feb 2020
Location: UNIST-Ulsan-Korea
Posts: 29
Rep Power: 6
danhnam is on a distinguished road
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,
danhnam is offline   Reply With Quote

Old   August 18, 2022, 23:33
Default
  #15
New Member
 
xubonan
Join Date: Mar 2019
Posts: 2
Rep Power: 0
xubonan is on a distinguished road
Quote:
Originally Posted by danhnam View Post
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.
xubonan is offline   Reply With Quote

Old   August 18, 2022, 23:50
Default
  #16
New Member
 
Nam Danh Nguyen
Join Date: Feb 2020
Location: UNIST-Ulsan-Korea
Posts: 29
Rep Power: 6
danhnam is on a distinguished road
Quote:
Originally Posted by xubonan View Post
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,
danhnam is offline   Reply With Quote

Old   November 21, 2022, 04:07
Default
  #17
New Member
 
Eliot Foss
Join Date: Nov 2022
Location: Tokyo, Japan
Posts: 2
Rep Power: 0
eliotfoss is on a distinguished road
Quote:
Originally Posted by xubonan View Post
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.
eliotfoss is offline   Reply With Quote

Old   November 22, 2022, 22:19
Default
  #18
New Member
 
Nam Danh Nguyen
Join Date: Feb 2020
Location: UNIST-Ulsan-Korea
Posts: 29
Rep Power: 6
danhnam is on a distinguished road
Quote:
Originally Posted by eliotfoss View Post
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,
danhnam is offline   Reply With Quote

Old   November 27, 2022, 23:27
Default
  #19
New Member
 
Eliot Foss
Join Date: Nov 2022
Location: Tokyo, Japan
Posts: 2
Rep Power: 0
eliotfoss is on a distinguished road
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!
eliotfoss is offline   Reply With Quote

Old   January 6, 2023, 12:28
Default Real Gas Jacobian
  #20
New Member
 
Rohit Mishra
Join Date: Apr 2020
Posts: 2
Rep Power: 0
rmishra is on a distinguished road
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.
rmishra 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
Compile User-Defined Real Gas Model (UDRGM) Captain Convergence Fluent UDF and Scheme Programming 31 November 6, 2020 07:30
make a new data from external .txt data and save it in a UDM etedalgara Fluent UDF and Scheme Programming 27 February 26, 2020 04:15
UDF velocity profile willroca Fluent UDF and Scheme Programming 2 January 10, 2016 04:13
Wrong flow in ratating domain problem Sanyo CFX 17 August 15, 2015 07:20
view factor yoollooz Fluent UDF and Scheme Programming 0 March 1, 2013 01:44


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