MATLAB/Engineering thermodynamics/Trouble with MATLAB code

From Wikiversity
Jump to navigation Jump to search

There seems to be a bug in Xsteam when T_hs is called in a certain regime. I believe this occurs in the saturated regime near h = 1500 kJ/kg between s = 3.17 and 3.18 kJ/kg

code[edit | edit source]

% Run this code in a folder with Xsteam.m and you will see a flaw with 'T_hs'
close all; clear all;clc;
%T_hs	Temperture as a function of enthalpy and entropy
contours = 0
for h=300:400:1900
    contours=contours+1;
h
sa=linspace(0,8,100);%
N=size(sa,2);
Ta = zeros(N,1);
for n=1:N
Ta(n)=XSteam('T_hs',h,sa(n));
end
plot(sa,Ta);
hold on
title('Trouble with T\_hs at h=1100: Plots for h = 300, 700, 1100, 1500, 1900');
%legend('h=constant');
xlabel('s=entropy (kJ/kg)');
ylabel('T=temperature (Celsius)');

end

output figure[edit | edit source]

There seems to be a flaw in T(h,s) in MATLAB steam table code found at http://www.mathworks.com/matlabcentral/fileexchange/9817-x-steam--thermodynamic-properties-of-water-and-steam