Function File to Solve Thermodynamics Problem
Mostrar comentarios más antiguos
I am trying to solve a thermodynamics problem based on an isentropic relationship. The problem boils down to a higher order equation in terms of T2. Ultimately, T2 needs to be found. I would like to be able to write a function file that is a function of only T2 and then I can use bisection or newtons method to solve. I have input the isentropic relationship as my function, and the rest of my parameters under that. cp_2 and gamma2 are fucntions of T2. Right now, Matlab is not referencing the parameters under the isentropic relationship. Here is the code I have so far.
function [f]=temperature_2(T2)
f= T1*((.02*v1.^(gamma1-1))./(v1.^(gamma2-1)))-T2
%Givens
%Volume at state 1(cubic meters)
v1=.75
%Temperature at state 1(kelvin)
T1=375
%Universal gas constant(kJ/kmole)
R=8.314
%Matrix for a is given in the problem statement
a=[2.0909*10^1; 6.8717*10^-2; -5.2719*10^-5; 2.1664*10^-8; -4.5346*10^-12; 3.7873*10^-16];
%cp_1 calculation, there is enough info to compute this
cp_1=a(1)+T1.*(a(2)+T1.*(a(3)+T1.*(a(4)+T1.*(a(5)+T1.*a(6)))));
%cp_2 calculation, this is a function of T2
cp_2=a(1)+T2.*(a(2)+T2.*(a(3)+T2.*(a(4)+T2.*(a(5)+T2.*a(6)))));
%Compute Gamma as per equation given
gamma1=((cp_1)./(cp_1-R));
%This is a function of T2
gamma2=((cp_2)./(cp_2-R));
end
2 comentarios
Andrew Newell
el 28 de Sept. de 2011
Please see http://www.mathworks.com/matlabcentral/answers/7885-tutorial-how-to-format-your-question to format your code correctly.
Rick Rosson
el 28 de Sept. de 2011
Please format your code. If you do not know how, please click on the link called "Markup help" below.
Respuesta aceptada
Más respuestas (0)
Categorías
Más información sobre Thermodynamics and Heat Transfer en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!