Description

This notebook computes the vapor–liquid two-phase region of ethane with the Soave–Redlich–Kwong (SRK) equation of state (see the Details section). Pseudo-arclength continuation, implemented with NDSolve and WhenEvent, follows the root
Z
of the SRK cubic through its turning points, so the full S-shaped loop is traced, including the metastable and unstable branches. The notebook plots:
(1) the compressibility factor
Z
versus reduced temperature
T
r
at fixed reduced pressure
P
r
=0.35
;
(2) the compressibility factor
Z
versus reduced pressure
P
r
at fixed reduced temperature
T
r
=0.85
;
(3) the spinodal curve (locus of turning points,
∂
P
r
∂Z
T
r
=0
) and the binodal (saturation) curve in the
Z
–
P
r
plane, with a zoom on the low-pressure region.
Ethane is used throughout (
T
c
=305.3K
,
P
c
=48.72bar
,
ω=0.1
). To study another compound, change
T
c
,
P
c
and
ω
. Other cubic equations of state, such as Peng–Robinson, can be used by changing the cubic and its coefficients.

Details

In the Soave–Redlich–Kwong (SRK) equation of state, the compressibility factor occurs as a solution of the cubic equation:​
f(Z)=
3
Z
-
2
Z
+(A-B-
2
B
)Z-AB=0
,where
A=
aP
2
(RT)
and
B=
bP
RT
, with
a=0.42748α
2
(R
T
c
)

P
c
,
b=0.08664R
T
c
/
P
c
,
α=
2
(1+m(1-
T
r
))
, and
m=0.480+1.574ω-0.176
2
ω
.
In[]:=
GridGeneration[N1_?EvenQ,T1_,TN_,r_]:=Module{texp,α,compfact,deltaT,xe,xe1,grid,i},​​ texp=1(N1-1);​​ α=
texp
r
;​​ compfact=(1-α)(1-
N1
α
);​​ deltaT=(TN-T1)compfact;​​ For[xe=T1;grid={xe};i=2,i<N1+2,i++,xe1=xe+deltaT;deltaT=deltaTα;grid={grid,xe1};xe=xe1];​​ Flatten[grid];​​SRKVaporPressure1[T_,Tc_,Pc_,ω_]:=Module{R=8.3144472,eqns,V,P1,a,b,​​κ,α,V1,V2,V3,x,Z1,roots,Vvalues,Tval,Pmean,Pvalues,rhsSRKEqn,Vmean,Vmax,Vmin},​​​​κ=0.480+1.574ω-0.176ω^2;​​α[Tval_]:=
2
1+κ1-
Tval/Tc

