Description
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 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:
Z
(1) the compressibility factor versus reduced temperature at fixed reduced pressure =0.35;
Z
T
r
P
r
(2) the compressibility factor versus reduced pressure at fixed reduced temperature =0.85;
Z
P
r
T
r
(3) the spinodal curve (locus of turning points, =0) and the binodal (saturation) curve in the – plane, with a zoom on the low-pressure region.
∂
P
r
∂Z
T
r
Z
P
r
Ethane is used throughout (=305.3K, =48.72bar, ). To study another compound, change , and . Other cubic equations of state, such as Peng–Robinson, can be used by changing the cubic and its coefficients.
T
c
P
c
ω=0.1
T
c
P
c
ω
Details
Details
In the Soave–Redlich–Kwong (SRK) equation of state, the compressibility factor occurs as a solution of the cubic equation:,where and , with , , , and .
f(Z)=-+(A-B-)Z-AB=0
3
Z
2
Z
2
B
A=
aP
2
(RT)
B=
bP
RT
a=0.42748α
2
(R)
T
c
P
c
b=0.08664R/
T
c
P
c
α=
2
(1+m(1-))
T
r
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); α=; compfact=(1-α)(1-); 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_]:=;a[Tval_]=0.42748α[Tval];b=0.08664;rhsSRKEqn[Tval_,V_]:=-;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[PmeanrhsSRKEqn[T,V],V]];P1[Tval_,V_]:=rhsSRKEqn[Tval,V];eqns[w1_?NumericQ,w3_?NumericQ]:={-NIntegrate[P1[T,V],{V,w1,w3},MaxRecursion1000,PrecisionGoal2]+P1[T,w1](w3-w1),P1[T,w1]-P1[T,w3]};sol=Quiet@FindRoot[eqns[w1,w3],{w1,V1},{w3,V3},WorkingPrecision6];{{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],AxesFalse,PlotStyle{Black,Thick},JoinedTrue,FrameLabel{Style["Pre",16,"Label"],Style["Z",16,"Label"]},FrameTrue,PlotRange{{0.001,1},{0.001,0.9995}},AspectRatio1],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;
texp
r
N1
α
2
1+κ1-
Tval/Tc
2
R
2
Tc
Pc
RTc
Pc
RTval
V-b
a[Tval]
V(V+b)
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/Pc1+m1-
Tre1
^2;B=bPre1Pc/(RTre1Tc);A=aPre1Pc/(RTre1Tc)^2;Given reduced pressure
Pre1=0.35;
In[]:=
solinit=NSolve[(fz1[Z,A,B]0)/.Tre12.,Z,Reals]
Out[]=
{{Z0.995379}}
In[]:=
eq1=fz1[Z,A,B]0/.Zz[s]/.Tre1Tre1[s];eq2=1-[s];init1=Tre1[0]2;init2=z[0]First[Z/.solinit];
2
Tre1'[s]
2
′
z
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 versus plot shows the isobar for the reduced pressure =0.35, including its unstable part. The green dots are the two turning points (spinodal limits, where , at ≈0.744 and ≈0.930); the dashed blue segment between them is the unstable branch. Vapor–liquid coexistence at this pressure occurs at the saturation temperature (≈0.85), where the liquid and vapor values of 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).
Z
T
r
P
r
/Z=0
T
r
T
r
T
r
T
r
Z
ParametricPlot
Out[]=
Clear[Pre1]
Reduced temperature
Tre1=0.85;
In[]:=
solinit1b=NSolve[(fz1[Z,A,B]0)/.Pre1->2,Z,Reals]
Out[]=
{{Z0.315531}}
In[]:=
eq1=fz1[Z,A,B]0/.Zz[s]/.Pre1Pre1[s];eq2=1-[s];init1=Pre1[0]2;init2=z[0]First[Z/.solinit1b];
2
Pre1'[s]
2
′
z
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
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
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
by Housam Binous
Wolfram Community, STAFF PICKS, October 18, 2026
https://community.wolfram.com/t/28359/1