*** empty log message ***
This commit is contained in:
parent
08e46a54e7
commit
27c66a8674
8 changed files with 76 additions and 54 deletions
|
|
@ -11,6 +11,8 @@ function a = set(a,varargin)
|
|||
% Entropy (S)
|
||||
% MoleFractions (X)
|
||||
% MassFractions (Y)
|
||||
% Vapor Fraction (Vapor)
|
||||
% Liquid Fractio (Liquid)
|
||||
%
|
||||
% Either the full property name or the symbol may be
|
||||
% specified. For the extensive properties (V,H,U,S), the values
|
||||
|
|
@ -28,6 +30,7 @@ function a = set(a,varargin)
|
|||
% set(gas,'H',0.5*enthalpy_mass(gas),'P',pressure(gas));
|
||||
% set(gas,'S',entropy_mass(gas),'P',0.5*pressure(gas));
|
||||
% set(gas,'X',ones(nSpecies(gas),1));
|
||||
% set(gas,'T',500.0,'Vapor',0.8)
|
||||
%
|
||||
% Alternatively, individual methods to set properties may be
|
||||
% called (setTemperature, setMoleFractions, etc.)
|
||||
|
|
@ -111,6 +114,12 @@ while length(property_argin) >= 2,
|
|||
case 'Sat'
|
||||
qval = val;
|
||||
nq = nq + 1;
|
||||
case 'Vapor'
|
||||
qval = val;
|
||||
nq = nq + 1;
|
||||
case 'Liquid'
|
||||
qval = 1.0 - val;
|
||||
nq = nq + 1;
|
||||
otherwise
|
||||
error(['unknown property ' char(prop)])
|
||||
end
|
||||
|
|
@ -139,33 +148,26 @@ elseif ntot == 2
|
|||
%
|
||||
% set property pairs
|
||||
%
|
||||
if nt == 1
|
||||
if nt == 1 & nv == 1
|
||||
setTemperature(a,tval);
|
||||
if nv == 1
|
||||
setDensity(a,1.0/vval); % temperature held fixed
|
||||
elseif np == 1
|
||||
setPressure(a, pval); % temperature held fixed
|
||||
elseif nq == 1
|
||||
if qval == 'Liquid'
|
||||
setState_satLiquid(a);
|
||||
elseif qval == 'Vapor'
|
||||
setState_satVapor(a);
|
||||
end
|
||||
else
|
||||
error('unimplemented property pair');
|
||||
end
|
||||
setDensity(a,1.0/vval);
|
||||
elseif nt == 1 & np == 1
|
||||
setTemperature(a,tval);
|
||||
setPressure(a, pval);
|
||||
elseif nt == 1 & nq == 1
|
||||
setState_Tsat(a, [tval,qval]);
|
||||
elseif np == 1 & nq == 1
|
||||
setState_Psat(a, [pval,qval]);
|
||||
elseif np == 1 & nh == 1
|
||||
setState_HP(a,[hval,pval]);
|
||||
elseif nu == 1 & nv == 1
|
||||
setState_UV(a,[uval,vval]);
|
||||
elseif ns == 1 & np == 1
|
||||
setState_SP(a,[sval,pval]);
|
||||
elseif ns == 1 & nv == 1
|
||||
setState_SV(a,[sval,vval]);
|
||||
else
|
||||
if np == 1 & nh == 1
|
||||
setState_HP(a,[hval,pval]);
|
||||
elseif nu == 1 & nv == 1
|
||||
setState_UV(a,[uval,vval]);
|
||||
elseif ns == 1 & np == 1
|
||||
setState_SP(a,[sval,pval]);
|
||||
elseif ns == 1 & nv == 1
|
||||
setState_SV(a,[sval,vval]);
|
||||
else
|
||||
error('unimplemented property pair');
|
||||
end
|
||||
error('unimplemented property pair');
|
||||
end
|
||||
else
|
||||
error('too many properties specified');
|
||||
|
|
|
|||
|
|
@ -10,5 +10,5 @@ function n = Hydrogen()
|
|||
% For more details, see classes Cantera::PureFluid and tpx::hydrogen in the
|
||||
% Cantera C++ source code documentation.
|
||||
%
|
||||
n = importPhase('purefluids.cti','hydrogen');
|
||||
n = importPhase('liquidvapor.cti','hydrogen');
|
||||
|
||||
|
|
|
|||
|
|
@ -7,5 +7,5 @@ function n = Methane()
|
|||
% equation of state is taken from W. C. Reynolds, "Thermodynamic
|
||||
% Properties in SI."
|
||||
%
|
||||
n = importPhase('purefluids.cti','methane');
|
||||
n = importPhase('liquidvapor.cti','methane');
|
||||
|
||||
|
|
|
|||
|
|
@ -7,5 +7,5 @@ function n = Nitrogen()
|
|||
% equation of state is taken from W. C. Reynolds, "Thermodynamic
|
||||
% Properties in SI."
|
||||
%
|
||||
n = importPhase('purefluids.cti','nitrogen');
|
||||
n = importPhase('liquidvapor.cti','nitrogen');
|
||||
|
||||
|
|
|
|||
|
|
@ -7,5 +7,5 @@ function n = Oxygen()
|
|||
% equation of state is taken from W. C. Reynolds, "Thermodynamic
|
||||
% Properties in SI."
|
||||
%
|
||||
n = importPhase('purefluids.cti','oxygen');
|
||||
n = importPhase('liquidvapor.cti','oxygen');
|
||||
|
||||
|
|
|
|||
|
|
@ -10,5 +10,5 @@ function w = Water()
|
|||
% For more details, see classes Cantera::PureFluid and tpx::water in the
|
||||
% Cantera C++ source code documentation.
|
||||
%
|
||||
w = importPhase('purefluids.cti','water');
|
||||
w = importPhase('liquidvapor.cti','water');
|
||||
|
||||
|
|
|
|||
|
|
@ -1,42 +1,62 @@
|
|||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
%
|
||||
% An ideal Rankine cycle.
|
||||
%
|
||||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
|
||||
function [work, efficiency] = rankine(t1, p2, eta_pump, ...
|
||||
eta_turbine)
|
||||
|
||||
% create an object representing water
|
||||
w = Water;
|
||||
|
||||
% start with saturated liquid water at 300 K
|
||||
set(w,'T',300.0,'Sat','Liquid');
|
||||
% start with saturated liquid water at t1
|
||||
set(w,'T',t1,'Liquid',1.0);
|
||||
h1 = enthalpy_mass(w);
|
||||
s1 = entropy_mass(w);
|
||||
p1 = pressure(w);
|
||||
|
||||
% pump it isentropically to 10 MPa
|
||||
set(w,'S',s1,'P',1.0e7);
|
||||
% pump it to p2
|
||||
pump_work = pump(w, p2, eta_pump);
|
||||
h2 = enthalpy_mass(w);
|
||||
p2 = pressure(w);
|
||||
|
||||
pump_work = h2 - h1;
|
||||
|
||||
|
||||
% heat to 1500 K at constant pressure
|
||||
set(w,'T',1500.0,'P',p2);
|
||||
% heat to saturated vapor
|
||||
set(w,'P',p2,'Vapor',1.0);
|
||||
h3 = enthalpy_mass(w);
|
||||
s3 = entropy_mass(w);
|
||||
|
||||
heat_added = h3 - h2;
|
||||
|
||||
|
||||
% expand isentropically to the initial pressure
|
||||
set(w,'S',s3,'P',p1);
|
||||
work = expand(w, p1, eta_turbine);
|
||||
h4 = enthalpy_mass(w);
|
||||
x4 = vaporFraction(w);
|
||||
|
||||
work_output = h3 - h4;
|
||||
|
||||
% compute the efficiency
|
||||
efficiency = (work_output - pump_work)/heat_added
|
||||
efficiency = (work - pump_work)/heat_added;
|
||||
|
||||
|
||||
|
||||
function w = pump(fluid, pfinal, eta)
|
||||
% Adiabatically pump a fluid to pressure pfinal, using
|
||||
% a pump with isentropic efficiency eta."""
|
||||
h0 = enthalpy_mass(fluid);
|
||||
s0 = entropy_mass(fluid);
|
||||
set(fluid, 'S', s0, 'P', pfinal);
|
||||
h1s = enthalpy_mass(fluid);
|
||||
isentropic_work = h1s - h0;
|
||||
actual_work = isentropic_work / eta;
|
||||
h1 = h0 + actual_work;
|
||||
set(fluid, 'H',h1, 'P',pfinal);
|
||||
w = actual_work;
|
||||
|
||||
|
||||
function w = expand(fluid, pfinal, eta)
|
||||
% Adiabatically expand a fluid to pressure pfinal, using
|
||||
% a turbine with isentropic efficiency eta
|
||||
h0 = enthalpy_mass(fluid);
|
||||
s0 = entropy_mass(fluid);
|
||||
set(fluid, 'S', s0, 'P', pfinal);
|
||||
h1s = enthalpy_mass(fluid);
|
||||
isentropic_work = h0 - h1s;
|
||||
actual_work = isentropic_work * eta;
|
||||
h1 = h0 - actual_work;
|
||||
set(fluid, 'H',h1, 'P',pfinal);
|
||||
w = actual_work;
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -28,10 +28,6 @@ static void thermoset( int nlhs, mxArray *plhs[],
|
|||
ierr = delThermo(th); break;
|
||||
case 1:
|
||||
ierr = th_setPressure(th,*ptr); break;
|
||||
case 2:
|
||||
ierr = th_setState_Psat(th,ptr[0],ptr[1]); break;
|
||||
case 3:
|
||||
ierr = th_setState_Tsat(th,ptr[0],ptr[1]); break;
|
||||
default:
|
||||
mexErrMsgTxt("unknown attribute.");
|
||||
}
|
||||
|
|
@ -49,6 +45,10 @@ static void thermoset( int nlhs, mxArray *plhs[],
|
|||
ierr = th_set_SV(th,ptr); break;
|
||||
case 23:
|
||||
ierr = th_set_SP(th,ptr); break;
|
||||
case 24:
|
||||
ierr = th_setState_Psat(th,ptr[0],ptr[1]); break;
|
||||
case 25:
|
||||
ierr = th_setState_Tsat(th,ptr[0],ptr[1]); break;
|
||||
default:
|
||||
mexErrMsgTxt("unknown pair attribute.");
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue