Plotting a p-V diagram
显示 更早的评论
I need to plot a p-V diagram for an ideal cycle using the ideal gas law: pV=mRT
Ive chosen arbitrary values of 373K and 273K for the max and min temperatures, 5kg for the mass, 0.2871 for R and [p1, V1] is [7.8378, 50]. Using this I can calculate the values for [p2 V2], [p3 V3] and [p4 V4]. However I need [p1 V1] and [p2 V2] to be connected by an isothermal and the same for [p3 V3] and [p4 V4]. Does anyone know how I can do this?? The plot should look like this:

Many thanks!
采纳的回答
更多回答(1 个)
Fernanda Silverio
2020-4-9
Hi,
This is correct for the Carnot cycle where you have the adiabatic transformation. For Stirling you should have isotherms, therefore create an array with VL elements with the same temperature.
Look at the difference
:

R = 0.2871;
m = 5;
VL = 10;
%Define Temperatures ( It only works correctly
% if the temperature vector is split into two separate
% ranges of equal differences. )
Th = 373; %K
Tc = 273; %K
Tm = (Th + Tc)/2;
%Define Volume Delta
V1 = 200;
V2 = 150;
Tv1 = linspace(Tc, Tm, VL); % Temp low -> Adiabatic transformation
Tv2 = linspace(Tm, Th, VL); % Temp high -> Adiabatic transformation
Vv1 = linspace(V2, V1, VL);
Thigh = zeros(1, 10) + Th;
Tlow = zeros(1, 10) + Tc;
%Ideal gases law
p = @(T,V) m*R*T./V;
%P-v Diagram
figure('DefaultAxesFontSize',12)
set(0,'DefaultTextFontSize',12)
plot(Vv1, p(Tv1,Vv1), '-k', 'LineWidth',2) %adiabatic
hold on
plot(Vv1, p(Thigh, Vv1), '-r', 'LineWidth',2); %isotherm
plot(Vv1, p(Tv2,Vv1), '-k', 'LineWidth',2) %adiabatic
plot(Vv1, p(Tlow, Vv1), '-r', 'LineWidth',2);%isotherm
%adiabatic
plot(Vv1(1)*[1 1], p([Tv1(1) Tv1(end)],[1 1]*Vv1(1)), '-k', 'LineWidth',2)
plot(Vv1(end)*[1 1], p([Tv2(1) Tv2(end)],[1 1]*Vv1(end)), '-k', 'LineWidth',2)
%isotherm
plot(Vv1(1)*[1 1], [p(Tc, Vv1(1)), p(Th, Vv1(1))], '-r', 'LineWidth',2)
text(mean(Vv1), p(Tc, mean(Vv1))+0.05, 'T cold');
plot(Vv1(end)*[1 1], [p(Tc, Vv1(end)), p(Th, Vv1(end))], '-r', 'LineWidth',2)
text(mean(Vv1), p(Th, mean(Vv1))+0.05, 'T hot');
%adiabatic
plot(V1, min(p(Tv1,Vv1)), 'k.', 'MarkerSize', 23) %POINT 1
text(V1+2, min(p(Tv1,Vv1)), '1');
plot(V2, max(p(Tv1,Vv1)), 'k.', 'MarkerSize', 23) %POINT 2
text(V2-3, max(p(Tv1,Vv1)), '2');
plot(V2, max(p(Tv2,Vv1)), 'k.', 'MarkerSize', 23) %POINT 3
text(V2-3, max(p(Tv2,Vv1)), '3');
plot(V1, min(p(Tv2,Vv1)), 'k.', 'MarkerSize', 23) %POINT 4
text(V1+2, min(p(Tv2,Vv1)), '4', 'FontSize',12);
%isotherm
plot(V1, min(p(Tlow,Vv1)), 'r.', 'MarkerSize', 23) %POINT 1
text(V1+2, min(p(Tlow,Vv1)), '1');
plot(V2, max(p(Tlow,Vv1)), 'r.', 'MarkerSize', 23) %POINT 2
text(V2-3, max(p(Tlow,Vv1)), '2');
plot(V2, max(p(Thigh,Vv1)), 'r.', 'MarkerSize', 23) %POINT 3
text(V2-3, max(p(Thigh,Vv1)), '3');
plot(V1, min(p(Thigh,Vv1)), 'r.', 'MarkerSize', 23) %POINT 4
text(V1+2, min(p(Thigh,Vv1)), '4');
set(gca,'XTick',[], 'YTick', []) % REMOVE VALUE FROM AXIS
hold off
grid
xlabel('V')
ylabel('p')
axis([135 215 1.7 3.8])
legend('adiabatic', 'isotherm')
类别
在 帮助中心 和 File Exchange 中查找有关 Thermodynamics and Heat Transfer 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
