*** empty log message ***

This commit is contained in:
Dave Goodwin 2004-03-11 05:00:00 +00:00
parent 59f5666c85
commit fc80f228ab
19 changed files with 160 additions and 20 deletions

View file

@ -40,6 +40,8 @@ hval = -999;
uval = -999;
sval = -999;
vval = -999;
qval = -999;
np = 0;
nt = 0;
nv = 0;
@ -48,6 +50,7 @@ ny = 0;
ns = 0;
nh = 0;
nu = 0;
nq = 0;
while length(property_argin) >= 2,
prop = property_argin{1};
@ -105,6 +108,9 @@ while length(property_argin) >= 2,
case 'S'
sval = val;
ns = ns + 1;
case 'Sat'
qval = val;
nq = nq + 1;
otherwise
error(['unknown property ' char(prop)])
end
@ -114,7 +120,7 @@ if nx + ny > 1
error('composition specified multiple times');
end
ntot = nt + np + nv + ns + nh + nu;
ntot = nt + np + nv + ns + nh + nu + nq;
if ntot == 1
%
@ -138,7 +144,13 @@ elseif ntot == 2
if nv == 1
setDensity(a,1.0/vval); % temperature held fixed
elseif np == 1
setPressure(a, pval); % temperature held fixed
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

View file

@ -0,0 +1,4 @@
function v = critDensity(a)
% CRITDENSITY - Critical density [kg/m3].
%
v = thermo_get(a.tp_id,21);

View file

@ -0,0 +1,4 @@
function v = critPressure(a)
% CRITPRESSURE - Critical pressure [Pa].
%
v = thermo_get(a.tp_id,20);

View file

@ -0,0 +1,4 @@
function v = critTemperature(a)
% CRITTEMPERATURE - Critical temperature [K].
%
v = thermo_get(a.tp_id,19);

View file

@ -1,12 +1,6 @@
function v = minTemp(p)
% MINTEMP - Minimum temperature.
%
% The parameterizations used to represent the temperature-dependent
% species thermodynamic properties are generally only valid in some
% finite temperature range, which may be different for each species
% in the phase. This method returns the lowest temperature at which
% the parameterizations are valid for all species in the phase.
function v = critTemperature(a)
% CRITTEMPERATURE - Critical temperature [K].
%
% See also: maxTemp
% The critical temperature is the temperature at the critical point
%
v = thermo_get(p.tp_id,16);
v = thermo_get(p.tp_id,19);

View file

@ -0,0 +1,3 @@
function v = satPressure(a, T)
% SATPRESSURE - Saturation pressure for temperature T.
v = thermo_get(a.tp_id,24,T);

View file

@ -0,0 +1,3 @@
function v = satTemperature(a, p)
% SATTEMPERATURE - Saturation temperature for pressure p.
v = thermo_get(a.tp_id,23,p);

View file

@ -0,0 +1,5 @@
function a = setState_satLiquid(a)
% SETSTATE_SATLIQUID Set the fluid to the saturated liquid state
% at the current temperature.
%
thermo_set(a.tp_id,2,0);

View file

@ -0,0 +1,5 @@
function a = setState_satVapor(a)
% SETSTATE_SATVAPOR Set the fluid to the saturated vapor state at the
% current temperature.
%
thermo_set(a.tp_id,3,0);

View file

@ -0,0 +1,5 @@
function v = vaporFraction(a)
% VAPORFRACTION - Vapor fraction.
% If object 'a' represents a liquid/vapor mixture, this method
% returns the vapor fraction.
v = thermo_get(a.tp_id,22);

View file

@ -15,7 +15,7 @@ if nargin == 4
node = child(xml_phase,'transport');
tr.model = attrib(node,'model');
catch
tr.model = '';
tr.model = 'None';
end
else
tr.model = model;

View file

@ -0,0 +1,11 @@
function n = Hydrogen()
% HYDROGEN - Return an object representing hydrogen.
%
% The object returned by this method implements an accurate equation of
% state for hydrogen that can be used in the liquid, vapor, saturated
% liquid/vapor, and supercritical regions of the phase diagram. The
% equation of state is taken from W. C. Reynolds, "Thermodynamic
% Properties in SI."
%
n = importPhase('purefluids.cti','hydrogen');

View file

@ -0,0 +1,11 @@
function n = Methane()
% METHANE - Return an object representing methane.
%
% The object returned by this method implements an accurate equation of
% state for methane that can be used in the liquid, vapor, saturated
% liquid/vapor, and supercritical regions of the phase diagram. The
% equation of state is taken from W. C. Reynolds, "Thermodynamic
% Properties in SI."
%
n = importPhase('purefluids.cti','methane');

View file

@ -0,0 +1,11 @@
function n = Nitrogen()
% NITROGEN - Return an object representing nitrogen.
%
% The object returned by this method implements an accurate equation of
% state for nitrogen that can be used in the liquid, vapor, saturated
% liquid/vapor, and supercritical regions of the phase diagram. The
% equation of state is taken from W. C. Reynolds, "Thermodynamic
% Properties in SI."
%
n = importPhase('purefluids.cti','nitrogen');

View file

@ -0,0 +1,11 @@
function n = Oxygen()
% OXYGEN - Return an object representing oxygen.
%
% The object returned by this method implements an accurate equation of
% state for oxygen that can be used in the liquid, vapor, saturated
% liquid/vapor, and supercritical regions of the phase diagram. The
% equation of state is taken from W. C. Reynolds, "Thermodynamic
% Properties in SI."
%
n = importPhase('purefluids.cti','oxygen');

View file

@ -0,0 +1,11 @@
function w = Water()
% WATER - Return an object representing water.
%
% The object returned by this method implements an accurate equation of
% state for water that can be used in the liquid, vapor, saturated
% liquid/vapor, and supercritical regions of the phase diagram. The
% equation of state is taken from W. C. Reynolds, "Thermodynamic
% Properties in SI."
%
w = importPhase('purefluids.cti','water');

View file

@ -0,0 +1,42 @@
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% An ideal Rankine cycle.
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% create an object representing water
w = Water;
% start with saturated liquid water at 300 K
set(w,'T',300.0,'Sat','Liquid');
h1 = enthalpy_mass(w);
s1 = entropy_mass(w);
p1 = pressure(w);
% pump it isentropically to 10 MPa
set(w,'S',s1,'P',1.0e7);
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);
h3 = enthalpy_mass(w);
s3 = entropy_mass(w);
heat_added = h3 - h2;
% expand isentropically to the initial pressure
set(w,'S',s3,'P',p1);
h4 = enthalpy_mass(w);
x4 = vaporFraction(w);
work_output = h3 - h4;
% compute the efficiency
efficiency = (work_output - pump_work)/heat_added

View file

@ -27,7 +27,11 @@ static void thermoset( int nlhs, mxArray *plhs[],
case 10:
ierr = delThermo(th); break;
case 1:
ierr = th_setPressure(th,*ptr); break;
ierr = th_setPressure(th,*ptr); break;
case 2:
ierr = th_setState_satLiquid(th); break;
case 3:
ierr = th_setState_satVapor(th); break;
default:
mexErrMsgTxt("unknown attribute.");
}
@ -69,7 +73,7 @@ static void thermoset( int nlhs, mxArray *plhs[],
static void thermoget( int nlhs, mxArray *plhs[],
int nrhs, const mxArray *prhs[] )
{
double vv;
double vv, psat, tsat;
int n = getInt(prhs[1]);
int job = getInt(prhs[2]);
@ -123,11 +127,11 @@ static void thermoget( int nlhs, mxArray *plhs[],
case 22:
vv = th_vaporFraction(n); break;
case 23:
double p = getDouble(prhs[3]);
vv = th_satTemperature(n, p); break;
psat = getDouble(prhs[3]);
vv = th_satTemperature(n, psat); break;
case 24:
double t = getDouble(prhs[3]);
vv = th_satPressure(n, t); break;
tsat = getDouble(prhs[3]);
vv = th_satPressure(n, tsat); break;
#endif
default:
ok = false;

View file

@ -1,7 +1,7 @@
import sys
bindir = '/home/goodwin/ct153d/bin'
bindir = '/home/goodwin/ctt/bin'
libdir = '/home/goodwin/dv/sf/cantera/build/lib/i686-pc-linux-gnu'
incdir = '/home/goodwin/dv/sf/cantera/build/include'
dflibdir = ''