From d6611f587832cf717e0eb45d533f6055234b7ec2 Mon Sep 17 00:00:00 2001 From: Dave Goodwin Date: Thu, 14 Jul 2005 18:54:10 +0000 Subject: [PATCH] *** empty log message *** --- Cantera/clib/src/ct.cpp | 10 ++++++- Cantera/clib/src/ct.h | 1 + Cantera/clib/src/ctmultiphase.cpp | 5 ++++ Cantera/clib/src/ctmultiphase.h | 1 + Cantera/cxx/demos/example_utils.h | 2 +- .../matlab/cantera/private/ctfunctions.cpp | 3 +++ Cantera/matlab/cantera/private/mllogger.h | 3 +++ Cantera/python/Cantera/mixture.py | 6 ++++- Cantera/python/examples/equilibrium/stoich.py | 15 ++++++----- Cantera/python/src/ctfuncs.cpp | 2 +- Cantera/python/src/ctmultiphase_methods.cpp | 14 ++++++++++ Cantera/python/src/methods.h | 1 + Makefile.in | 2 ++ config.h.in | 4 +++ config/configure | 27 ++++++++++--------- config/configure.in | 24 +++++++---------- configure | 2 +- examples/cxx/example_utils.h | 2 +- ext/f2c_libs/arith.h | 6 +++-- test_problems/python/runtest | 4 +-- tools/templates/f77/demo_ftnlib.cpp | 1 + 21 files changed, 91 insertions(+), 44 deletions(-) diff --git a/Cantera/clib/src/ct.cpp b/Cantera/clib/src/ct.cpp index 984b3f4fb..176be3325 100755 --- a/Cantera/clib/src/ct.cpp +++ b/Cantera/clib/src/ct.cpp @@ -493,7 +493,10 @@ extern "C" { equilibrate(*th(n), XY, solver, rtol, maxsteps, loglevel); return 0; } - catch (CanteraError) {return -1;} + catch (CanteraError) { + cout << "exception caught in th_equil. returning -1." << endl; + return -1; + } } doublereal DLL_EXPORT th_refPressure(int n) { @@ -1040,6 +1043,11 @@ extern "C" { catch (CanteraError) { return -1; } } + int DLL_EXPORT write_HTML_log(char* file) { + write_logfile(string(file)); + return 0; + } + int DLL_EXPORT getCanteraError(int buflen, char* buf) { string e; e = lastErrorMessage(); diff --git a/Cantera/clib/src/ct.h b/Cantera/clib/src/ct.h index 7c662ce5e..990450f25 100755 --- a/Cantera/clib/src/ct.h +++ b/Cantera/clib/src/ct.h @@ -147,6 +147,7 @@ extern "C" { char* id, int validate, double threshold); int DLL_IMPORT getCanteraError(int buflen, char* buf); int DLL_IMPORT showCanteraErrors(); + int DLL_IMPORT write_HTML_log(char* file); int DLL_IMPORT setLogWriter(void* logger); int DLL_IMPORT addCanteraDirectory(int buflen, char* buf); int DLL_IMPORT clearStorage(); diff --git a/Cantera/clib/src/ctmultiphase.cpp b/Cantera/clib/src/ctmultiphase.cpp index 4f5903531..3919591ae 100644 --- a/Cantera/clib/src/ctmultiphase.cpp +++ b/Cantera/clib/src/ctmultiphase.cpp @@ -96,6 +96,11 @@ extern "C" { return 0; } + int DLL_EXPORT mix_init(int i) { + _mix(i)->init(); + return 0; + } + int DLL_EXPORT mix_nElements(int i) { return _mix(i)->nElements(); } diff --git a/Cantera/clib/src/ctmultiphase.h b/Cantera/clib/src/ctmultiphase.h index e8d8f7153..f85ea8fe1 100644 --- a/Cantera/clib/src/ctmultiphase.h +++ b/Cantera/clib/src/ctmultiphase.h @@ -10,6 +10,7 @@ extern "C" { int DLL_IMPORT mix_copy(int i); int DLL_IMPORT mix_assign(int i, int j); int DLL_IMPORT mix_addPhase(int i, int j, double moles); + int DLL_IMPORT mix_init(int i); int DLL_IMPORT mix_nElements(int i); int DLL_IMPORT mix_elementIndex(int i, char* name); int DLL_IMPORT mix_speciesIndex(int i, int k, int p); diff --git a/Cantera/cxx/demos/example_utils.h b/Cantera/cxx/demos/example_utils.h index 6fd9c93cc..5426c8871 100644 --- a/Cantera/cxx/demos/example_utils.h +++ b/Cantera/cxx/demos/example_utils.h @@ -49,7 +49,7 @@ void plotSoln(string fname, string fmt, string title, const G& gas, const A& sol inline void writeCanteraHeader(ostream& s) { s << endl; - s << " Cantera version " << CANTERA_VERSION << endl; + s << " Cantera version " << "CANTERA_VERSION" << endl; s << " Copyright California Institute of Technology, 2002." << endl; s << " http://www.cantera.org" << endl; s << endl; diff --git a/Cantera/matlab/cantera/private/ctfunctions.cpp b/Cantera/matlab/cantera/private/ctfunctions.cpp index 82e0f437d..ce1ee5971 100644 --- a/Cantera/matlab/cantera/private/ctfunctions.cpp +++ b/Cantera/matlab/cantera/private/ctfunctions.cpp @@ -5,8 +5,11 @@ #include "../../../clib/src/ctxml.h" #include "ctmatutils.h" #include +#include +using namespace std; void reportError() { + write_HTML_log("error_log.html"); int buflen = 0; char* output_buf = 0; buflen = getCanteraError(buflen, output_buf) + 1; diff --git a/Cantera/matlab/cantera/private/mllogger.h b/Cantera/matlab/cantera/private/mllogger.h index 03b0cc2a6..439075842 100644 --- a/Cantera/matlab/cantera/private/mllogger.h +++ b/Cantera/matlab/cantera/private/mllogger.h @@ -5,6 +5,9 @@ #include #include "../../../src/logger.h" +#include +using namespace std; + static std::string ss = "disp('"; namespace Cantera { diff --git a/Cantera/python/Cantera/mixture.py b/Cantera/python/Cantera/mixture.py index 41301afd5..3054f3e3d 100644 --- a/Cantera/python/Cantera/mixture.py +++ b/Cantera/python/Cantera/mixture.py @@ -52,9 +52,13 @@ class Mixture: moles = p[1] except: ph = p - moles = 0 + if p == phases[0]: + moles = 1 + else: + moles = 0 self._addPhase(ph, moles) self._phases.append(ph) + _cantera.mix_init(self.__mixid) self.setTemperature(self._phases[0].temperature()) self.setPressure(self._phases[0].pressure()) diff --git a/Cantera/python/examples/equilibrium/stoich.py b/Cantera/python/examples/equilibrium/stoich.py index ce08e49b8..77339c617 100644 --- a/Cantera/python/examples/equilibrium/stoich.py +++ b/Cantera/python/examples/equilibrium/stoich.py @@ -33,14 +33,15 @@ except: print "ChemEquil solver failed! Try the MultiPhaseEquil solver..." # Try again. Reset the gas to the initial state - gas.set(T = temp, P = OneAtm, X = comp) + gas.set(T = temp, P = OneAtm, X = comp) - # setting parameter 'solver' to 1 requests that the - # MultiPhaseEquil solver be used (specifying 0 would cause - # ChemEquil to be used). Some other useful parameters are rtol - # (relative error tolerance, default = 1.0e-9), max_steps (default = 1000), - # loglevel (default = 0). - gas.equilibrate("TP", solver = 1, rtol = 1.0e-10, loglevel = 4) + # The MultiPhaseEquil solver is used to equilibrate 'Mixture' + # objects, since these may have more than one phase. Here we'll + # create a Mixture object containing only the gas. Some other + # useful parameters are rtol (relative error tolerance, default = + # 1.0e-9), max_steps (default = 1000), loglevel (default = 0). + mix = Mixture([(gas,1.0)]) + mix.equilibrate("TP", loglevel=4) # print a summary of the results print gas diff --git a/Cantera/python/src/ctfuncs.cpp b/Cantera/python/src/ctfuncs.cpp index 124017cf0..6a50f0c56 100644 --- a/Cantera/python/src/ctfuncs.cpp +++ b/Cantera/python/src/ctfuncs.cpp @@ -86,7 +86,7 @@ ct_writelogfile(PyObject *self, PyObject *args) { int iok; char *logfile; - if (!PyArg_ParseTuple(args, "s:ck2cti", &logfile)) + if (!PyArg_ParseTuple(args, "s:writelogfile", &logfile)) return NULL; iok = writelogfile(logfile); if (iok == -1) { return reportCanteraError();} diff --git a/Cantera/python/src/ctmultiphase_methods.cpp b/Cantera/python/src/ctmultiphase_methods.cpp index c419beeab..1330d88b1 100644 --- a/Cantera/python/src/ctmultiphase_methods.cpp +++ b/Cantera/python/src/ctmultiphase_methods.cpp @@ -38,6 +38,20 @@ py_mix_addPhase(PyObject *self, PyObject *args) } +static PyObject * +py_mix_init(PyObject *self, PyObject *args) +{ + int i; + int _val; + if (!PyArg_ParseTuple(args, "i:mix_init", &i)) + return NULL; + + _val = mix_init(i); + if (_val < 0) return reportCanteraError(); + return Py_BuildValue("i",_val); +} + + static PyObject * py_mix_nElements(PyObject *self, PyObject *args) { diff --git a/Cantera/python/src/methods.h b/Cantera/python/src/methods.h index b4ee0b4ad..40394a2fd 100644 --- a/Cantera/python/src/methods.h +++ b/Cantera/python/src/methods.h @@ -257,6 +257,7 @@ static PyMethodDef ct_methods[] = { {"mix_new", py_mix_new, METH_VARARGS}, {"mix_del", py_mix_del, METH_VARARGS}, {"mix_addPhase", py_mix_addPhase, METH_VARARGS}, + {"mix_init", py_mix_init, METH_VARARGS}, {"mix_nElements", py_mix_nElements, METH_VARARGS}, {"mix_elementIndex", py_mix_elementIndex, METH_VARARGS}, {"mix_speciesIndex", py_mix_speciesIndex, METH_VARARGS}, diff --git a/Makefile.in b/Makefile.in index 69b40350d..4e7cb7383 100755 --- a/Makefile.in +++ b/Makefile.in @@ -309,6 +309,8 @@ cf: gzip cantera-cf.tar; scp cantera-cf.tar.gz dggoodwin@cf-shell.sourceforge.net:cantera.tar.gz) sshcf './runall' & +configure: config/configure.in + (cd config; autoconf) #info: # echo '#define CANTERA_ROOT "@prefix@/cantera"' > include/ctdir.h diff --git a/config.h.in b/config.h.in index 45ecbd162..c106217f2 100755 --- a/config.h.in +++ b/config.h.in @@ -61,6 +61,9 @@ typedef int ftnlen; // Fortran hidden string length type #undef DARWIN #undef HAS_SSTREAM +// Cantera version +#undef CANTERA_VERSION + // Identify whether the operating system is cygwin's overlay of // windows, with gcc being used as the compiler. #undef CYGWIN @@ -86,6 +89,7 @@ typedef int ftnlen; // Fortran hidden string length type //--------------------- Cantera ----------------------------------- #undef CANTERA_ROOT + // This data pathway is used to locate a directory where datafiles // are to be found. Note, the local directory is always searched // as well. diff --git a/config/configure b/config/configure index 008080c7a..5f66ba3a6 100755 --- a/config/configure +++ b/config/configure @@ -1353,6 +1353,10 @@ fi ctversion=${CANTERA_VERSION} +cat >>confdefs.h <<_ACEOF +#define CANTERA_VERSION $ctversion +_ACEOF + homedir=${HOME} @@ -1829,11 +1833,7 @@ fi -# -# Fortran90 Interface -# Before turning on this interface, we do a rudimentary check -# to make sure that the F90 compiler can be found -# + BUILD_F90=1 if test "x$BUILD_F90_INTERFACE" = "xn"; then BUILD_F90=0 @@ -3339,7 +3339,7 @@ echo "${ECHO_T}${has_sstream}" >&6 # Fortran #--------------------------------- -if test x"$build_with_f2c" = "x0"; then +#if test x"$build_with_f2c" = "x0"; then ac_ext=f ac_compile='$F77 -c $FFLAGS conftest.$ac_ext >&5' ac_link='$F77 -o conftest$ac_exeext $FFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' @@ -3860,7 +3860,7 @@ ac_compiler_gnu=$ac_cv_c_compiler_gnu override_f77_libs=0; case $ac_sys_system in - Darwin*) FLIBS='-lstdc++ -lg2c -lcc_dynamic'; override_f77_libs=1; SHARED_CTLIB=0;; + Darwin*) FLIBS='-lSystem'; override_f77_libs=1; SHARED_CTLIB=0;; esac if test $override_f77_libs -gt 0; then @@ -3869,13 +3869,14 @@ if test $override_f77_libs -gt 0; then echo FLIBS = $FLIBS fi -fi +#fi #-------------------------------------------- -if test -n ${BUILD_F90}; then +if test "x${BUILD_F90}" != "x0"; then echo F90 = $F90 + echo BUILD_F90 = $BUILD_F90 if test "$F90" = "default" -o \ "$F90"x = "x"; then for ac_prog in f95 gfortran g95 @@ -3938,7 +3939,7 @@ f90type=none f90_module_dir='-I' f90_opts='' -if test -n ${BUILD_F90}; then +if test "x${BUILD_F90}" != "x0"; then echo "$as_me:$LINENO: checking Fortran 90 compiler ($F90) type" >&5 echo $ECHO_N "checking Fortran 90 compiler ($F90) type... $ECHO_C" >&6 cat >> testf90.f90 << EOF @@ -3970,9 +3971,9 @@ EOF f90type="g95" f90opts="-fno-second-underscore -I. -I${ct_incdir}" f90buildopts="-fno-second-underscore -I." - case $ac_sys_system in - Darwin*) FLIBS='-lg2c -lcc_dynamic';; - esac + #case $ac_sys_system in + # Darwin*) FLIBS='-lg2c -lcc_dynamic';; + #esac fi msg=`${F90} -V &> f90out` diff --git a/config/configure.in b/config/configure.in index 8d00ea6ec..9ac1856da 100755 --- a/config/configure.in +++ b/config/configure.in @@ -109,6 +109,7 @@ AC_SUBST(python_win_prefix) ctversion=${CANTERA_VERSION} AC_SUBST(ctversion) +AC_DEFINE_UNQUOTED(CANTERA_VERSION,$ctversion) homedir=${HOME} AC_SUBST(homedir) @@ -474,11 +475,7 @@ AC_SUBST(LOCAL_LIBS) AC_SUBST(CT_SHARED_LIB) -# -# Fortran90 Interface -# Before turning on this interface, we do a rudimentary check -# to make sure that the F90 compiler can be found -# + BUILD_F90=1 if test "x$BUILD_F90_INTERFACE" = "xn"; then BUILD_F90=0 @@ -624,7 +621,7 @@ AC_MSG_RESULT(${has_sstream}) # Fortran #--------------------------------- -if test x"$build_with_f2c" = "x0"; then +#if test x"$build_with_f2c" = "x0"; then AC_PROG_F77() # if G77 is defined, then add a flag to turn off adding a second underscore @@ -638,7 +635,7 @@ AC_F77_LIBRARY_LDFLAGS() override_f77_libs=0; case $ac_sys_system in - Darwin*) FLIBS='-lstdc++ -lg2c -lcc_dynamic'; override_f77_libs=1; SHARED_CTLIB=0;; + Darwin*) FLIBS='-lSystem'; override_f77_libs=1; SHARED_CTLIB=0;; esac if test $override_f77_libs -gt 0; then @@ -647,13 +644,12 @@ if test $override_f77_libs -gt 0; then echo FLIBS = $FLIBS fi -fi +#fi #-------------------------------------------- -if test ${BUILD_F90} = "1"; then - echo F90 = $F90 +if test "x${BUILD_F90}" != "x0"; then if test "$F90" = "default" -o \ "$F90"x = "x"; then AC_PATH_PROGS(F90, f95 gfortran g95, "none") @@ -672,7 +668,7 @@ f90type=none f90_module_dir='-I' f90_opts='' -if test ${BUILD_F90} = "1" ; then +if test "x${BUILD_F90}" != "x0"; then AC_MSG_CHECKING(Fortran 90 compiler ($F90) type) cat >> testf90.f90 << EOF module mt @@ -703,9 +699,9 @@ EOF f90type="g95" f90opts="-fno-second-underscore -I. -I${ct_incdir}" f90buildopts="-fno-second-underscore -I." - case $ac_sys_system in - Darwin*) FLIBS='-lg2c -lcc_dynamic';; - esac + #case $ac_sys_system in + # Darwin*) FLIBS='-lg2c -lcc_dynamic';; + #esac fi msg=`${F90} -V &> f90out` diff --git a/configure b/configure index 87de87528..1ce6f8a58 100755 --- a/configure +++ b/configure @@ -309,7 +309,7 @@ FFLAGS=${FFLAGS:='-O3 -g'} # the additional Fortran flags required for linking, if any. Leave commented # out if no additional flags are required. -LFORT_FLAGS="-lcc_dynamic" +#LFORT_FLAGS="-lcc_dynamic" #------------------------------------------------------ diff --git a/examples/cxx/example_utils.h b/examples/cxx/example_utils.h index 33984c84d..3cab8a8a5 100755 --- a/examples/cxx/example_utils.h +++ b/examples/cxx/example_utils.h @@ -50,7 +50,7 @@ void plotSoln(string fname, string fmt, string title, const G& gas, const A& sol inline void writeCanteraHeader(ostream& s) { s << endl; - s << " Cantera version " << CANTERA_VERSION << endl; + s << " Cantera version " << "CANTERA_VERSION" << endl; s << " Copyright California Institute of Technology, 2002." << endl; s << " http://www.cantera.org" << endl; s << endl; diff --git a/ext/f2c_libs/arith.h b/ext/f2c_libs/arith.h index 76539f82b..508eb414f 100644 --- a/ext/f2c_libs/arith.h +++ b/ext/f2c_libs/arith.h @@ -1,2 +1,4 @@ -#define IEEE_8087 -#define Arith_Kind_ASL 1 +#define IEEE_MC68k +#define Arith_Kind_ASL 2 +#define Double_Align +#define NANCHECK diff --git a/test_problems/python/runtest b/test_problems/python/runtest index 125cdddbc..877da74fb 100755 --- a/test_problems/python/runtest +++ b/test_problems/python/runtest @@ -28,7 +28,7 @@ PYTHON_CMD=${FIRSTARG:=PYTHON_CMDA} #echo $PYTHON_CMD -$PYTHON_CMD ../../Cantera/python/examples/flame1.py > flame1.out +$PYTHON_CMD ../../Cantera/python/examples/flames/flame1.py > flame1.out retnStat=$? if [ $retnStat != "0" ] then @@ -36,7 +36,7 @@ then echo "flame1.py returned with bad status, $retnStat, check output" fi -$PYTHON_CMD ../../Cantera/python/examples/diamond.py > diamond.out +$PYTHON_CMD ../../Cantera/python/examples/surface_chemistry/diamond.py > diamond.out retnStat=$? if [ $retnStat != "0" ] then diff --git a/tools/templates/f77/demo_ftnlib.cpp b/tools/templates/f77/demo_ftnlib.cpp index b3e57f11a..5f2a067b3 100644 --- a/tools/templates/f77/demo_ftnlib.cpp +++ b/tools/templates/f77/demo_ftnlib.cpp @@ -32,6 +32,7 @@ #endif // add any other Cantera header files you need here +#include #include