added support for exceptions from tpx
This commit is contained in:
parent
0f723ca045
commit
684ee95a9d
6 changed files with 43 additions and 19 deletions
|
|
@ -4,7 +4,7 @@
|
|||
# $Date$
|
||||
# $Revision$
|
||||
#
|
||||
# Copyright 2001 California Institute of Technology
|
||||
# Copyright 2001-2004 California Institute of Technology
|
||||
# See file License.txt for licensing information
|
||||
#
|
||||
###############################################################
|
||||
|
|
@ -25,6 +25,7 @@ SRCS = cantera/private/ctmethods.cpp \
|
|||
cantera/private/surfmethods.cpp \
|
||||
cantera/private/funcmethods.cpp
|
||||
|
||||
|
||||
CANTERA_LIBDIR=@buildlib@
|
||||
os_is_win=@OS_IS_WIN@
|
||||
|
||||
|
|
@ -38,6 +39,11 @@ LIB_DEPS = $(CANTERA_LIBDIR)/cantera.lib $(CANTERA_LIBDIR)/zeroD.lib \
|
|||
$(CANTERA_LIBDIR)/transport.lib
|
||||
endif
|
||||
|
||||
DEPENDS = $(SRCS:.cpp=.d)
|
||||
|
||||
.cpp.d:
|
||||
g++ -MM $(CXX_INCLUDES) $*.cpp > $*.d
|
||||
|
||||
all: cantera/ctmethods.@mex_ext@
|
||||
|
||||
cantera/ctmethods.@mex_ext@: $(SRCS) $(LIBDEPS) Makefile
|
||||
|
|
@ -49,7 +55,6 @@ endif
|
|||
(@MATLAB_CMD@ -nojvm -nosplash -r setup)
|
||||
rm -f setup.m
|
||||
|
||||
|
||||
install:
|
||||
@INSTALL@ -d @prefix@/matlab/toolbox/cantera/cantera
|
||||
@INSTALL@ -d @prefix@/matlab/toolbox/cantera/cantera-demos
|
||||
|
|
@ -125,10 +130,22 @@ install:
|
|||
|
||||
|
||||
clean:
|
||||
echo '-'
|
||||
rm -f cantera/private/*.o
|
||||
rm -f cantera/ctmethods.@mex_ext@
|
||||
|
||||
#depends: $(DEPENDS)
|
||||
# cat *.d > .depends
|
||||
# $(RM) $(DEPENDS)
|
||||
|
||||
depends:
|
||||
echo '-'
|
||||
echo "-"
|
||||
|
||||
TAGS:
|
||||
etags *.h *.cpp
|
||||
|
||||
ifeq ($(wildcard .depends), .depends)
|
||||
include .depends
|
||||
endif
|
||||
|
||||
run-demo:
|
||||
(cd @ct_dir@; matlab -nojvm -nosplash -r cantera_demos)
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@ s3 = entropy_mass(w);
|
|||
|
||||
heat_added = h3 - h2;
|
||||
|
||||
% expand isentropically to the initial pressure
|
||||
% expand adiabatically back to the initial pressure
|
||||
work = expand(w, p1, eta_turbine);
|
||||
h4 = enthalpy_mass(w);
|
||||
x4 = vaporFraction(w);
|
||||
|
|
@ -33,8 +33,9 @@ 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."""
|
||||
% PUMP - 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);
|
||||
|
|
@ -47,8 +48,9 @@ w = actual_work;
|
|||
|
||||
|
||||
function w = expand(fluid, pfinal, eta)
|
||||
% Adiabatically expand a fluid to pressure pfinal, using
|
||||
% a turbine with isentropic efficiency eta
|
||||
% EXPAND - 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);
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@
|
|||
void reportError() {
|
||||
int buflen = 0;
|
||||
char* output_buf = 0;
|
||||
buflen = getCanteraError(buflen, output_buf);
|
||||
buflen = getCanteraError(buflen, output_buf) + 1;
|
||||
output_buf = (char*)mxCalloc(buflen, sizeof(char));
|
||||
getCanteraError(buflen, output_buf);
|
||||
mexErrMsgTxt(output_buf);
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
const double Undef = -999.123;
|
||||
//const double DERR = -999.999;
|
||||
|
||||
void reportError();
|
||||
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@
|
|||
int nrhs, const mxArray *prhs[] )
|
||||
{
|
||||
double vv;
|
||||
int iok, k, m;
|
||||
int iok=0, k, m;
|
||||
int ph = getInt(prhs[1]);
|
||||
int job = getInt(prhs[2]);
|
||||
|
||||
|
|
@ -34,9 +34,9 @@
|
|||
|
||||
switch (mjob) {
|
||||
case 1:
|
||||
phase_setTemperature(ph,*ptr); break;
|
||||
iok = phase_setTemperature(ph,*ptr); break;
|
||||
case 2:
|
||||
phase_setDensity(ph,*ptr); break;
|
||||
iok = phase_setDensity(ph,*ptr); break;
|
||||
default:
|
||||
ok = false;
|
||||
}
|
||||
|
|
@ -48,18 +48,18 @@
|
|||
int norm = 1;
|
||||
switch (mjob) {
|
||||
case 20:
|
||||
phase_setMoleFractions(ph, nsp, ptr, norm);
|
||||
iok = phase_setMoleFractions(ph, nsp, ptr, norm);
|
||||
break;
|
||||
case 21:
|
||||
phase_setMassFractions(ph, nsp, ptr, norm);
|
||||
iok = phase_setMassFractions(ph, nsp, ptr, norm);
|
||||
break;
|
||||
case 22:
|
||||
norm = 0;
|
||||
phase_setMoleFractions(ph, nsp, ptr, norm);
|
||||
iok = phase_setMoleFractions(ph, nsp, ptr, norm);
|
||||
break;
|
||||
case 23:
|
||||
norm = 0;
|
||||
phase_setMassFractions(ph, nsp, ptr, norm);
|
||||
iok = phase_setMassFractions(ph, nsp, ptr, norm);
|
||||
break;
|
||||
default:
|
||||
ok = false;
|
||||
|
|
@ -88,10 +88,10 @@
|
|||
|
||||
switch (mjob) {
|
||||
case 30:
|
||||
phase_setMoleFractionsByName(ph, input_buf);
|
||||
iok = phase_setMoleFractionsByName(ph, input_buf);
|
||||
break;
|
||||
case 31:
|
||||
phase_setMassFractionsByName(ph, input_buf);
|
||||
iok = phase_setMassFractionsByName(ph, input_buf);
|
||||
break;
|
||||
default:
|
||||
mexErrMsgTxt("what?");
|
||||
|
|
@ -139,6 +139,7 @@
|
|||
ok = false;
|
||||
}
|
||||
if (ok) {
|
||||
if (vv == DERR) reportError();
|
||||
plhs[0] = mxCreateNumericMatrix(1,1,mxDOUBLE_CLASS,mxREAL);
|
||||
double *h = mxGetPr(plhs[0]);
|
||||
*h = vv;
|
||||
|
|
@ -236,6 +237,7 @@
|
|||
}
|
||||
else {
|
||||
mexErrMsgTxt("error or unknown method.");
|
||||
reportError();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
|
@ -243,4 +245,5 @@
|
|||
mexErrMsgTxt("unimplemented method.");
|
||||
return;
|
||||
}
|
||||
if (iok < 0) reportError();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -138,6 +138,7 @@ static void thermoget( int nlhs, mxArray *plhs[],
|
|||
ok = false;
|
||||
}
|
||||
if (ok) {
|
||||
if (vv == DERR) reportError();
|
||||
plhs[0] = mxCreateNumericMatrix(1,1,mxDOUBLE_CLASS,mxREAL);
|
||||
double *h = mxGetPr(plhs[0]);
|
||||
*h = vv;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue