I have been using the Redlich-Kwong EOS to calculate the compressibility factor for nitrogen. I am currently running an Excel VBA that performs the calculation. I have noticed that the process of calculation fails at temperatures of 92 F and below at 10,000 psia. However, it works at a temperatures of 93 F and above, at 10,000 psia. I have also shown it to work for a temperature and pressure envelope of 60 F to 600 F and 14.7 psia to 9,000 psia, respectively. By failure, I mean to say that Excel cannot converge on an answer and the program crashes. I am not sure if this failure is due to the capabilities of Excel, my computer, or if it is due to the limitation of the Redlich-Kwong EOS.

The macro I am using comes from Peress, J.:"Working with Non-Ideal Gases," CEP Magazine March 2003 p. 39. Unfortunately, I have only managed to obtain this macro, I have not been able to get this article to read for myself. The macro, the process to calculate z (compressibility factor), is shown below.

So my questions are:

  1. Are there pressure and temperature limits to the Redlich-Kwong equation of state? If so, what are they?
  2. What other factors need to be considered in understanding the limitations of the Redlich-Kwong eos?
  3. Is there a more robust EOS that can be used to solve for the compressibility factor, specifically for nitrogen, and can be implemented in Microsoft excel?
  4. Do you have access to the "Working with Non-Ideal Gases" article referenced and can I get a copy from you, please?

The macro:

enter image description here


The convergence of the iteration you are using becomes very slow below 93F. I might be inclined to switch to a binary chop instead. Something like:

Const pc = 33.5
Const tc = 126.2

Function n2z(p as Double, t as Double) as Double

  Dim zstart As Double
  Dim zend As Double
  Dim z As Double

  zstart = 1
  zend = 2
    z = (zstart + zend) / 2
    If zdiff(p, t, z) > 0 Then
      zstart = z
      zend = z
    End If
  Loop Until zend - zstart < 0.01

  n2z = z

End Function

Function zdiff(p As Double, t As Double, z As Double) As Double

  Dim tk As Double
  Dim pa As Double
  Dim zcal As Double
  Dim a As Double
  Dim b As Double
  Dim h As Double

  tk = (t - 32) * 5 / 9 + 273.15
  pa = p / 14.6959
  a = (0.4278 * (tc ^ 2.5)) / (pc * (tk ^ 2.5))
  b = (0.0867 * tc) / (pc * tk)
  h = b * pa / z
  zcal = 1 / (1 - h) - (a / b) * h / (1 + h)

  zdiff = zcal - z

End Function
| cite | improve this answer | |
  • $\begingroup$ Wow, this is great. I read a quick explanation about the binary chop, very powerful method. Two questions, how did you come about learning about the binary chop method? How did you create the code/scrolling window in your answer?-I will post the code for my question like so if I know how. $\endgroup$ – Armadillo Mar 18 '15 at 18:08
  • $\begingroup$ @jakemcgregor: the binary chop is an elementary technique I'm afraid. I learned it at my mother's knee (seriously: she was a scientist! :-). If you're going to be doing any scientific computing then you need to read up on basic numerical techniques. You get the scrolling code by indenting by four spaces. $\endgroup$ – John Rennie Mar 18 '15 at 18:15
  • $\begingroup$ @jakemcgregor: discussing code is frowned upon hereabouts as it should really be done on the Scientific Computing SE. I only answered because I was curious about the problem. Please don't post any more code in your question. $\endgroup$ – John Rennie Mar 18 '15 at 18:17
  • $\begingroup$ @jakemcgregor: but do feel free to click the tick symbol to mark the question as answered if you're happy with my suggestion. $\endgroup$ – John Rennie Mar 18 '15 at 18:18

If I may suggest, when you handle a pressure-explicit equation of state, it is always better to write the equation as function of the compressibility factor $Z=\frac{PV}{RT}$. In the case of the most commonly used equations of state, this leads to a cubic equation in $Z$ for which you can use Cardano method or, better, Newton method for a first root followed by polynomila deflation for the other one if it exists. This converges extremely fast to very high accuracy.

| cite | improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.