*** empty log message ***

This commit is contained in:
Dave Goodwin 2004-05-17 23:09:27 +00:00
parent ad791e12d5
commit 6f43b06ca5
21 changed files with 169 additions and 68 deletions

View file

@ -26,7 +26,7 @@ endif
clean:
cd src; @MAKE@ clean
cd cxx/src; @MAKE@ clean
cd cxx; @MAKE@ clean
cd clib/src; @MAKE@ clean
cd python; @MAKE@ clean
ifeq ($(build_f90),1)

View file

@ -34,12 +34,17 @@ inline XML_Node* _xml(int i) {
#ifdef INCL_PURE_FLUID
static PureFluid* purefluid(int n) {
ThermoPhase* tp = th(n);
if (tp->eosType() == cPureFluid) {
return (PureFluid*)tp;
try {
ThermoPhase* tp = th(n);
if (tp->eosType() == cPureFluid) {
return (PureFluid*)tp;
}
else {
throw CanteraError("purefluid","object is not a PureFluid object");
}
}
else {
throw CanteraError("purefluid","object is not a PureFluid object");
catch (CanteraError) {
return 0;
}
}
#else
@ -82,8 +87,7 @@ extern "C" {
}
int DLL_EXPORT phase_setDensity(int n, double rho) {
if (rho < 0.0) throw CanteraError("phase_setDensity",
"density cannot be negative");
if (rho < 0.0) return -1;
ph(n)->setDensity(rho);
return 0;
}

View file

@ -2,7 +2,7 @@
#define CTC_CT_H
#include "clib_defs.h"
#include <cantera/Cantera.h>
#include "../../../config.h"
extern "C" {

View file

@ -94,10 +94,10 @@ extern "C" {
return 0;
}
//int DLL_EXPORT reactor_setInitialTime(int i, double t) {
// _reactor(i)->setInitialTime(t);
// return 0;
//}
int DLL_EXPORT reactor_setInitialTime(int i, double t) {
_reactor(i)->setInitialTime(t);
return 0;
}
int DLL_EXPORT reactor_setThermoMgr(int i, int n) {
_reactor(i)->setThermoMgr(*_th(n));
@ -111,17 +111,17 @@ extern "C" {
return 0;
}
//int DLL_EXPORT reactor_advance(int i, double t) {
// try {
// _reactor(i)->advance(t);
// return 0;
// }
// catch (CanteraError) {return -1;}
//}
int DLL_EXPORT reactor_advance(int i, double t) {
try {
_reactor(i)->advance(t);
return 0;
}
catch (CanteraError) {return -1;}
}
// double DLL_EXPORT reactor_step(int i, double t) {
// return _reactor(i)->step(t);
//}
double DLL_EXPORT reactor_step(int i, double t) {
return _reactor(i)->step(t);
}
double DLL_EXPORT reactor_time(int i) {
return _reactor(i)->time();
@ -196,11 +196,26 @@ extern "C" {
return 0;
}
int DLL_EXPORT reactornet_addreactor(int i, int n) {
_reactornet(i)->addReactor(_reactor(n));
int DLL_EXPORT reactornet_setMaxTimeStep(int i, double maxstep) {
_reactornet(i)->setMaxTimeStep(maxstep);
return 0;
}
int DLL_EXPORT reactornet_setTolerances(int i, double rtol, double atol) {
_reactornet(i)->setTolerances(rtol, atol);
return 0;
}
int DLL_EXPORT reactornet_addreactor(int i, int n) {
try {
_reactornet(i)->addReactor(_reactor(n));
return 0;
}
catch (CanteraError) {
return -1;
}
}
int DLL_EXPORT reactornet_advance(int i, double t) {
try {
_reactornet(i)->advance(t);
@ -218,6 +233,19 @@ extern "C" {
}
}
double DLL_EXPORT reactornet_time(int i) {
return _reactornet(i)->time();
}
double DLL_EXPORT reactornet_rtol(int i) {
return _reactornet(i)->rtol();
}
double DLL_EXPORT reactornet_atol(int i) {
return _reactornet(i)->atol();
}
// flow devices

View file

@ -10,12 +10,12 @@ extern "C" {
int DLL_IMPORT reactor_copy(int i);
int DLL_IMPORT reactor_assign(int i, int j);
int DLL_IMPORT reactor_setInitialVolume(int i, double v);
// int DLL_IMPORT reactor_setInitialTime(int i, double t);
int DLL_IMPORT reactor_setInitialTime(int i, double t);
int DLL_IMPORT reactor_setEnergy(int i, int eflag);
int DLL_IMPORT reactor_setThermoMgr(int i, int n);
int DLL_IMPORT reactor_setKineticsMgr(int i, int n);
//int DLL_IMPORT reactor_advance(int i, double t);
//double DLL_IMPORT reactor_step(int i, double t);
int DLL_IMPORT reactor_advance(int i, double t);
double DLL_IMPORT reactor_step(int i, double t);
double DLL_IMPORT reactor_time(int i);
double DLL_IMPORT reactor_mass(int i);
double DLL_IMPORT reactor_volume(int i);
@ -31,9 +31,14 @@ extern "C" {
int DLL_IMPORT reactornet_copy(int i);
int DLL_IMPORT reactornet_assign(int i, int j);
int DLL_IMPORT reactornet_setInitialTime(int i, double t);
int DLL_IMPORT reactornet_setMaxTimeStep(int i, double maxstep);
int DLL_IMPORT reactornet_setTolerances(int i, double rtol, double atol);
int DLL_IMPORT reactornet_addreactor(int i, int n);
int DLL_IMPORT reactornet_advance(int i, double t);
double DLL_IMPORT reactornet_step(int i, double t);
double DLL_IMPORT reactornet_time(int i);
double DLL_IMPORT reactornet_rtol(int i);
double DLL_IMPORT reactornet_atol(int i);
int DLL_IMPORT flowdev_new(int type);
int DLL_IMPORT flowdev_del(int i);

View file

@ -100,11 +100,12 @@ class Kinetics:
return _cantera.kin_speciesIndex(self.ckin, name, phase)
def kineticsStart(self, n):
"""The starting location of phase n in production rate arrays."""
return _cantera.kin_start(self.ckin, n)
def phase(self, n):
"""Return an object representing the nth phase."""
return ThermoPhase(index = _cantera.kin_phase(self.ckin, n))
#return self._ph[_cantera.kin_phase(self.ckin, n)]
def nReactions(self):
"""Number of reactions."""
@ -121,10 +122,9 @@ class Kinetics:
"""Type of reaction 'i'"""
return _cantera.kin_rxntype(self.ckin,i)
#def reactionString(self,i):
# return _cantera.kin_getstring(self.ckin,1,i)
def reactionEqn(self,i):
"""The equation for the specified reaction. If a list of equation numbers
is given, then a list of equation strings is returned."""
try:
eqs = []
for rxn in i:
@ -134,6 +134,7 @@ class Kinetics:
return self.reactionString(i)
def reactionString(self, i):
"""Reaction string for reaction number 'i'"""
s = ''
nsp = _cantera.kin_nspecies(self.ckin)
for k in range(nsp):
@ -157,9 +158,13 @@ class Kinetics:
return s
def reactantStoichCoeff(self,k,i):
"""The stoichiometric coefficient of species k as a reactant in reaction i."""
return _cantera.kin_rstoichcoeff(self.ckin,k,i)
def reactantStoichCoeffs(self):
"""The array of reactant stoichiometric coefficients. Element
[k,i] of this array is the reactant stoichiometric
coefficient of species k in reaction i."""
nsp = _cantera.kin_nspecies(self.ckin)
nr = _cantera.kin_nreactions(self.ckin)
nu = Numeric.zeros((nsp,nr),'d')
@ -169,9 +174,13 @@ class Kinetics:
return nu
def productStoichCoeff(self,k,i):
"""The stoichiometric coefficient of species k as a product in reaction i."""
return _cantera.kin_pstoichcoeff(self.ckin,k,i)
def productStoichCoeffs(self):
"""The array of product stoichiometric coefficients. Element
[k,i] of this array is the product stoichiometric
coefficient of species k in reaction i."""
nsp = _cantera.kin_nspecies(self.ckin)
nr = _cantera.kin_nreactions(self.ckin)
nu = Numeric.zeros((nsp,nr),'d')
@ -181,12 +190,15 @@ class Kinetics:
return nu
def fwdRatesOfProgress(self):
"""Forward rates of progress of the reactions."""
return _cantera.kin_getarray(self.ckin,10)
def revRatesOfProgress(self):
"""Reverse rates of progress of the reactions."""
return _cantera.kin_getarray(self.ckin,20)
def netRatesOfProgress(self):
"""Net rates of progress of the reactions."""
return _cantera.kin_getarray(self.ckin,30)
def equilibriumConstants(self):
@ -198,9 +210,11 @@ class Kinetics:
return _cantera.kin_getarray(self.ckin,32)
def fwdRateConstants(self):
"""Forward rate constants for all reactions."""
return _cantera.kin_getarray(self.ckin,34)
def revRateConstants(self, doIrreversible = 0):
"""Reverse rate constants for all reactions."""
if doIrreversible:
return _cantera.kin_getarray(self.ckin,35)
else:

View file

@ -35,11 +35,12 @@ class Transport:
self._models[self.model] = self.__tr_id
def __del__(self):
for m in self._models.keys():
try:
_cantera.tran_delete(self._models[m])
except:
pass
if hasattr(self,'_models'):
for m in self._models.keys():
try:
_cantera.tran_delete(self._models[m])
except:
pass
def addTransportModel(self, model, loglevel=1):
new_id = _cantera.Transport(model,

View file

@ -2,14 +2,31 @@
Physical Constants
"""
# One atmosphere in Pascals
OneAtm = 101325.0
# The ideal gas constant in J/kmo-K
GasConstant = 8314.0
# Avogadro's Number, /kmol
Avogadro = 6.022136736e26
# The ideal gas constant in cal/mol-K
GasConst_cal_mol_K = 1.987
# Boltzmann-s constant
Boltzmann = GasConstant / Avogadro
# The Stefan-Boltzmann constant, W/m^2K^4
StefanBoltz = 5.67e-8
# The charge on an electron
ElectronCharge = 1.602e-19
Pi = 3.1415926
# Faraday's constant, C/kmol
Faraday = ElectronCharge * Avogadro
# Planck's constant
Planck = 6.6262e-34

View file

@ -38,7 +38,7 @@ win: _winbuild
_build: $(SRCS) $(LIB_DEPS)
touch src/pycantera.cpp
(@PYTHON_CMD@ setup.py build)
(CXX=@CXX@; export CXX; CC=@CC@; export CC; @PYTHON_CMD@ setup.py build)
echo 'ok' > _build

View file

@ -71,7 +71,7 @@ thermo_getfp(PyObject *self, PyObject *args)
if (!PyArg_ParseTuple(args, "ii:thermo_getfp", &th, &job))
return NULL;
try {
// try {
// floating-point attributes
switch (job) {
@ -123,10 +123,10 @@ thermo_getfp(PyObject *self, PyObject *args)
PyErr_SetString(ErrorObject,"Unknown floating-point attribute");
return NULL;
}
}
catch (CanteraError) {
return reportCanteraError();
}
//}
//catch (CanteraError) {
// return reportCanteraError();
//}
}
static PyObject*

View file

@ -11,6 +11,7 @@
#pragma warning(disable:4503)
#endif
#include "../../../config.h"
#include "Python.h"
#include "Numeric/arrayobject.h"

View file

@ -178,6 +178,7 @@ namespace Cantera {
*/
virtual void getActivityConcentrations(doublereal* c) const {
getConcentrations(c);
//for (int k = 0; k < m_kk; k++) if (c[k] < 0.0) c[k] = 0.0;
}
/**

View file

@ -12,14 +12,7 @@
#include <iostream>
#include <string>
// on cygwin, #include <sstream> doesn't work
#if defined(__CYGWIN__)
#undef USE_STRINGSTREAM
#else
#define USE_STRINGSTREAM
#endif
#ifdef USE_STRINGSTREAM
#ifdef HAS_SSTREAM
#include <sstream>
#endif
using namespace std;
@ -64,7 +57,7 @@ namespace pip {
* somehow. Should probably default to the USE_STRINGSTREAM
* option.
*/
#ifdef USE_STRINGSTREAM
#ifdef HAS_SSTREAM
/*
* Read a line from the file
*/

View file

@ -21,6 +21,8 @@
#include "../CVode.h"
#include "../Kinetics.h"
#define INCL_REACTOR_INTEG
namespace Cantera {
/**

View file

@ -5,9 +5,9 @@ namespace Cantera {
ReactorNet::ReactorNet() : FuncEval(), m_nr(0), m_nreactors(0),
m_integ(0), m_time(0.0), m_init(false),
m_nv(0), m_rtol(1.0e-6), m_atols(1.0e-15),
m_nv(0), m_rtol(1.0e-9), m_atols(1.0e-15),
m_maxstep(-1.0),
m_verbose(false)
m_verbose(true)
{
m_integ = new CVodeInt;
@ -50,7 +50,7 @@ namespace Cantera {
if (m_verbose) {
sprintf(buf, "Number of equations: %d\n", neq());
writelog(buf);
sprintf(buf, "Maximum time step: %g14.6\n", m_maxstep);
sprintf(buf, "Maximum time step: %14.6g\n", m_maxstep);
writelog(buf);
}
m_integ->initialize(t0, *this);
@ -59,8 +59,8 @@ namespace Cantera {
void ReactorNet::advance(doublereal time) {
if (!m_init) {
if (m_maxstep < 0.0)
m_maxstep = time - m_time;
//if (m_maxstep < 0.0)
m_maxstep = time;// - m_time;
initialize();
}
m_integ->integrate(time);
@ -70,8 +70,8 @@ namespace Cantera {
double ReactorNet::step(doublereal time) {
if (!m_init) {
if (m_maxstep < 0.0)
m_maxstep = time - m_time;
//if (m_maxstep < 0.0)
m_maxstep = time;// - m_time;
initialize();
}
m_time = m_integ->step(time);

View file

@ -54,8 +54,8 @@ namespace Cantera {
}
void setTolerances(doublereal rtol, doublereal atol) {
m_rtol = rtol;
m_atols = atol;
if (rtol >= 0.0) m_rtol = rtol;
if (atol >= 0.0) m_atols = atol;
m_init = false;
}

View file

@ -245,7 +245,7 @@ depends:
endif
changes:
perl cvs2cl.pl --prune
cvs2cl.pl --prune
export: changes
@INSTALL@ -d $(export_dir)

View file

@ -50,7 +50,7 @@ typedef int ftnlen; // Fortran hidden string length type
// OS X, This used to add some Mac-specific directories to the default
// data file search path.
#undef DARWIN
#undef HAS_SSTREAM
//--------- Fonts for reaction path diagrams ----------------------
#undef RXNPATH_FONT

26
config/configure vendored
View file

@ -3167,6 +3167,26 @@ fi
echo "$as_me:$LINENO: result: ${precompile_headers}" >&5
echo "${ECHO_T}${precompile_headers}" >&6
has_sstream=no
echo "$as_me:$LINENO: checking for sstream" >&5
echo $ECHO_N "checking for sstream... $ECHO_C" >&6
cat >> teststream.cpp << \EOF
#include <sstream>
main() {}
EOF
msg=`$CXX -c testsstream &> /dev/null`
if test -f testsstream.o; then
has_sstream=yes
rm teststream.o
cat >>confdefs.h <<\_ACEOF
#define HAS_SSTREAM 1
_ACEOF
fi
rm teststream.cpp
echo "$as_me:$LINENO: result: ${has_sstream}" >&5
echo "${ECHO_T}${has_sstream}" >&6
#---------------------------------
# Fortran
@ -3264,7 +3284,7 @@ fi
# Provide some information about the compiler.
echo "$as_me:3267:" \
echo "$as_me:3287:" \
"checking for Fortran 77 compiler version" >&5
ac_compiler=`set X $ac_compile; echo $2`
{ (eval echo "$as_me:$LINENO: \"$ac_compiler --version </dev/null >&5\"") >&5
@ -3441,7 +3461,7 @@ _ACEOF
# flags.
ac_save_FFLAGS=$FFLAGS
FFLAGS="$FFLAGS $ac_verb"
(eval echo $as_me:3444: \"$ac_link\") >&5
(eval echo $as_me:3464: \"$ac_link\") >&5
ac_f77_v_output=`eval $ac_link 5>&1 2>&1 | grep -v 'Driving:'`
echo "$ac_f77_v_output" >&5
FFLAGS=$ac_save_FFLAGS
@ -3521,7 +3541,7 @@ _ACEOF
# flags.
ac_save_FFLAGS=$FFLAGS
FFLAGS="$FFLAGS $ac_cv_prog_f77_v"
(eval echo $as_me:3524: \"$ac_link\") >&5
(eval echo $as_me:3544: \"$ac_link\") >&5
ac_f77_v_output=`eval $ac_link 5>&1 2>&1 | grep -v 'Driving:'`
echo "$ac_f77_v_output" >&5
FFLAGS=$ac_save_FFLAGS

View file

@ -481,6 +481,21 @@ if test -n "$GCC"; then
fi
AC_MSG_RESULT(${precompile_headers})
has_sstream=no
AC_MSG_CHECKING(for sstream)
cat >> teststream.cpp << \EOF
#include <sstream>
main() {}
EOF
msg=`$CXX -c testsstream &> /dev/null`
if test -f testsstream.o; then
has_sstream=yes
rm teststream.o
AC_DEFINE(HAS_SSTREAM)
fi
rm teststream.cpp
AC_MSG_RESULT(${has_sstream})
#---------------------------------
# Fortran

View file

@ -76,8 +76,8 @@ except:
ctpath = "-"
fm = open(ctdir+"/ctpath.m","w")
fm.write("""path(path,'"""+prefix+"""/matlab/toolbox/cantera/cantera')\n""")
fm.write("""path(path,'"""+prefix+"""/matlab/toolbox/cantera/cantera/1D')\n""")
fm.write("""path('"""+prefix+"""/matlab/toolbox/cantera/cantera',path)\n""")
fm.write("""path('"""+prefix+"""/matlab/toolbox/cantera/cantera/1D',path)\n""")
fm.close()
print """