;​​a[Tval_]=0.42748
2
R
2
Tc
Pc
α[Tval];​​b=0.08664
RTc
Pc
;​​rhsSRKEqn[Tval_,V_]:=
RTval
V-b
-
a[Tval]
V(V+b)
;​​​​If[T>0.9999Tc,Print["You have selected a temperature T > 0.9999 Tc"],Vvalues=Take[Quiet[Solve[D[rhsSRKEqn[T,V],V]0,V]],-2];​​{Vmin,Vmax}=V/.Vvalues;​​​​Pvalues=rhsSRKEqn[T,V]/.Vvalues;​​​​If[First[Pvalues]>0,Pmean=Mean[Pvalues],Pmean=Last[Pvalues]/2];​​​​{V1,V2,V3}=V/.Quiet[Solve[PmeanrhsSRKEqn[T,V],V]];​​​​P1[Tval_,V_]:=rhsSRKEqn[Tval,V];​​eqns[w1_?NumericQ,w3_?NumericQ]:={-NIntegrate[P1[T,V],{V,w1,w3},MaxRecursion1000,PrecisionGoal2]+P1[T,w1](w3-w1),P1[T,w1]-P1[T,w3]};​​​​sol=Quiet@FindRoot[eqns[w1,w3],{w1,V1},{w3,V3},WorkingPrecision6];​​{{P1[T,w1/.sol]/Pc,w1P1[T,w1/.sol]/(RT)},{P1[T,w1/.sol]/Pc,w3P1[T,w1/.sol]/(RT)}}/.sol];​​​​BinodalCurve1[T_,Tc_,Pc_,ω_,Prmin_]:=​​Module[{R=8.3144472,myplotRange,Tmin,PVvalues,Vmin,Vmax,Vc,Psat,volumes,Pmin,VExtremevalues,PExmin,Tmin2,Vexc1,Vexc2},​​​​Tmin=T-0.02T;​​​​myplotRange:=GridGeneration[20,Tmin,0.9999Tc,0.08];​​​​{ListPlot[SortBy[Union[Flatten[Table[SRKVaporPressure1[i,Tc,Pc,ω],{i,myplotRange}],1]],Last],AxesFalse,PlotStyle{Black,Thick},JoinedTrue,​​FrameLabel{Style["Pre",16,"Label"],Style["Z",16,"Label"]},FrameTrue,PlotRange{{0.001,1},{0.001,0.9995}},AspectRatio1],SortBy[Union[Flatten[Table[SRKVaporPressure1[i,Tc,Pc,ω],{i,myplotRange}],1]],Last]}];​​​​fz1[Z_,A_,B_]:=Z^3-Z^2+(A-B-B^2)Z-AB;
Universal gas constant
R=8.314;
Ethane properties
Tc=305.3;Pc=48.72;ω=0.1;Zc=0.279;
In[]:=
b=0.08664RTc/Pc;​​m=0.480+1.574ω-0.176ω^2;​​a=0.42748(RTc)^2/Pc1+m1-
Tre1
^2;​​B=bPre1Pc/(RTre1Tc);​​A=aPre1Pc/(RTre1Tc)^2;
Given reduced pressure
Pre1=0.35;
In[]:=
solinit=NSolve[(fz1[Z,A,B]0)/.Tre12.,Z,Reals]
Out[]=
{{Z0.995379}}
In[]:=
eq1=fz1[Z,A,B]0/.Zz[s]/.Tre1Tre1[s];​​eq2=
2
Tre1'[s]
1-
2
′
z
[s]
;​​init1=Tre1[0]2;​​init2=z[0]First[Z/.solinit];
In[]:=
{sol,points}=Reap@NDSolve[{eq1,eq2,init1,init2,Tre1'[0]1,z'[0]0,WhenEvent[Tre1'[s]0,Sow[s]]},{z[s],Tre1[s]},{s,-50,50}];
The
Z
versus
T
r
plot shows the isobar for the reduced pressure
P
r
=0.35
, including its unstable part. The green dots are the two turning points (spinodal limits, where

T
r
/Z=0
, at
T
r
≈0.744
and
T
r
≈0.930
); the dashed blue segment between them is the unstable branch. Vapor–liquid coexistence at this pressure occurs at the saturation temperature (
T
r
≈0.85
), where the liquid and vapor values of
Z
correspond to equal Gibbs energy; this point is not marked in this plot. The portions of the solid curve between saturation and each green dot are metastable (superheated liquid and supercooled vapor).
ParametricPlot

Out[]=
Clear[Pre1]
Reduced temperature
Tre1=0.85;
In[]:=
solinit1b=NSolve[(fz1[Z,A,B]0)/.Pre1->2,Z,Reals]
Out[]=
{{Z0.315531}}
In[]:=
eq1=fz1[Z,A,B]0/.Zz[s]/.Pre1Pre1[s];​​eq2=
2
Pre1'[s]
1-
2
′
z
[s]
;​​init1=Pre1[0]2;​​init2=z[0]First[Z/.solinit1b];
In[]:=
{sol,points}=Reap@NDSolve[{eq1,eq2,init1,init2,Pre1'[0]1,z'[0]0,WhenEvent[Pre1'[s]0,Sow[s]]},{z[s],Pre1[s]},{s,-50,50}];
p2=ParametricPlot{Pre1[s],z[s]}/.sol,{s,-50,50},

Out[]=
Zoom

References

[1] W.-G. Dong and J. H. Lienhard, “Corresponding States Correlation of Saturated and Metastable Properties,” The Canadian Journal of Chemical Engineering, 64(1), 1986 pp. 158–161. doi:10.1002/cjce.5450640123.

CITE THIS NOTEBOOK

The law of corresponding states for hydrocarbons : the two-phase region​
by Housam Binous​
Wolfram Community, STAFF PICKS, October 18, 2026
https://community.wolfram.com/t/28359/1