diff --git a/Cantera/fortran/src/Makefile.in b/Cantera/fortran/src/Makefile.in index 057f9cd05..7b7f13ea2 100644 --- a/Cantera/fortran/src/Makefile.in +++ b/Cantera/fortran/src/Makefile.in @@ -14,7 +14,7 @@ SUFFIXES= .cpp .d .o CXX_FLAGS = @CXXFLAGS@ $(CXX_OPT) -OBJS = fct.o +OBJS = fct.o fctxml.o DEPENDS = $(OBJS:.o=.d) @@ -32,7 +32,7 @@ CANTERA_LIBDIR=@buildlib@ # ../../../lib LIB_DEPS = $(CANTERA_LIBDIR)/libcantera.a \ - $(CANTERA_LIBDIR)/libtransport.a $(CANTERA_LIBDIR)/libconverters.a + $(CANTERA_LIBDIR)/libtransport.a # the directory where Cantera include files may be found. CANTERA_INCDIR=../../src diff --git a/Cantera/fortran/src/fct.cpp b/Cantera/fortran/src/fct.cpp index 04da10960..721a3593b 100644 --- a/Cantera/fortran/src/fct.cpp +++ b/Cantera/fortran/src/fct.cpp @@ -19,9 +19,11 @@ #include "transport/TransportFactory.h" #include "ctml.h" #include "importCTML.h" -#include "converters/ck2ctml.h" +//#include "converters/ck2ct.h" +#include "../../clib/src/Storage.h" #include "../../clib/src/Cabinet.h" #include "InterfaceKinetics.h" +#include "PureFluidPhase.h" #include "flib_defs.h" diff --git a/Cantera/src/ArrayViewer.h b/Cantera/src/ArrayViewer.h index 160a7c94a..fab042751 100755 --- a/Cantera/src/ArrayViewer.h +++ b/Cantera/src/ArrayViewer.h @@ -49,7 +49,7 @@ namespace Cantera { data = v; } - /// resize the array + /// resize the array viewer void resize(int n, int m) { m_nrows = n; m_ncols = m; diff --git a/Cantera/src/ChemEquil.cpp b/Cantera/src/ChemEquil.cpp index f480c4578..02a25fb84 100755 --- a/Cantera/src/ChemEquil.cpp +++ b/Cantera/src/ChemEquil.cpp @@ -294,8 +294,9 @@ namespace Cantera { } } if (j < m_mm) - throw CanteraError("estimateElementPotentials", - "too few species."); + return -1; + //throw CanteraError("estimateElementPotentials", + // "too few species (" + int2str(j) + ")."); for (m = 0; m < m_mm; m++) { for (n = 0; n < m_mm; n++) { @@ -309,7 +310,7 @@ namespace Cantera { info = solve(aa, b.begin()); } catch (CanteraError) { - throw CanteraError("estimateElementPotentials","singular matrix."); + return -2; //throw CanteraError("estimateElementPotentials","singular matrix."); } if (info == 0) { @@ -560,9 +561,15 @@ namespace Cantera { && fabs(deltay) < options.relTolerance) { options.iterations = iter; + m_lambda.resize(m_mm); + doublereal rt = GasConstant*m_thermo->temperature(); + for (m = 0; m < m_mm; m++) { + m_lambda[m] = x[m]*rt; + } + if (m_thermo->temperature() > m_thermo->maxTemp() + 1.0 || m_thermo->temperature() < m_thermo->minTemp() - 1.0 ) { - throw CanteraError("ChemEquil","Temperature (" + writelog("Warning: Temperature (" +fp2str(m_thermo->temperature())+" K) outside " "valid range of "+fp2str(m_thermo->minTemp())+" K to " +fp2str(m_thermo->maxTemp())+" K\n"); diff --git a/Cantera/src/ChemEquil.h b/Cantera/src/ChemEquil.h index fe72c7c3a..737cf6164 100755 --- a/Cantera/src/ChemEquil.h +++ b/Cantera/src/ChemEquil.h @@ -75,6 +75,7 @@ namespace Cantera { int equilibrate(thermo_t& s, int XY = 0); int equilibrate(thermo_t& s, int XY, vector_fp& elMoles); + const vector_fp& elementPotentials() const { return m_lambda; } /** * Options controlling how the calculation is carried out. @@ -163,6 +164,7 @@ namespace Cantera { inline void equilibrate(thermo_t& s, const char* XY) { ChemEquil e; e.equilibrate(s,_equilflag(XY)); + s.setElementPotentials(e.elementPotentials()); } } diff --git a/Cantera/src/NasaThermo.h b/Cantera/src/NasaThermo.h index 30494bbcd..b81c14afa 100755 --- a/Cantera/src/NasaThermo.h +++ b/Cantera/src/NasaThermo.h @@ -249,7 +249,7 @@ namespace Cantera { /* * This map takes as its index, the species index in the phase. * It returns the group index, where the temperature polynomials - * for that species are storred. group indecises start at 1, + * for that species are stored. group indecises start at 1, * so a decrement is always performed to access vectors. */ mutable map m_group_map; diff --git a/Cantera/src/SpeciesThermoFactory.cpp b/Cantera/src/SpeciesThermoFactory.cpp index 6a81807b3..42537d41e 100755 --- a/Cantera/src/SpeciesThermoFactory.cpp +++ b/Cantera/src/SpeciesThermoFactory.cpp @@ -124,49 +124,45 @@ namespace Cantera { } - /// Check the continuity of properties at the midpoint - /// temperature, and adjust the high-T coefficients to - /// make the properties exactly continuous at Tmid. + /// Check the continuity of properties at the midpoint + /// temperature. void NasaThermo::checkContinuity(double tmid, const doublereal* clow, - doublereal* chigh) { + doublereal* chigh) { - // heat capacity - doublereal cplow = poly4(tmid, clow+2); - doublereal cphigh = poly4(tmid, chigh+2); - doublereal delta = cplow - cphigh; - if (fabs(delta/cplow) > 0.001) { - writelog("\n**** WARNING ****\nDiscontinuity in cp/R detected at Tmid = " - +fp2str(tmid)+"\n"); - writelog("\tValue computed using low-temperature polynomial: "+fp2str(cplow)+".\n"); - writelog("\tValue computed using high-temperature polynomial: "+fp2str(cphigh)+".\n"); - } - //chigh[2] += cplow - cphigh; - - // enthalpy - doublereal hrtlow = enthalpy_RT(tmid, clow); - doublereal hrthigh = enthalpy_RT(tmid, chigh); - delta = hrtlow - hrthigh; - // chigh[0] += tmid*(hrtlow - hrthigh); - if (fabs(delta/hrtlow) > 0.001) { - writelog("\n**** WARNING ****\nDiscontinuity in h/RT detected at Tmid = " - +fp2str(tmid)+"\n"); - writelog("\tValue computed using low-temperature polynomial: "+fp2str(hrtlow)+".\n"); - writelog("\tValue computed using high-temperature polynomial: "+fp2str(hrthigh)+".\n"); - } - - // entropy - doublereal srlow = entropy_R(tmid, clow); - doublereal srhigh = entropy_R(tmid, chigh); - //chigh[1] += srlow - srhigh; - delta = srlow - srhigh; - if (fabs(delta/srlow) > 0.001) { - writelog("\n**** WARNING ****\nDiscontinuity in s/R detected at Tmid = " - +fp2str(tmid)+"\n"); - writelog("\tValue computed using low-temperature polynomial: "+fp2str(srlow)+".\n"); - writelog("\tValue computed using high-temperature polynomial: "+fp2str(srhigh)+".\n"); - } + // heat capacity + doublereal cplow = poly4(tmid, clow+2); + doublereal cphigh = poly4(tmid, chigh+2); + doublereal delta = cplow - cphigh; + if (fabs(delta/cplow) > 0.001) { + writelog("\n**** WARNING ****\nDiscontinuity in cp/R detected at Tmid = " + +fp2str(tmid)+"\n"); + writelog("\tValue computed using low-temperature polynomial: "+fp2str(cplow)+".\n"); + writelog("\tValue computed using high-temperature polynomial: "+fp2str(cphigh)+".\n"); } + // enthalpy + doublereal hrtlow = enthalpy_RT(tmid, clow); + doublereal hrthigh = enthalpy_RT(tmid, chigh); + delta = hrtlow - hrthigh; + if (fabs(delta/hrtlow) > 0.001) { + writelog("\n**** WARNING ****\nDiscontinuity in h/RT detected at Tmid = " + +fp2str(tmid)+"\n"); + writelog("\tValue computed using low-temperature polynomial: "+fp2str(hrtlow)+".\n"); + writelog("\tValue computed using high-temperature polynomial: "+fp2str(hrthigh)+".\n"); + } + + // entropy + doublereal srlow = entropy_R(tmid, clow); + doublereal srhigh = entropy_R(tmid, chigh); + delta = srlow - srhigh; + if (fabs(delta/srlow) > 0.001) { + writelog("\n**** WARNING ****\nDiscontinuity in s/R detected at Tmid = " + +fp2str(tmid)+"\n"); + writelog("\tValue computed using low-temperature polynomial: "+fp2str(srlow)+".\n"); + writelog("\tValue computed using high-temperature polynomial: "+fp2str(srhigh)+".\n"); + } + } + /** * Install a NASA polynomial thermodynamic property diff --git a/Cantera/src/State.h b/Cantera/src/State.h index 36dbd627b..cf7b487be 100755 --- a/Cantera/src/State.h +++ b/Cantera/src/State.h @@ -20,8 +20,6 @@ #define CT_STATE2_H #include "ct_defs.h" -//#include "utilities.h" -//#include "ctexceptions.h" namespace Cantera { @@ -65,7 +63,9 @@ namespace Cantera { */ void getMoleFractions(doublereal* x) const; - /// The mole fraction of species k. + + /// The mole fraction of species k. If k is ouside the valid + /// range, an exception will be thrown. doublereal moleFraction(int k) const; /** @@ -79,34 +79,30 @@ namespace Cantera { /** * Set the mole fractions to the specified values without - * normalizing. + * normalizing. This is useful when the normalization + * condition is being handled by some other means, for example + * by a constraint equation as part of a larger set of + * equations. */ void setMoleFractions_NoNorm(const doublereal* x); /** - * Get the species mass fractions. - * @param y On return, y contains the mass fractions. Array y - * must have a length at least as large as the number of species. - */ - //void getMassFractions(size_t leny, doublereal* y) const { - // copy(m_y.begin(), m_y.end(), y); - //} - - /** - * Get the species mass fractions. @param y On return, y + * Get the species mass fractions. + * @param y On return, y * contains the mass fractions. Array \i y must have a length * greater than or equal to the number of species. */ void getMassFractions(doublereal* y) const; - /// Mass fraction of species k. + /// Mass fraction of species k. If k is outside the valid + /// range, an exception will be thrown. doublereal massFraction(int k) const; /** - * Set the mole fractions to the specified values, and then + * Set the mass fractions to the specified values, and then * normalize them so that they sum to 1.0. - * @param x Array of unnormalized mole fraction values (input). + * @param y Array of unnormalized mass fraction values (input). * Must have a length greater than or equal to the number of * species. */ @@ -168,24 +164,17 @@ namespace Cantera { /// Set the density to value rho (kg/m^3). void setDensity(doublereal rho) { - // if (rho != m_dens) { - m_dens = rho; - //m_C_updater.need_update(); - //} + m_dens = rho; } /// Set the molar density to value n (kmol/m^3). void setMolarDensity(doublereal n) { m_dens = n*meanMolecularWeight(); - //m_C_updater.need_update(); } /// Set the temperature to value temp (K). void setTemperature(doublereal temp) { - //if (temp != m_temp) { - m_temp = temp; - //m_T_updater.need_update(); - //} + m_temp = temp; } /** diff --git a/Cantera/src/ThermoPhase.h b/Cantera/src/ThermoPhase.h index b24db9c5c..96bf8e846 100755 --- a/Cantera/src/ThermoPhase.h +++ b/Cantera/src/ThermoPhase.h @@ -506,6 +506,17 @@ namespace Cantera { virtual void setToEquilState(const doublereal* lambda_RT) { err("setToEquilState"); } + + // called by function 'equilibrate' in ChemEquil.h to transfer + // the element potentials to this object + void setElementPotentials(const vector_fp& lambda) { + m_lambda = lambda; + } + + void getElementPotentials(doublereal* lambda) { + copy(m_lambda.begin(), m_lambda.end(), lambda); + } + //@} void getActivities(doublereal* a); @@ -693,6 +704,7 @@ namespace Cantera { /// Index number int m_index; doublereal m_phi; + vector_fp m_lambda; private: diff --git a/Cantera/src/ct2ctml.cpp b/Cantera/src/ct2ctml.cpp index 7277635d2..042a6e052 100644 --- a/Cantera/src/ct2ctml.cpp +++ b/Cantera/src/ct2ctml.cpp @@ -19,6 +19,7 @@ #include #include #include +#include #include "ctml.h" using namespace Cantera; @@ -44,7 +45,7 @@ namespace ctml { } static bool checkPython() { - string path = tmpDir() + "/.check.py"; + string path = tmpDir() + "/.check.pyw"; ofstream f(path.c_str()); if (!f) { throw CanteraError("checkPython","cannot open "+path+" for writing"); @@ -82,7 +83,15 @@ namespace ctml { void ct2ctml(const char* file) { - string path = tmpDir()+"/.cttmp.py"; + + int irnd = rand(); + struct tm *newtime; + time_t aclock; + time( &aclock ); + cout << "aclock = " << aclock << endl; + cout << rand() << endl; + + string path = tmpDir()+"/.cttmp.pyw"; ofstream f(path.c_str()); if (!f) { throw CanteraError("ct2ctml","cannot open "+path+" for writing."); diff --git a/Cantera/src/ctvector.cpp b/Cantera/src/ctvector.cpp index dbfb9d56e..17321b4d1 100755 --- a/Cantera/src/ctvector.cpp +++ b/Cantera/src/ctvector.cpp @@ -40,13 +40,11 @@ using namespace ct; namespace ct { ctvector_fp::ctvector_fp(size_t n) : _size(0), _alloc(0), _data(0) { - // if (n > 0) resize(n); } ctvector_fp::ctvector_fp(size_t n, value_type v0) : _size(0), _alloc(0), _data(0) { - //if (n > 0) resize(n, v0); } @@ -128,14 +126,12 @@ namespace ct { ctvector_int::ctvector_int(size_t n) : _size(0), _alloc(0), _data(0) { - // if (n > 0) resize(n); } ctvector_int::ctvector_int(size_t n, value_type v0) : _size(0), _alloc(0), _data(0) { - //if (n > 0) - resize(n, v0); + resize(n, v0); } ctvector_int::ctvector_int(const ctvector_int& x) { diff --git a/Cantera/src/sort.h b/Cantera/src/sort.h index 868023460..46db02601 100755 --- a/Cantera/src/sort.h +++ b/Cantera/src/sort.h @@ -9,9 +9,13 @@ namespace Cantera { - // sort (x,y) pairs by x - + /// Given two arrays x and y, sort the (x,y) pairs by the x + /// values. This version is for floating-point x, and integer y. void heapsort(vector_fp& x, vector_int& y); + + /// Given two arrays x and y, sort the (x,y) pairs by the x + /// values. This version is for floating-point x, and + /// floating-point y. void heapsort(vector_fp& x, vector_fp& y); } diff --git a/License.txt b/License.txt index fd6eaa70b..562968336 100755 --- a/License.txt +++ b/License.txt @@ -1,5 +1,5 @@ -Copyright (c) 2001-2003, California Institute of Technology +Copyright (c) 2001-2004, California Institute of Technology All rights reserved. Redistribution and use in source and binary forms, with or without @@ -30,4 +30,3 @@ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - diff --git a/Makefile.in b/Makefile.in index 2fd6a7b00..774fc7d7d 100755 --- a/Makefile.in +++ b/Makefile.in @@ -21,7 +21,7 @@ compact_install = @COMPACT_INSTALL@ prefix=@prefix@ -all: kernel user cxxlib hdr-collect clib python matlab particles \ +all: kernel user cxxlib hdr-collect clib fortran python matlab particles \ utils datafiles # use this target on a Windows machine to build the Python and @@ -64,6 +64,9 @@ ifeq ($(do_ranlib),1) @RANLIB@ @buildlib@/*.a endif +fortran: + cd Cantera/fortran/src; @MAKE@ + cxxlib: cd Cantera/cxx/src; @MAKE@ diff --git a/README.txt b/README.txt index 20cf54526..7af55671b 100644 --- a/README.txt +++ b/README.txt @@ -3,9 +3,9 @@ release 1.5 - 9/12/2003 + 7/30/2004 - Copyright (c) 2001-2003 California Institute of Technology + Copyright (c) 2001-2004 California Institute of Technology @@ -19,6 +19,16 @@ All trademarks referenced herein are property of their respective holders. +Installing a Binary Version of Cantera +====================================== + +Binary installers are available for the Windows and Mac platforms. If +you wish to install from one of these, download the appropriate +installer from the Cantera Sourceforge site and run it. This is the +simplest option if you want a standard installation, and plan to +primarily use Cantera from Python or MATLAB. + + Building Cantera from the source code ===================================== @@ -27,14 +37,18 @@ Building Cantera from the source code 1) Unix/linux/cygwin/Mac OSX build procedure -------------------------------------------- -Run the 'configure' script to build the Makefiles. By default, 'make install' -will install under '/usr/local' If you want to install Cantera somewhere else, -run 'configure' with the 'prefix' option: +Run the 'configure' script to build the Makefiles. -configure --prefix=$HOME/my_cantera_dir +By default, 'make install' will install under '/usr/local' on +linux/unix, and '/Applications/Cantera' on OS X. If you want to +install Cantera somewhere else, run 'configure' with the 'prefix' +option. For example, to install in directory 'cantera' within your +home directory: + +configure --prefix=$HOME/cantera If necessary, edit 'configure' to set options appropriate for your -system. +system before running it. After running 'configure', type: @@ -47,8 +61,13 @@ To test the installation, type make test -After running 'make install', run script '/usr/local/cantera/setup_cantera' -to configure the environment before using Cantera. +After running 'make install', a script 'setup_cantera' will be written +to your home directory. Run it using 'source' +to configure the environment before using Cantera. You may want to add the line + +source ~/setup_cantera + +to your login script. The build process requires a 'make' utility compatible with GNU 'make'. If this has a different name on your system, define @@ -58,24 +77,34 @@ environment variable MAKE to the name (e.g. 'gmake') before running This procedure also builds the Python and MATLAB interfaces if your system is configured to use them. The requirements are: -- Python 2.x + NumPy for the Python interface - -- MATLAB 6.x for the MATLAB toolbox + -- MATLAB 13 or 14 for the MATLAB toolbox. If either is missing or an error occurs, the interface is not installed. +Note that your C++ compiler must be compatible with the compiler used +to compile Python or MATLAB. For MATLAB 14, this means you will need +to build Cantera with g++ 3.x, while for MATLAB 13, you will need to +use g++ 2.95. + 2) Windows Build Procedure -------------------------- -Cantera can be built under Windows using Visual C++ 6.0 and Compaq Visual -Fortran 6.0. In the 'win32' directory, open workspace 'cantera.dsw'. Set -the active project to 'examples', and the active configuration to -'Win32 - Release'. Build the project, and execute 'examples.exe' from -the Build menu to verify that it works. +Cantera can be built under Windows using Visual C++ 6.0 and Compaq +Visual Fortran 6.0. You need to have cygwin installed, however, so +that you can use 'make' ot set up the directory structure in the +install directory. -If you plan to build the Python or MATLAB interfaces, you also need to -build project 'ct'. This creates a DLL file which by default is placed -in the Windows system directory. Edit the project settings if you want -to put it somewhere else. +The first step is to run 'configure' from a cygwin shell window. Once +this finishes, start Visual C++, and go to the 'win32' directory and +open workspace 'cantera.dsw'. Set the active project to 'all', and the +active configuration to 'Win32 - Release'. Build the project. +When this completes, return to the cygwin shell, and type 'make win' +to complete the process. At the end, you should have a working +installation in C:\Cantera (or wherever you specified to 'configure'). + +The Windows build procedure is described in more detail in the +document **. Configuring Matlab diff --git a/tools/src/package4mac.in b/tools/src/package4mac.in index 744cdc4d5..e326015e5 100644 --- a/tools/src/package4mac.in +++ b/tools/src/package4mac.in @@ -1,19 +1,30 @@ #!/bin/sh -INSTALL='@INSTALL@' +INSTALL='@INSTALL' +PYVERSION=2.3 PKGDIR=$HOME/Packages -CTDIR=$PKGDIR/Cantera/root_dir/Applications/Cantera -PYDIR=$PKGDIR/Cantera/root_dir/Library/Python -instdir=@ct_dir@ +CTDIR=$PKGDIR/Cantera/root_dir/Applications/Cantera +PYDIR=$PKGDIR/Cantera/root_dir/Library/Python/$PYVERSION +RESDIR=$PKGDIR/Cantera/resources_dir + +# where Cantera has been installed +instdir=/Applications/Cantera +pylibdir=/Library/Python/$PYVERSION $INSTALL -d $CTDIR -$INSTALL -d $PYDIR -$INSTALL -d $PKGDIR/Cantera/resources_dir +$INSTALL -d $PYDIR/Cantera +$INSTALL -d $PYDIR/MixMaster +$INSTALL -d $RESDIR -cp -r -f $instdir/* $CTDIR -cp -r -f /Library/Python/2.3 $PYDIR +cp -R -f $instdir/* $CTDIR +chmod +x $CTDIR/bin/* + +cp -R -f $pylibdir/Cantera/* $PYDIR/Cantera +cp -R -f $pylibdir/MixMaster/* $PYDIR/MixMaster +cp -f $pylibdir/ctml_writer.py $PYDIR +cp -f ~/setup_cantera $CTDIR + +cp -f /Users/dgg/dv/sf/cantera/License.txt $RESDIR -cp -f @ctroot@/License.* $PKGDIR/Cantera/resources_dir -chown -R $USER $PKGDIR \ No newline at end of file