-
Notifications
You must be signed in to change notification settings - Fork 6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add isothermal_compressibility
and thermal_expansion_coefficient
for Redlich-Kwong and Peng-Robinson EOS
#122
Comments
isothermal_compressibility
and thermal_expansion_coefficient
for Peng-Robinson EOS
Would it be better to move this issue to the main repository as it is smaller? |
@corykinney Nope, this is a great place for this issue. I'd be happy to have a Zoom/Webex/etc. to help you get started on the contribution, if it'd be helpful. Feel free to reach out to the email in my profile! |
thanks, @bryanwweber - I had noticed this, yesterday. This would definitely be a great extension of that model. I'll try and remember to give it a look once I've finished grading for the semester and recovered that portion of my brain. @corykinney please feel free to bug me if I forget, if you want feedback (but I also trust you to proceed, without any input from me). |
@bryanwweber I will definitely be reaching out to you and asking some questions, I appreciate the offer! @decaluwe I'll go ahead and start trying to implement it next week. I'll likely proceed fairly slowly as I figure out the C++ side of things, but I would definitely appreciate if you had time to double check the equations sometime along the way! |
Starting to work on it at |
isothermal_compressibility
and thermal_expansion_coefficient
for Peng-Robinson EOSisothermal_compressibility
and thermal_expansion_coefficient
for Redlich-Kwong and Peng-Robinson EOS
@corykinney … are you planning to post a PR for this? |
@ischoegl ... Yes, I plan on posting a PR eventually. It's just taken a back seat to some other things, so it might be a month or two before I get around to it. |
Unfortunately I won't be able to continue working on this, but I'll leave this open in case anyone wants to finish it from the derivations I had included in the initial post. |
@ischoegl I've been working on real gas stuff more recently and had time to finish the implementations over on |
@corykinney … sounds great! However, I myself don’t have much experience with non-ideal gas models. @decaluwe should be able to help though as his group has been driving some of these efforts lately. |
Hi @corykinney. Here are my recommendations:
Thanks! |
@decaluwe If I calculate the result manually and hard code the value, wouldn't that be open to an error in my derivation of the equation? I suppose if I verify the manual calculation matches the external software it would be a good option.
This seems like it would be a bit more straightforward, as I could implement a central finite difference for a small change in either temperature or pressure and the corresponding change in molar volume. I suppose I would just need to select the right tolerance for error. |
At some point somewhere, one has to assume that somebody has done something correctly. 😁 I don't see any way around this, in a test. But yes, a one-time verification of your derivation against external software would be a good way to be double-sure. It would probably also be a good standard procedure to always get at least two sets of eyes on any derivation that isn't already an established part of the literature. I'll try and make some time for this, between now and when this PR is ready.
My only caution here is: what would differentiate what P-R returns for any given identity, vs. ideal gas, vs. R-K, etc? I guess it would check against gross/large errors in the derivation or implementation, but still wouldn't give a guarantee that the theory was done correctly. Again, a workable solution, and yes more straightforward, but it would be good if tests like these were supplemented by others. Also, thermodynamic identities, such as |
As a comment on thermodynamic consistency, @speth introduced comprehensive checks in Cantera/cantera#1299, which implements #114. While presumably not available for all properties, the framework is in place. |
@decaluwe That's a fair point, perhaps I was going a little overboard 😁
I implemented a quick test for the work on the SRK EOS #159 to check the implementations for the same functions, and it seems like a central finite difference can give at least a decent check on accuracy. Here is some sample output for
the check is pretty simple def isothermal_compressibiliy_central_diff(gas, dP):
T, P = gas.TP
gas.TP = T, P - dP
rho1 = gas.density_mass
gas.TP = T, P + dP
rho2 = gas.density_mass
gas.TP = T, P
return - gas.density_mass * (1 / rho2 - 1 / rho1) / (2 * dP) and something similar for
@ischoegl I see that |
Thanks for sharing your derivation of the Peng-Robinson isothermal compressibility. I think there is actually a simpler approach to calculating all of these quantities, by applying a couple of partial derivative identities. Peng-RobinsonWriting the EoS as: Isothermal compressibility,
|
@speth Using the partial derivative identities is a great idea! I can update the code with the simplified equations and implement the equations into the comments. |
Abstract
Implementing the required functions to calculate the isothermal compressibility and thermal expansion coefficient for the Peng-Robinson EOS added in Cantera/cantera#1047.
Motivation
I'm currently developing a Python package that solvers for shock conditions (in a shock tube) using a real gas EOS. Currently, the implementation of Peng-Robinson does not define the
isothermal_compressibility
andthermal_expansion_coefficient
properties that the algorithm requires.Description
I found this paper that includes the derivation of the derivative of molar mass with respect to temperature at constant pressure, which can be used for the thermal expansion coefficient. I couldn't find a similar resource relevant to the isothermal compressibility factor. I have attached my attempt at a derivation of the isothermal compressibility factor in case there are any errors in my understanding of the thermodynamic principles or the derivatives.
I have not yet started on any code, as I have limited C++ experience and expect to have some trouble implementing it. I will document my progress here, and if anyone is willing to help, that would be great!
The text was updated successfully, but these errors were encountered: