Calculating Ideal gas properties
Afficher commentaires plus anciens
% SADEQ ALMAYYAHI
% applied thermodynamics project
% function
% 1 input : T
% 4 outputs : h(T), u(T), pr(T), so(T)
% Calculates the [h(T),u(T),pr(T),so(T)] of an ideal gas
% IdealGas_propaties calculates a variety of air properties from the measured
% temperature
% prop* | units (si) | Description
% ------------------------------------------------
% T | K | Temperature
% T0 | K | Reference Temperature
% h0 | kJ/kg | Reference Enthalpy
% h | kJ/kg | Enthalpy
% u | kJ/kg | Internal Energy
% pr | - | Relative Pressure
% so | kJ/(kg*K) | Entropy
% c_p | kJ/kmol·K | Specific heat capacity (constant pressure)
% c_v | kJ/kmol·K | Specific heat capacity (constant volume)
% a | - | Constant
% b | - | Constant
% c | - | Constant
% d | - | Constant
% P | bar | Pressure
function [h_T, so_T, u_T, pr_T] = IdealGas_prop(y)
clear clc; %clear all previous variables and command window
% y = Vector of temperatures (K) by user
% h_T = enthalpy h at input Tempreture
% so_T = Entropy so at input Tempreture
% u_T = Internal energy u at input Tempreture
% pr_T = Relative Pressure pr at input Tempreture
T0 = 300; %reference temperature
h0 = 300.19; %reference enthalp
so(T0)= 1.70203; %reference Entropy
a=28.11;
b= 0.1967e2;
c= 0.4802e5;
d= -1.966e9;
T = input(' Vector of temperatures (K) = '); %input function call for user input
h_T =(a*(T-T0)+(b*(T^2-T0^2)/2)+(c*(T^3-T0^3)/3)+(d*(T^4-T0^4)/4))+h0;
% calculate the Enthlpy h
disp('h(T)=')
so_T =((a*log(T/T0))+(b*(T-T0))+(c*(T^2-T0^2)/2)+(d*(T^3-T0^3)/3))+so(T0);
% calculate the Entropy so
disp('so(T)=')
R=8314; %gas constant
u_T = h_T-R*T;
% calculate the Internel Energy u
disp('u(T)=')
pr_T = exp((so_T-(so*273.15)/R));
% calculate the Relative Pressure pr
disp('pr(T)=')
y = input(' Vector of temperatures (K) = '); %input function call for user input
end
Réponses (2)
SADEQ ALMAYYAHI
le 1 Oct 2020
0 votes
Carlos Mamani
le 28 Juil 2021
0 votes
Your input data is wrong, as well as the output
this is the scheme
function insert_the_name_of_result_variable_here = name_function_here (input,all,data,here,with,comas)
% put all of your code here
% name all variables if necessary
% example
% a=1;
% b=2;
% insert_the_name_of_result_variable_here= a+b;
end
%% remember you're working with a function, so you need to call if from the command or script window like this
input=1;
all=2;
here=3;
with=4;
comas=5;
name_function_here(input,all,data,here,with,comas) and press 'run' or enter
Catégories
En savoir plus sur Thermodynamics and Heat Transfer dans Centre d'aide et File Exchange
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!