You are now following this question
- You will see updates in your followed content feed.
- You may receive emails, depending on your communication preferences.
I need a help to plots pressure vs. Temp at equilibrium from the attached paper and in the same graph another plot using Peng Robinson model.
5 views (last 30 days)
Show older comments
Hanadi
on 13 Dec 2023
plot (p, T)
# in the same figure, plot using the model from the paper for P and T and compare it with Peng Robinson model. at equilibrium
Accepted Answer
Sam Chak
on 14 Dec 2023
I'm not an expert in gas laws, but when the data is available (for example, in the fictional dataset below), you can plot the graph as desired. I cannot find any equilibrium in this sample dataset. Additionally, I'm unfamiliar with the Peng–Robinson model because the formula is not provided. I am unsure if this Peng–Robinson equation in this Wikipedia article is the same. If you provide the parameters in your question above, you can also plot it on the same graph for comparison purposes, using the 'hold on' feature.
data = [
223.160 0.0929
233.159 0.1486
233.159 0.1487
243.146 0.2285
243.156 0.2283
253.151 0.3380
253.152 0.3367
253.154 0.3378
253.154 0.3379
263.147 0.4832
263.149 0.4830
263.152 0.4830
263.152 0.4833
273.146 0.6710
273.150 0.6710
273.150 0.6712
273.151 0.6714
283.144 0.9088
283.144 0.9092
293.141 1.2047
293.141 1.2056
293.184 1.2066
298.144 1.3774
298.183 1.3800
303.139 1.5678
303.139 1.5679
303.139 1.5692
303.181 1.5701
303.181 1.5705
313.136 2.0075
313.136 2.0077
313.136 2.0078
313.136 2.0080
313.136 2.0082
313.136 2.0089
313.136 2.0090
313.136 2.0094
317.148 2.2090
318.138 2.2606
319.638 2.3411
323.133 2.5360
323.133 2.5363
323.133 2.5364
323.133 2.5368
323.133 2.5369
323.133 2.5370
323.250 2.5436
328.138 2.8398
328.176 2.8419
333.130 3.1700
333.130 3.1706
333.130 3.1710
333.130 3.1712
333.130 3.1715
333.251 3.1801
334.252 3.2505
335.134 3.3127
336.252 3.3967
337.133 3.4605
337.133 3.4621
338.252 3.5472];
%% extract the data
T = data(:,1);
P = data(:,2);
%% plot the graph
plot(P, T), grid on
title('Temperature vs. Pressure')
xlabel('Pressure (MPa)'), ylabel('Temperature (K)')
15 Comments
Hanadi
on 14 Dec 2023
Table 1 for Pressure and Temperature
Table 2 for pressure, Temperature and volume at equilibrium.
Peng-Robinson equation is
p = R T/ (v-b) - a /((v+b)+b(v-b))
b = 0.0778 R^2 Tc^2 / Pc
a = 0.45724 R^2 Tc^2 alph / Pc
alph = (1+k(1-sqrt(Tc)))^2
k= 0.37464+1.54266 w-0.26992 w^2
R=8.341
Tc= 339.45 K
Pc= 3642.77 KPa
w= 0.2986
Can I have two figures ?
the first plot is from table 1 using the model in the attached paper and Peng-Robenson model.
the second plot is from table 2 using the model in the attached paper and Peng-Robenson model.
Hanadi
on 14 Dec 2023
Edited: Walter Roberson
on 14 Dec 2023
okay I will put them
Peng-Robinson equation is
p = 8.314 * T/ (v- 169942.3108 ) - 167766846.8 /((v+ 169942.3108 )+ 169942.3108 (v- 169942.3108 ))
Sam Chak
on 14 Dec 2023
Edited: Sam Chak
on 14 Dec 2023
Great. Now, we need the value of v to plot the graph. When I input the Peng–Robinson equation (according to your formula) into the code without the value of v, it threw an error message.
%% Peng–Robinson equation
p = 8.314*T/(v - 169942.3108) - 167766846.8/((v + 169942.3108) + 169942.3108*(v - 169942.3108));
Unrecognized function or variable 'v'.
Hanadi
on 14 Dec 2023
so, I think you should only use table 2, because we have the volume...
in the same graph plot pressure and temperature from table 2, and plot using Peng-Robinson by taking the volume and Temperature from table 2
Sam Chak
on 14 Dec 2023
Oh, I see. Can you input the data from Table II into the grey field? Click this icon
to toggle the grey field.
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1569159/image.png)
Also, the third column in Table II is Density. I'm unfamiliar with Physics Gas Theory. Could you please show me how to calculate the Volume of gas without knowing the Mass of the gas?
Torsten
on 14 Dec 2023
Edited: Torsten
on 15 Dec 2023
My guess is that the universal gas constant is not correct for the units used for P and rho in the Peng-Robinson equation-of-state.
M = [280.148 0.8087 50.98
282.148 0.8176 50.98
303.139 0.9086 50.93
333.130 1.0324 50.86
343.127 1.0732 50.83
343.127 1.0732 50.83
353.125 1.1133 50.81
363.122 1.1517 50.78
373.118 1.1917 50.76
393.115 1.2687 50.71
413.111 1.3464 50.66
433.108 1.4198 50.61
453.105 1.4983 50.55
463.105 1.5352 50.53
473.104 1.5694 50.50
298.144 1.3543 88.74
313.136 1.4815 88.68
333.129 1.6423 88.60
353.125 1.7971 88.51
373.120 1.9469 88.42
393.115 2.0934 88.33
413.111 2.2368 88.25
433.108 2.3777 88.15
453.106 2.5158 88.06
463.105 2.5782 88.02
473.103 2.6462 87.97
323.133 2.4778 187.16
333.130 2.6918 187.07
343.128 2.8973 186.98
353.125 3.0955 186.90
363.123 3.2897 186.80
373.120 3.4793 186.71
383.117 3.6659 186.62
393.115 3.8500 186.52
403.113 4.0315 186.43
413.096 4.2113 186.33
423.110 4.3893 186.24
433.108 4.5653 186.14
453.106 4.9132 185.94
473.104 5.2557 185.75
328.136 2.7507 217.07
333.130 2.8804 217.02
343.128 3.1307 216.92
353.125 3.3720 216.81
363.122 3.6070 216.70
373.120 3.8369 216.60
383.117 4.0627 216.49
393.115 4.2851 216.38
403.113 4.5046 216.27
413.111 4.7215 216.16
423.110 4.9359 216.05
433.108 5.1482 215.93
443.107 5.3590 215.82
453.106 5.5681 215.71
473.104 5.9819 215.48
338.133 3.4746 346.47
343.128 3.7078 346.38
353.125 4.1544 346.21
363.122 4.5877 346.04
373.120 5.0116 345.87
383.117 5.4282 345.69
393.115 5.8368 345.52
403.113 6.2456 345.34
413.111 6.6476 345.16
423.110 7.0463 344.98
433.108 7.4415 344.80
443.107 7.8342 344.62
453.106 8.2232 344.43
473.104 8.9952 344.06
339.483 3.6320 449.66
343.128 3.8638 449.58
353.125 4.4800 449.35
363.122 5.0833 449.13
373.114 5.6791 448.90
383.117 6.2699 448.67
393.115 6.8559 448.44
403.110 7.4375 448.21
413.111 8.0157 447.98
423.110 8.5901 447.74
433.108 9.1613 447.51
453.106 10.2950 447.03
473.104 11.4172 446.54
339.283 3.6298 567.41
339.383 3.6364 567.41
340.252 3.7060 567.38
341.246 3.7847 567.35
342.253 3.8643 567.32
343.254 3.9436 567.30
343.254 3.9433 567.30
353.256 4.7442 567.01
363.255 5.5492 566.73
373.237 6.3547 566.44
383.258 7.1616 566.15
393.259 7.9540 565.85
413.261 9.5565 565.26
433.262 11.1515 564.66
453.263 12.7424 564.05
473.265 14.3170 563.43
333.145 3.1762 704.48
336.133 3.3908 704.38
338.133 3.5423 704.31
339.133 3.6316 704.28
340.128 3.7323 704.24
341.132 3.8353 704.21
342.132 3.9397 704.17
343.128 4.0445 704.13
353.115 5.1362 703.78
373.120 7.4227 703.05
393.115 9.7631 702.32
413.111 12.1260 701.57
433.108 14.4957 700.81
453.203 16.8750 700.03
339.133 3.6695 756.32
343.126 4.1431 756.16
353.125 5.3898 755.78
363.122 6.6820 755.39
373.120 7.9998 754.99
383.124 9.3353 754.60
393.115 10.6792 754.20
403.124 12.0331 753.79
413.111 13.3882 753.39
423.110 14.7467 752.98
433.108 16.1064 752.56
439.963 17.0384 752.28
335.140 3.3660 848.73
338.133 3.8158 848.60
343.128 4.5902 848.38
348.130 5.3874 848.16
353.133 6.1998 847.94
363.122 7.8533 847.50
373.120 9.5370 847.05
383.117 11.2391 846.60
393.133 12.9576 846.14
413.111 16.4039 845.22
416.116 16.9240 845.08
333.130 3.5409 924.19
338.133 4.4970 923.95
343.118 5.4717 923.71
348.130 6.4679 923.47
353.128 7.4740 923.23
358.128 8.4908 922.98
363.114 9.5120 922.73
368.125 10.5448 922.49
373.121 11.5796 922.24
378.123 12.6205 921.99
383.104 13.6591 921.74
393.115 15.7549 921.23
328.142 3.3843 988.22
333.130 4.5304 987.96
338.133 5.7026 987.70
343.128 6.8878 987.43
348.163 8.0951 987.17
353.125 9.2934 986.90
358.128 10.5115 986.64
363.122 11.7320 986.37
368.129 12.9609 986.10
373.120 14.1900 985.83
378.123 15.4247 985.56
383.117 16.6599 985.29
306.530 1.8664 1145.32
308.181 2.4621 1145.25
313.180 4.2649 1144.94
318.178 6.0758 1144.59
323.177 7.8960 1144.31
328.176 9.7266 1143.96
333.175 11.5449 1143.64
346.031 16.2723 1142.82];
T = M(:,1);
P = M(:,2);
rho = M(:,3);
[P,I] = sort(P);
T = T(I);
rho = rho(I);
v = 1./rho;
R=8.3143/(120.02e-3)*1e-6; %MJ/(kg*K)
Tc= 339.45; %K
Pc= 3642.77e-3; %MPa
w= 0.2986;
k= 0.37464+1.54266*w-0.26992*w^2;
alph = (1+k*(1-sqrt(T/Tc))).^2;
a = 0.45724*R^2*Tc^2*alph / Pc;
b = 0.0778*R^2*Tc^2 / Pc;
pPR = R*T./ (v-b) - a ./(v.^2+2*b*v-b^2);
hold on
plot(P,T)
[pPR,I] = sort(pPR);
plot(pPR,T(I))
hold off
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1569502/image.png)
Sam Chak
on 15 Dec 2023
Thanks, @Torsten, for showing the plots. There is a discrepancy in the formula for the parameter 'b' in the Peng–Robinson equation of state, and the one supplied by the OP. I'm unsure which one is correct. Please edit the code as necessary.
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1569547/image.png)
%% Data
M = [280.148 0.8087 50.98
282.148 0.8176 50.98
303.139 0.9086 50.93
333.130 1.0324 50.86
343.127 1.0732 50.83
343.127 1.0732 50.83
353.125 1.1133 50.81
363.122 1.1517 50.78
373.118 1.1917 50.76
393.115 1.2687 50.71
413.111 1.3464 50.66
433.108 1.4198 50.61
453.105 1.4983 50.55
463.105 1.5352 50.53
473.104 1.5694 50.50
298.144 1.3543 88.74
313.136 1.4815 88.68
333.129 1.6423 88.60
353.125 1.7971 88.51
373.120 1.9469 88.42
393.115 2.0934 88.33
413.111 2.2368 88.25
433.108 2.3777 88.15
453.106 2.5158 88.06
463.105 2.5782 88.02
473.103 2.6462 87.97
323.133 2.4778 187.16
333.130 2.6918 187.07
343.128 2.8973 186.98
353.125 3.0955 186.90
363.123 3.2897 186.80
373.120 3.4793 186.71
383.117 3.6659 186.62
393.115 3.8500 186.52
403.113 4.0315 186.43
413.096 4.2113 186.33
423.110 4.3893 186.24
433.108 4.5653 186.14
453.106 4.9132 185.94
473.104 5.2557 185.75
328.136 2.7507 217.07
333.130 2.8804 217.02
343.128 3.1307 216.92
353.125 3.3720 216.81
363.122 3.6070 216.70
373.120 3.8369 216.60
383.117 4.0627 216.49
393.115 4.2851 216.38
403.113 4.5046 216.27
413.111 4.7215 216.16
423.110 4.9359 216.05
433.108 5.1482 215.93
443.107 5.3590 215.82
453.106 5.5681 215.71
473.104 5.9819 215.48
338.133 3.4746 346.47
343.128 3.7078 346.38
353.125 4.1544 346.21
363.122 4.5877 346.04
373.120 5.0116 345.87
383.117 5.4282 345.69
393.115 5.8368 345.52
403.113 6.2456 345.34
413.111 6.6476 345.16
423.110 7.0463 344.98
433.108 7.4415 344.80
443.107 7.8342 344.62
453.106 8.2232 344.43
473.104 8.9952 344.06
339.483 3.6320 449.66
343.128 3.8638 449.58
353.125 4.4800 449.35
363.122 5.0833 449.13
373.114 5.6791 448.90
383.117 6.2699 448.67
393.115 6.8559 448.44
403.110 7.4375 448.21
413.111 8.0157 447.98
423.110 8.5901 447.74
433.108 9.1613 447.51
453.106 10.2950 447.03
473.104 11.4172 446.54
339.283 3.6298 567.41
339.383 3.6364 567.41
340.252 3.7060 567.38
341.246 3.7847 567.35
342.253 3.8643 567.32
343.254 3.9436 567.30
343.254 3.9433 567.30
353.256 4.7442 567.01
363.255 5.5492 566.73
373.237 6.3547 566.44
383.258 7.1616 566.15
393.259 7.9540 565.85
413.261 9.5565 565.26
433.262 11.1515 564.66
453.263 12.7424 564.05
473.265 14.3170 563.43
333.145 3.1762 704.48
336.133 3.3908 704.38
338.133 3.5423 704.31
339.133 3.6316 704.28
340.128 3.7323 704.24
341.132 3.8353 704.21
342.132 3.9397 704.17
343.128 4.0445 704.13
353.115 5.1362 703.78
373.120 7.4227 703.05
393.115 9.7631 702.32
413.111 12.1260 701.57
433.108 14.4957 700.81
453.203 16.8750 700.03
339.133 3.6695 756.32
343.126 4.1431 756.16
353.125 5.3898 755.78
363.122 6.6820 755.39
373.120 7.9998 754.99
383.124 9.3353 754.60
393.115 10.6792 754.20
403.124 12.0331 753.79
413.111 13.3882 753.39
423.110 14.7467 752.98
433.108 16.1064 752.56
439.963 17.0384 752.28
335.140 3.3660 848.73
338.133 3.8158 848.60
343.128 4.5902 848.38
348.130 5.3874 848.16
353.133 6.1998 847.94
363.122 7.8533 847.50
373.120 9.5370 847.05
383.117 11.2391 846.60
393.133 12.9576 846.14
413.111 16.4039 845.22
416.116 16.9240 845.08
333.130 3.5409 924.19
338.133 4.4970 923.95
343.118 5.4717 923.71
348.130 6.4679 923.47
353.128 7.4740 923.23
358.128 8.4908 922.98
363.114 9.5120 922.73
368.125 10.5448 922.49
373.121 11.5796 922.24
378.123 12.6205 921.99
383.104 13.6591 921.74
393.115 15.7549 921.23
328.142 3.3843 988.22
333.130 4.5304 987.96
338.133 5.7026 987.70
343.128 6.8878 987.43
348.163 8.0951 987.17
353.125 9.2934 986.90
358.128 10.5115 986.64
363.122 11.7320 986.37
368.129 12.9609 986.10
373.120 14.1900 985.83
378.123 15.4247 985.56
383.117 16.6599 985.29
306.530 1.8664 1145.32
308.181 2.4621 1145.25
313.180 4.2649 1144.94
318.178 6.0758 1144.59
323.177 7.8960 1144.31
328.176 9.7266 1143.96
333.175 11.5449 1143.64
346.031 16.2723 1142.82];
%% Data extraction
T = M(:,1); % extract Temperature data
P = M(:,2); % extract Pressure data
rho = M(:,3); % extract Density data
[P, I] = sort(P); % sorted Pressure [MPa]
T = T(I); % sorted Temperature [K]
rho = rho(I); % sorted Density [kg/m³]
v = 1./rho; % specific volume [m³/kg]
%% Parameters
R = 8.314462618/(120.02e-3)*1e-6; % Gas constant [MJ/(kg*K)]
Tc = 339.45; % Critical Temperature [K]
Pc = 3642.77e-3; % Critical Pressure [MPa]
omega = 0.2986;
kappa = 0.37464 + 1.54266*omega - 0.26992*omega^2;
alpha = (1 + kappa*(1 - sqrt(T/Tc))).^2;
a = 0.45724*(R^2*Tc^2)/Pc; % parameter a in P–R EoS (Wiki)
% b = 0.07780*(R^2*Tc^2)/Pc; % parameter b (defined by OP)
b = 0.07780*(R*Tc)/Pc; % parameter b in P–R EoS (Wiki)
%% Peng–Robinson equation of state
pPR = (R*T)./(v - b) - (a*alpha)./(v.^2 + 2*b*v - b^2);
%% Graphing
hold on
plot(P, T), grid on
[pPR,I] = sort(pPR);
plot(pPR, T(I)), grid on
hold off
xlabel Pressure, ylabel Temperature
legend('Data', 'Peng–Robinson', 'location', 'SE')
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1569552/image.png)
Hanadi
on 15 Dec 2023
Edited: Hanadi
on 15 Dec 2023
Thank you for the plot.
I have another question related to the same article... table 1 is showing vapor pressure (TWO Phases at equilibrium). How can I plot the graph including also PR model.... I need to compare them... similar to the last graph that you plot ...This the data from table 1
Temp. (K)
223.160 233.159 233.159 243.146 243.156 253.151 253.152 253.154 253.154 263.147 263.149 263.152 263.152 273.146 273.150 273.150 273.151 283.144 283.144 293.141 293.141 293.184 298.144 298.183
303.139 303.139 303.139 303.181 303.181 313.136 313.136 313.136 313.136 313.136 313.136 313.136 313.136 317.148 318.138 319.638 323.133 323.133 323.133 323.133 323.133 323.133 323.250 328.138 328.176 333.130 333.130 333.130 333.130 333.130 333.251 334.252 335.134 336.252 337.133 337.133 338.252
Press. (MPa)
0.0929 0.1486 0.1487 0.2285 0.2283 0.3380 0.3367 0.3378 0.3379 0.4832 0.4830 0.4830 0.4833 0.6710 0.6710 0.6712 0.6714 0.9088 0.9092
1.2047 1.2056 1.2066 1.3774 1.3800 1.5678 1.5679 1.5692 1.5701 1.5705 2.0075 2.0077 2.0078 2.0080 2.0082 2.0089 2.0090 2.0094 2.2090 2.2606 2.3411 2.5360 2.5363 2.5364 2.5368 2.5369 2.5370 2.5436 2.8398 2.8419 3.1700 3.1706 3.1710 3.1712 3.1715 3.1801 3.2505 3.3127 3.3967 3.4605 3.4621 3.5472
Torsten
on 15 Dec 2023
Edited: Torsten
on 15 Dec 2023
We need to know how to compute the density at saturation conditions in order to apply PR (i.e. compute pressure from temperature and density).
Thank you for finding another error in the OPs coding.
For comparison, it might be better to plot Pressure against Temperature:
%% Data
M = [280.148 0.8087 50.98
282.148 0.8176 50.98
303.139 0.9086 50.93
333.130 1.0324 50.86
343.127 1.0732 50.83
343.127 1.0732 50.83
353.125 1.1133 50.81
363.122 1.1517 50.78
373.118 1.1917 50.76
393.115 1.2687 50.71
413.111 1.3464 50.66
433.108 1.4198 50.61
453.105 1.4983 50.55
463.105 1.5352 50.53
473.104 1.5694 50.50
298.144 1.3543 88.74
313.136 1.4815 88.68
333.129 1.6423 88.60
353.125 1.7971 88.51
373.120 1.9469 88.42
393.115 2.0934 88.33
413.111 2.2368 88.25
433.108 2.3777 88.15
453.106 2.5158 88.06
463.105 2.5782 88.02
473.103 2.6462 87.97
323.133 2.4778 187.16
333.130 2.6918 187.07
343.128 2.8973 186.98
353.125 3.0955 186.90
363.123 3.2897 186.80
373.120 3.4793 186.71
383.117 3.6659 186.62
393.115 3.8500 186.52
403.113 4.0315 186.43
413.096 4.2113 186.33
423.110 4.3893 186.24
433.108 4.5653 186.14
453.106 4.9132 185.94
473.104 5.2557 185.75
328.136 2.7507 217.07
333.130 2.8804 217.02
343.128 3.1307 216.92
353.125 3.3720 216.81
363.122 3.6070 216.70
373.120 3.8369 216.60
383.117 4.0627 216.49
393.115 4.2851 216.38
403.113 4.5046 216.27
413.111 4.7215 216.16
423.110 4.9359 216.05
433.108 5.1482 215.93
443.107 5.3590 215.82
453.106 5.5681 215.71
473.104 5.9819 215.48
338.133 3.4746 346.47
343.128 3.7078 346.38
353.125 4.1544 346.21
363.122 4.5877 346.04
373.120 5.0116 345.87
383.117 5.4282 345.69
393.115 5.8368 345.52
403.113 6.2456 345.34
413.111 6.6476 345.16
423.110 7.0463 344.98
433.108 7.4415 344.80
443.107 7.8342 344.62
453.106 8.2232 344.43
473.104 8.9952 344.06
339.483 3.6320 449.66
343.128 3.8638 449.58
353.125 4.4800 449.35
363.122 5.0833 449.13
373.114 5.6791 448.90
383.117 6.2699 448.67
393.115 6.8559 448.44
403.110 7.4375 448.21
413.111 8.0157 447.98
423.110 8.5901 447.74
433.108 9.1613 447.51
453.106 10.2950 447.03
473.104 11.4172 446.54
339.283 3.6298 567.41
339.383 3.6364 567.41
340.252 3.7060 567.38
341.246 3.7847 567.35
342.253 3.8643 567.32
343.254 3.9436 567.30
343.254 3.9433 567.30
353.256 4.7442 567.01
363.255 5.5492 566.73
373.237 6.3547 566.44
383.258 7.1616 566.15
393.259 7.9540 565.85
413.261 9.5565 565.26
433.262 11.1515 564.66
453.263 12.7424 564.05
473.265 14.3170 563.43
333.145 3.1762 704.48
336.133 3.3908 704.38
338.133 3.5423 704.31
339.133 3.6316 704.28
340.128 3.7323 704.24
341.132 3.8353 704.21
342.132 3.9397 704.17
343.128 4.0445 704.13
353.115 5.1362 703.78
373.120 7.4227 703.05
393.115 9.7631 702.32
413.111 12.1260 701.57
433.108 14.4957 700.81
453.203 16.8750 700.03
339.133 3.6695 756.32
343.126 4.1431 756.16
353.125 5.3898 755.78
363.122 6.6820 755.39
373.120 7.9998 754.99
383.124 9.3353 754.60
393.115 10.6792 754.20
403.124 12.0331 753.79
413.111 13.3882 753.39
423.110 14.7467 752.98
433.108 16.1064 752.56
439.963 17.0384 752.28
335.140 3.3660 848.73
338.133 3.8158 848.60
343.128 4.5902 848.38
348.130 5.3874 848.16
353.133 6.1998 847.94
363.122 7.8533 847.50
373.120 9.5370 847.05
383.117 11.2391 846.60
393.133 12.9576 846.14
413.111 16.4039 845.22
416.116 16.9240 845.08
333.130 3.5409 924.19
338.133 4.4970 923.95
343.118 5.4717 923.71
348.130 6.4679 923.47
353.128 7.4740 923.23
358.128 8.4908 922.98
363.114 9.5120 922.73
368.125 10.5448 922.49
373.121 11.5796 922.24
378.123 12.6205 921.99
383.104 13.6591 921.74
393.115 15.7549 921.23
328.142 3.3843 988.22
333.130 4.5304 987.96
338.133 5.7026 987.70
343.128 6.8878 987.43
348.163 8.0951 987.17
353.125 9.2934 986.90
358.128 10.5115 986.64
363.122 11.7320 986.37
368.129 12.9609 986.10
373.120 14.1900 985.83
378.123 15.4247 985.56
383.117 16.6599 985.29
306.530 1.8664 1145.32
308.181 2.4621 1145.25
313.180 4.2649 1144.94
318.178 6.0758 1144.59
323.177 7.8960 1144.31
328.176 9.7266 1143.96
333.175 11.5449 1143.64
346.031 16.2723 1142.82];
%% Data extraction
T = M(:,1); % extract Temperature data
P = M(:,2); % extract Pressure data
rho = M(:,3); % extract Density data
[T, I] = sort(T); % sorted Temperature [K]
P = P(I); % sorted Pressure [MPa]
rho = rho(I); % sorted Density [kg/m³]
v = 1./rho; % specific volume [m³/kg]
%% Parameters
R = 8.314462618/(120.02e-3)*1e-6; % Gas constant [MJ/(kg*K)]
Tc = 339.45; % Critical Temperature [K]
Pc = 3642.77e-3; % Critical Pressure [MPa]
omega = 0.2986;
kappa = 0.37464 + 1.54266*omega - 0.26992*omega^2;
alpha = (1 + kappa*(1 - sqrt(T/Tc))).^2;
a = 0.45724*(R^2*Tc^2)/Pc; % parameter a in P–R EoS (Wiki)
% b = 0.07780*(R^2*Tc^2)/Pc; % parameter b (defined by OP)
b = 0.07780*(R*Tc)/Pc; % parameter b in P–R EoS (Wiki)
%% Peng–Robinson equation of state
pPR = (R*T)./(v - b) - (a*alpha)./(v.^2 + 2*b*v - b^2);
%% Graphing
hold on
plot(T, P), grid on
plot(T, pPR), grid on
hold off
xlabel Temperature, ylabel Pressure
legend('Data', 'Peng–Robinson', 'location', 'SE')
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1569812/image.png)
Sam Chak
on 15 Dec 2023
Love you, Torsten, I learned new things from you 👍. Please move your solution to the Answer.
Hanadi
on 15 Dec 2023
final request can you plot (pressure vs. density) from the previous data using the paper data and PR?
More Answers (0)
See Also
Categories
Find more on 2-D and 3-D Plots in Help Center and File Exchange
Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!An Error Occurred
Unable to complete the action because of changes made to the page. Reload the page to see its updated state.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)
Asia Pacific
- Australia (English)
- India (English)
- New Zealand (English)
- 中国
- 日本Japanese (日本語)
- 한국Korean (한국어)