diff --git a/Cantera/python/Cantera/Phase.py b/Cantera/python/Cantera/Phase.py index 1c08020fc..967b75cd6 100755 --- a/Cantera/python/Cantera/Phase.py +++ b/Cantera/python/Cantera/Phase.py @@ -201,6 +201,12 @@ class Phase: checked for validity and returned. If no such species is present, an exception is thrown.""" nsp = self.nSpecies() + if type(species) == types.ListType: + s = [] + for sp in species: + s.append(self.speciesIndex(sp)) + return s + if type(species) == types.IntType or type(species) == types.FloatType: k = species else: diff --git a/ext/tpx/Makefile.in b/ext/tpx/Makefile.in index e786d24f3..284251ced 100755 --- a/ext/tpx/Makefile.in +++ b/ext/tpx/Makefile.in @@ -7,7 +7,7 @@ OBJDIR = . CXX_FLAGS = @CXXFLAGS@ $(CXX_OPT) -COBJS = Methane.o Nitrogen.o Oxygen.o Water.o Hydrogen.o Sub.o utils.o +COBJS = Methane.o Nitrogen.o Oxygen.o Water.o Hydrogen.o lk.o Sub.o utils.o FOBJS = diff --git a/ext/tpx/lk.cpp b/ext/tpx/lk.cpp index a5756bd33..63f635ffc 100755 --- a/ext/tpx/lk.cpp +++ b/ext/tpx/lk.cpp @@ -3,79 +3,81 @@ #include "lk.h" #include -const double b[2][4] = {{0.1181193, 0.265728, 0.154790, 0.030323}, - {0.2026579, 0.331511, 0.027655, 0.203488}}; -const double c[2][4] = {{0.0236744, 0.0186984, 0.0, 0.042724}, - {0.0313385, 0.0503618, 0.016901, 0.041577}}; -const double d[2][2] = {{1.55488e-5, 6.23689e-5},{4.8736e-5, 0.740336e-5}}; -const double beta[2] = {0.65392, 1.226}; -const double gamma[2] = {0.060167, 0.03754}; +namespace tpx { -//--------------------------- member functions ------------------ + static double b[2][4] = {{0.1181193, 0.265728, 0.154790, 0.030323}, + {0.2026579, 0.331511, 0.027655, 0.203488}}; + static double c[2][4] = {{0.0236744, 0.0186984, 0.0, 0.042724}, + {0.0313385, 0.0503618, 0.016901, 0.041577}}; + static double d[2][2] = {{1.55488e-5, 6.23689e-5},{4.8736e-5, 0.740336e-5}}; + static double beta[2] = {0.65392, 1.226}; + static double gamma[2] = {0.060167, 0.03754}; -double lk::W(int n, double egrho, double Gamma) { - return (n == 0 ? (1.0 - egrho)/(2.0*Gamma) : - (n*W(n-1, egrho, Gamma) - 0.5*pow(Rho,2*n)*egrho)/Gamma); -} + //--------------------------- member functions ------------------ -double lk::up(){ + double leekesler::W(int n, double egrho, double Gamma) { + return (n == 0 ? (1.0 - egrho)/(2.0*Gamma) : + (n*W(n-1, egrho, Gamma) - 0.5*pow(Rho,2*n)*egrho)/Gamma); + } + + double leekesler::up(){ return -(8314.3/Mw)*T*(1.0 + T*I()/Tcr); // + h_0(T) -} + } -double lk::hdep(){ + double leekesler::hdep(){ double tr = T/Tcr; return tr*tr*I() + (1.0 - z())*tr; -} + } -double lk::sdep(){ + double leekesler::sdep(){ double tr = T/Tcr; return tr*I() + J() - log(z()); -} + } -double lk::sp() { + double leekesler::sp() { const double Pref = 101325.0; double rgas = 8314.3/Mw; - return rgas*(log(Pref/(Rho*rgas*T)) - (T/Tcr)*I() - J()); // + s^0(T,p_0) -} + return rgas*(log(Pref/(Rho*rgas*T)) - (T/Tcr)*I() - J()); + } -double lk::I() { // \int_0^\rho_r (1/\rho_r)(dZ/dT_r) d\rho_r + double leekesler::I() { // \int_0^\rho_r (1/\rho_r)(dZ/dT_r) d\rho_r double Bp, Cp, Dp; double rtr = Tcr/T; double rtr2 = rtr*rtr; double rvr = 8314.3*Tcr*Rho/(Pcr*Mw); // 1/v_r^\prime double rvr2 = rvr*rvr; - double egrho; + double egrho; egrho = exp(-gamma[Isr]*rvr2); Bp = rtr2*b[Isr][1] + 2.0*rtr*rtr2*b[Isr][2] + 3.0*rtr2*rtr2*b[Isr][3]; Cp = rtr2*c[Isr][1] - 3.0*c[Isr][2]*rtr2*rtr2; Dp = -d[Isr][1]*rtr2; double r = Bp*rvr + 0.5*rvr2*Cp + 0.2*pow(rvr,5)*Dp - - 3.0*c[Isr][3]*rtr2*rtr2*(beta[Isr]*W(0,egrho,gamma[Isr]) - + gamma[Isr]*W(1,egrho,gamma[Isr])); + - 3.0*c[Isr][3]*rtr2*rtr2*(beta[Isr]*W(0,egrho,gamma[Isr]) + + gamma[Isr]*W(1,egrho,gamma[Isr])); return r; -} + } -double lk::J() { // \int_0^\rho_r (1/\rho_r)(Z - 1) d\rho_r + double leekesler::J() { // \int_0^\rho_r (1/\rho_r)(Z - 1) d\rho_r double BB, CC, DD; double rtr = Tcr/T; double rtr2 = rtr*rtr; double rvr = 8314.3*Tcr*Rho/(Pcr*Mw); // 1/v_r^\prime double rvr2 = rvr*rvr; - double egrho; + double egrho; egrho = exp(-gamma[Isr]*rvr2); BB = b[Isr][0] - rtr*(b[Isr][1] - + rtr*(b[Isr][2] + rtr*b[Isr][3])); + + rtr*(b[Isr][2] + rtr*b[Isr][3])); CC = c[Isr][0] - rtr*(c[Isr][1] - c[Isr][2]*rtr*rtr); DD = d[Isr][0] + d[Isr][1]*rtr; double r = BB*rvr + 0.5*rvr2*CC + 0.2*pow(rvr,5)*DD - + c[Isr][3]*rtr2*rtr*(beta[Isr]*W(0,egrho,gamma[Isr]) - + gamma[Isr]*W(1,egrho,gamma[Isr])); + + c[Isr][3]*rtr2*rtr*(beta[Isr]*W(0,egrho,gamma[Isr]) + + gamma[Isr]*W(1,egrho,gamma[Isr])); return r; -} + } -double lk::z() { + double leekesler::z() { double zz, rvr2, BB, CC, DD, EE; double rtr = Tcr/T; // 1/T_r double rvr = Rho*8314.3*Tcr/(Pcr*Mw); @@ -90,42 +92,45 @@ double lk::z() { + c[Isr][3]*pow(rtr,3)*rvr2* (beta[Isr] + gamma[Isr]*rvr2)*EE; return zz; -} + } -double lk::Pp() { + double leekesler::Pp() { return 8314.3*z()*Rho*T/Mw; } -double lk::Psat(){ + double leekesler::Psat(){ double tr = 1.0 - Tcr/T; double lpr; if (Isr == 0) - lpr = 5.395743797*tr + 0.05524287*tr*tr + 0.06853005*tr*tr*tr; + lpr = 5.395743797*tr + 0.05524287*tr*tr + 0.06853005*tr*tr*tr; else - lpr = 7.259961465*tr - 0.549206092*tr*tr + 0.177581752*tr*tr*tr; + lpr = 7.259961465*tr - 0.549206092*tr*tr + 0.177581752*tr*tr*tr; return Pcr*exp(lpr); -} + } -double lk::ldens(){ + double leekesler::ldens(){ double x = 1.0 - T/Tcr; + // for simple fluid double rho_r; if (Isr == 0) - rho_r = 5.2307 + 15.16*x - 21.9778*x*x + 18.767*x*x*x; + rho_r = 5.2307 + 15.16*x - 21.9778*x*x + 18.767*x*x*x; else { - rho_r = 6.166930606 + 17.42866964*x - 18.62589833*x*x + 11.73957224*x*x*x; - rho_r *= 1.0; + rho_r = 6.166930606 + 17.42866964*x - 18.62589833*x*x + + 11.73957224*x*x*x; + rho_r *= 1.0; } return Pcr*rho_r*Mw/(8314.3*Tcr); -} + } -double lk::Tcrit() {return Tcr;} -double lk::Pcrit() {return Pcr;} -double lk::Vcrit() {return 0.2901*8314.3*Tcr/(Pcr*Mw);} -double lk::Tmin() {return -100.0;} -double lk::Tmax() {return 10000.0;} -char * lk::name() {return "Lee-Kesler";} -char * lk::formula() {return "---";} -double lk::MolWt() {return Mw;} + double leekesler::Tcrit() {return Tcr;} + double leekesler::Pcrit() {return Pcr;} + double leekesler::Vcrit() {return 0.2901*8314.3*Tcr/(Pcr*Mw);} + double leekesler::Tmin() {return -100.0;} + double leekesler::Tmax() {return 10000.0;} + char * leekesler::name() {return "Lee-Kesler";} + char * leekesler::formula() {return "---";} + double leekesler::MolWt() {return Mw;} +} diff --git a/ext/tpx/lk.h b/ext/tpx/lk.h index b5bdd6826..11c2a05bb 100755 --- a/ext/tpx/lk.h +++ b/ext/tpx/lk.h @@ -1,18 +1,23 @@ -#ifndef LK_H -#define LK_H +#ifndef TPX_LK_H +#define TPX_LK_H -#include "sub.h" +#include "Sub.h" -class lk : public Substance{ -public: - lk(double tc = 1.0, double pc = 1.0, double wt = 1.0, int itype = 0) +namespace tpx { + + class leekesler : public Substance{ + + public: + + leekesler(double tc = 1.0, double pc = 1.0, + double wt = 1.0, int itype = 0) { Tcr = tc; Pcr = pc; Mw = wt; Isr = itype; // simple fluid or reference - }; - ~lk() {}; + } + ~leekesler() {} double MolWt(); double Tcrit(); @@ -27,18 +32,30 @@ public: double up(); double sp(); double Psat(); + double dPsatdT(); + + // compressibility double z(); + + // enthalpy departure double hdep(); + + // entropy departure double sdep(); + double ldens(); -protected: + protected: + double Tcr, Pcr, Mw; int Isr; -private: + private: + double W(int n, double egrho, double gamma); double I(); double J(); -}; -#endif // ! LK_H + }; +} + +#endif // ! TPX_LK_H diff --git a/tools/src/package4mac.in b/tools/src/package4mac.in index e326015e5..3025c819d 100644 --- a/tools/src/package4mac.in +++ b/tools/src/package4mac.in @@ -1,6 +1,6 @@ #!/bin/sh -INSTALL='@INSTALL' +INSTALL='@INSTALL@' PYVERSION=2.3 PKGDIR=$HOME/Packages @@ -9,6 +9,9 @@ CTDIR=$PKGDIR/Cantera/root_dir/Applications/Cantera PYDIR=$PKGDIR/Cantera/root_dir/Library/Python/$PYVERSION RESDIR=$PKGDIR/Cantera/resources_dir +NUMPYDIR=$PKGDIR/Numeric/root_dir/Library/Python/$PYVERSION +NUMRESDIR=$PKGDIR/Numeric/resources_dir + # where Cantera has been installed instdir=/Applications/Cantera pylibdir=/Library/Python/$PYVERSION @@ -18,6 +21,9 @@ $INSTALL -d $PYDIR/Cantera $INSTALL -d $PYDIR/MixMaster $INSTALL -d $RESDIR +$INSTALL -d $NUMPYDIR/Numeric +$INSTALL -d $NUMRESDIR + cp -R -f $instdir/* $CTDIR chmod +x $CTDIR/bin/* @@ -28,3 +34,5 @@ cp -f ~/setup_cantera $CTDIR cp -f /Users/dgg/dv/sf/cantera/License.txt $RESDIR +cp -R -f $pylibdir/Numeric/* $NUMPYDIR/Numeric +cp -f $pylibdir/Numeric.pth $NUMPYDIR