diff --git a/CMakeLists.txt b/CMakeLists.txt index 2844f7752..ff25e5e86 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -3,6 +3,7 @@ PROJECT (Cantera) #---------------------------- # user-configurable settings #---------------------------- + INCLUDE (config.cmake) @@ -25,6 +26,7 @@ CONFIGURE_FILE ( ${PROJECT_BINARY_DIR}/config.h ) INCLUDE_DIRECTORIES (${PROJECT_BINARY_DIR}) +INCLUDE_DIRECTORIES (${PROJECT_BINARY_DIR}/build/include/cantera) SET (LIBRARY_OUTPUT_PATH ${PROJECT_BINARY_DIR}/build/lib/${CMAKE_SYSTEM_PROCESSOR}-${CMAKE_SYSTEM_VERSION} CACHE PATH "Single directory for all libraries" @@ -39,6 +41,10 @@ MARK_AS_ADVANCED ( EXECUTABLE_OUTPUT_PATH ) +ADD_SUBDIRECTORY (ext) ADD_SUBDIRECTORY (Cantera) +SET ( CANTERA_INCLUDE_DIR ${PROJECT_SOURCE_DIR}/Cantera/cxx/include ) +SET(CMAKE_INSTALL_PREFIX /Applications/Cantera/include ) +INSTALL_FILES ( /cantera .h ${CANTERA_CXX_HEADERS} ) diff --git a/Cantera/CMakeLists.txt b/Cantera/CMakeLists.txt index 2b9fed7f8..7e910ca1d 100644 --- a/Cantera/CMakeLists.txt +++ b/Cantera/CMakeLists.txt @@ -1,5 +1,6 @@ add_subdirectory(src) -#add_subdirectory(clib) +add_subdirectory(clib) +# add_subdirectory(python) #add_subdirectory(fortran) diff --git a/Cantera/clib/CMakeLists.txt b/Cantera/clib/CMakeLists.txt new file mode 100644 index 000000000..febd4f0ab --- /dev/null +++ b/Cantera/clib/CMakeLists.txt @@ -0,0 +1 @@ +add_subdirectory(src) diff --git a/Cantera/clib/src/CMakeLists.txt b/Cantera/clib/src/CMakeLists.txt new file mode 100644 index 000000000..b8b2391c1 --- /dev/null +++ b/Cantera/clib/src/CMakeLists.txt @@ -0,0 +1,25 @@ +SET (CLIB_SRCS ct.cpp Storage.cpp ctsurf.cpp ctrpath.cpp ctreactor.cpp + ctfunc.cpp ctxml.cpp ctonedim.cpp ctmultiphase.cpp ) + +INCLUDE_DIRECTORIES (${PROJECT_SOURCE_DIR}/Cantera/src/base) +INCLUDE_DIRECTORIES (${PROJECT_SOURCE_DIR}/Cantera/src/thermo) +INCLUDE_DIRECTORIES (${PROJECT_SOURCE_DIR}/Cantera/src/equil) +INCLUDE_DIRECTORIES (${PROJECT_SOURCE_DIR}/Cantera/src/numerics) +INCLUDE_DIRECTORIES (${PROJECT_SOURCE_DIR}/Cantera/src/kinetics) +INCLUDE_DIRECTORIES (${PROJECT_SOURCE_DIR}/Cantera/src/transport) +INCLUDE_DIRECTORIES (${PROJECT_SOURCE_DIR}/Cantera/src/converters) +INCLUDE_DIRECTORIES (${PROJECT_SOURCE_DIR}/Cantera/src/zeroD) +INCLUDE_DIRECTORIES (${PROJECT_SOURCE_DIR}/Cantera/src/oneD) + +SET (LIBRARY_OUTPUT_PATH + ${PROJECT_BINARY_DIR}/build/lib/${CMAKE_SYSTEM_PROCESSOR}-${CMAKE_SYSTEM_VERSION} CACHE PATH "Single directory for all libraries" + ) + +ADD_LIBRARY(clib ${CLIB_SRCS}) + +SET (CLIB_H ct.h Storage.h ctsurf.h ctrpath.h ctreactor.h + ctfunc.h ctxml.h ctonedim.h ctmultiphase.h ) + +TARGET_LINK_LIBRARIES (clib oneD zeroD equil kinetics thermo ctbase) + +# @phase_header_files@) diff --git a/Cantera/clib/src/ct.cpp b/Cantera/clib/src/ct.cpp index d11df16d5..5c40c4154 100755 --- a/Cantera/clib/src/ct.cpp +++ b/Cantera/clib/src/ct.cpp @@ -557,7 +557,7 @@ extern "C" { thermo_t* thrm = th(n); int nsp = thrm->nSpecies(); if (lenm >= nsp) { - thrm->getEnthalpy_RT(h_rt); + thrm->getEnthalpy_RT_ref(h_rt); return 0; } else @@ -571,7 +571,7 @@ extern "C" { thermo_t* thrm = th(n); int nsp = thrm->nSpecies(); if (lenm >= nsp) { - thrm->getEntropy_R(s_r); + thrm->getEntropy_R_ref(s_r); return 0; } else @@ -585,10 +585,10 @@ extern "C" { thermo_t* thrm = th(n); int nsp = thrm->nSpecies(); if (lenm >= nsp) { - thrm->getCp_R(cp_r); + thrm->getCp_R_ref(cp_r); return 0; } - else + else return -10; } catch (CanteraError) {return -1;} diff --git a/Cantera/cmake_install.cmake b/Cantera/cmake_install.cmake new file mode 100644 index 000000000..d49115f71 --- /dev/null +++ b/Cantera/cmake_install.cmake @@ -0,0 +1,35 @@ +# Install script for directory: /Users/dgg/dv/sf/cantera/Cantera + +# Set the install prefix +IF(NOT DEFINED CMAKE_INSTALL_PREFIX) + SET(CMAKE_INSTALL_PREFIX "/Applications/Cantera") +ENDIF(NOT DEFINED CMAKE_INSTALL_PREFIX) +STRING(REGEX REPLACE "/$" "" CMAKE_INSTALL_PREFIX "${CMAKE_INSTALL_PREFIX}") + +# Set the install configuration name. +IF(NOT CMAKE_INSTALL_CONFIG_NAME) + IF(BUILD_TYPE) + STRING(REGEX REPLACE "^[^A-Za-z0-9_]+" "" + CMAKE_INSTALL_CONFIG_NAME "${BUILD_TYPE}") + ELSE(BUILD_TYPE) + SET(CMAKE_INSTALL_CONFIG_NAME "Release") + ENDIF(BUILD_TYPE) + MESSAGE(STATUS "Install configuration: \"${CMAKE_INSTALL_CONFIG_NAME}\"") +ENDIF(NOT CMAKE_INSTALL_CONFIG_NAME) + +# Set the component getting installed. +IF(NOT CMAKE_INSTALL_COMPONENT) + IF(COMPONENT) + MESSAGE(STATUS "Install component: \"${COMPONENT}\"") + SET(CMAKE_INSTALL_COMPONENT "${COMPONENT}") + ELSE(COMPONENT) + SET(CMAKE_INSTALL_COMPONENT) + ENDIF(COMPONENT) +ENDIF(NOT CMAKE_INSTALL_COMPONENT) + +IF(NOT CMAKE_INSTALL_LOCAL_ONLY) + # Include the install script for each subdirectory. + INCLUDE("/Users/dgg/dv/sf/cantera/Cantera/src/cmake_install.cmake") + INCLUDE("/Users/dgg/dv/sf/cantera/Cantera/clib/cmake_install.cmake") + +ENDIF(NOT CMAKE_INSTALL_LOCAL_ONLY) diff --git a/Cantera/cxx/demos/flamespeed.cpp b/Cantera/cxx/demos/flamespeed.cpp index 3f723b841..e11299f2d 100644 --- a/Cantera/cxx/demos/flamespeed.cpp +++ b/Cantera/cxx/demos/flamespeed.cpp @@ -18,221 +18,221 @@ using namespace Cantera; int flamespeed(int np, void* p) { - try { - int i; - IdealGasMix gas("gri30.cti","gri30_mix"); - - doublereal temp = 300.0; // K - doublereal pressure = 1.0*OneAtm; //atm - doublereal uin=0.3; //m/sec - - gas.setState_TPX(temp, pressure, "CH4:1.0, O2:2.0, N2:7.52"); - int nsp = gas.nSpecies(); - - vector_fp x; - x.resize(nsp); - - double phi = 0.0; - if (np > 0) phi = *(double*)(p); - if (phi == 0.0) { - cout << "Enter phi: "; - cin >> phi; - } - - doublereal C_atoms=1.0; - doublereal H_atoms=4.0; - doublereal ax=C_atoms+H_atoms/4.0; - doublereal fa_stoic=1.0/(4.76*ax); - for(int k=0;k 0) phi = *(double*)(p); + if (phi == 0.0) { + cout << "Enter phi: "; + cin >> phi; + } + + doublereal C_atoms=1.0; + doublereal H_atoms=4.0; + doublereal ax=C_atoms+H_atoms/4.0; + doublereal fa_stoic=1.0/(4.76*ax); + for(int k=0;k domains; + domains.push_back(&inlet); + domains.push_back(&flow); + domains.push_back(&outlet); + + // OneDim flamesim(domains); + + Sim1D flame(domains); + + //----------- Supply initial guess---------------------- + + vector_fp locs; + vector_fp value; + + locs.resize(3); + value.resize(3); + + //ramp values from inlet to adiabatic flame conditions + // over 70% of domain and then level off at equilibrium + double z1=0.7; + + double uout; + uout=inlet.mdot()/rho_out; + uin=inlet.mdot()/rho_in; + locs[0]=0.0; locs[1]=z1; locs[2]=1.0; + value[0]=uin; value[1]=uout; value[2]=uout; + flame.setInitialGuess("u",locs,value); + + value[0]=temp; value[1]=Tad; value[2]=Tad; + flame.setInitialGuess("T",locs,value); + + for(i=0;i zvec,Tvec,COvec,CO2vec,Uvec; + + printf("\n%9s\t%8s\t%5s\t%7s\n","z (m)", "T (K)", "U (m/s)", "Y(CO)"); + for(int n=0;n domains; - domains.push_back(&inlet); - domains.push_back(&flow); - domains.push_back(&outlet); - - // OneDim flamesim(domains); - - Sim1D flame(domains); - - //----------- Supply initial guess---------------------- - - vector_fp locs; - vector_fp value; - - locs.resize(3); - value.resize(3); - - //ramp values from inlet to adiabatic flame conditions - // over 70% of domain and then level off at equilibrium - double z1=0.7; - - double uout; - uout=inlet.mdot()/rho_out; - uin=inlet.mdot()/rho_in; - locs[0]=0.0; locs[1]=z1; locs[2]=1.0; - value[0]=uin; value[1]=uout; value[2]=uout; - flame.setInitialGuess("u",locs,value); - - value[0]=temp; value[1]=Tad; value[2]=Tad; - flame.setInitialGuess("T",locs,value); - - for(i=0;i zvec,Tvec,COvec,CO2vec,Uvec; - - printf("\n%9s\t%8s\t%5s\t%7s\n","z (m)", "T (K)", "U (m/s)", "Y(CO)"); - for(int n=0;n>> f1 = Polynomial([1.0, 0.0, 3.0]) # 3*t*t + 1 @@ -147,7 +147,7 @@ class Func1: def write(self, arg = 'x', length = 1000): return _cantera.func_write(self._func_id, length, arg) - + class Sin(Func1): def __init__(self,omega=1.0): @@ -249,6 +249,15 @@ class Fourier(Func1): Func1.__init__(self, 1, n-1, ravel(transpose(cc))) +##Sum of modified Arrhenius terms. Instances of class 'Arrhenius' evaluate +# \f[ +# f(T) = \sum_{n=1}^N A_n T^{b_n}\exp(-E_n/T) +# \f] +# +# Example: +# +# >>> f = Arrhenius([(a0, b0, e0), (a1, b1, e1)]) +# class Arrhenius(Func1): """Sum of modified Arrhenius terms. Instances of class 'Arrhenius' evaluate \f[ @@ -306,6 +315,11 @@ class PeriodicFunction(Func1): # functions that combine two functions class ComboFunc1(Func1): + """ + Combines two functions. + This class is the base class for functors that combine two + other functors in a binary operation. + """ def __init__(self, typ, f1, f2): self._own = 1 @@ -407,19 +421,21 @@ class RatioFunction(ComboFunc1): """ ComboFunc1.__init__(self, 40, f1, f2) +## Function of a function. +# Instances of class CompositeFunction evaluate f(g(t)) for two supplied +# functors f and g. It is not necessary to explicitly create an instance +# of 'CompositeFunction', since the () operator of the base class is +# overloaded to return a CompositeFunction when called with a functor +# argument. +# @example +# >>> f1 = Polynomial([2.0, 1.0]) +# >>> f2 = Polynomial([3.0, -5.0]) +# >>> f3 = f1(f2) # functor to evaluate 2(3t - 5) + 1 +# In this example, object 'f3' is a functor of class'CompositeFunction' +# that calls f1 and f2 and returns f1(f2(t)). + class CompositeFunction(ComboFunc1): - """Function of a function. - Instances of class CompositeFunction evaluate f(g(t)) for two supplied - functors f and g. It is not necessary to explicitly create an instance - of 'CompositeFunction', since the () operator of the base class is - overloaded to return a CompositeFunction when called with a functor - argument. - >>> f1 = Polynomial([2.0, 1.0]) - >>> f2 = Polynomial([3.0, -5.0]) - >>> f3 = f1(f2) # functor to evaluate 2(3t - 5) + 1 - In this example, object 'f3' is a functor of class'CompositeFunction' - that calls f1 and f2 and returns f1(f2(t)). - """ + def __init__(self, f1, f2): """ f1 - first functor. @@ -427,6 +443,7 @@ class CompositeFunction(ComboFunc1): f2 - second functor. """ ComboFunc1.__init__(self, 60, f1, f2) + class DerivativeFunction(Func1): def __init__(self, f): @@ -435,9 +452,11 @@ class DerivativeFunction(Func1): self._own = 1 self._func_id = _cantera.func_derivative(f.func_id()) +## +# The derivative of f +# def derivative(f): return DerivativeFunction(f) - diff --git a/Cantera/python/Cantera/Kinetics.py b/Cantera/python/Cantera/Kinetics.py index 3ab2897be..eaee178e5 100755 --- a/Cantera/python/Cantera/Kinetics.py +++ b/Cantera/python/Cantera/Kinetics.py @@ -28,13 +28,11 @@ class Kinetics: the specification of the parameters. """ np = len(phases) - #self._np = np self._sp = [] self._phnum = {} # p0 through p4 are the integer indices of the phase objects # corresponding to the input sequence of phases - self._end = [0] p0 = phases[0].thermophase() p1 = -1 diff --git a/Cantera/python/Cantera/SurfWriter.py b/Cantera/python/Cantera/SurfWriter.py deleted file mode 100755 index f6f458d29..000000000 --- a/Cantera/python/Cantera/SurfWriter.py +++ /dev/null @@ -1,180 +0,0 @@ -""" -Write C functions implementing a surface reaction mechanism. -NOT CURRENTLY FUNCTIONAL -""" - -from Cantera import CanteraError -from Cantera import units -from Numeric import array -from Cantera import constants -import math -import types - -hdr = """ -/* - -The identity of the species in each phase is as listed below. -""" - -ropheader = """ - - /* - Get the reaction rates of progress given the concentrations. - - conc --- concentrations in kmol/m^3 or kmol/m^2. Array c - must be dimensioned at least KB1 + KB2 + KS. The first - KB1 entries are the concentrations of species in bulk phase 1, - the next KB2 entries are the concentrations of species in bulk - phase 2, and the final KS entries are the concentrations of the - surface species. - - ropf --- rates of progress of the surface reactions in kmol/m^2/s. - Must be dimensioned at least NSR, the number of surface reactions. - - */ - - void get_rop(double* c, double* kf, double* ropf) { -""" - -sdotheader = """ - - void get_sdot(double* r, double* sdot) { -""" - -rateheader = """ - - /* get the forward reaction rates */ - void get_kf(double T, double* kf) { - double logT = log(T); - double rt = 1.0/T; -""" - -finaltxt = """ - } - """ - -class SurfWriter: - - def __init__(self, iface, mechname): - self.bulk1 = iface.p1 - self.bulk2 = iface.p2 - self.surf = iface - self.sp = {} - self.f = open(mechname+'.c', 'w') - self.write_top() - self.f.write('\n#ifdef __cplusplus\nextern "C" {\n#endif') - self.rop = ropheader - self.rate = rateheader - self.nrxns = 0 - self.sdot = {} - - def write(self): - self.f.write(self.rop) - self.f.write(' }\n\n') - self.f.write(sdotheader) - for k in self.sdot.keys(): - self.f.write('\n /* '+self.sp[k]+' */\n') - self.f.write(' sdot['+`k`+'] = '+self.sdot[k]+';\n') - self.f.write(' }\n\n') - self.f.write(self.rate) - self.f.write(' }\n') - self.f.write('#ifdef __cplusplus\n}\n#endif\n') - self.f.close() - - def write_top(self): - self.f.write(hdr) - n1 = self.bulk1.nSpecies() - self.f.write('Bulk phase 1 species: '+`n1`+' total.\n') - - sp = self.bulk1.speciesNames() - i = 0 - k = 0 - for s in sp: - self.f.write('%3d %s\n' % (i, s)) - i += 1 - self.sp[k] = s - k += 1 - self.f.write('\n\n') - - if self.bulk2: - n2 = self.bulk2.nSpecies() - self.f.write('Bulk phase 2 species: '+`n2`+' total.\n') - - sp = self.bulk2.speciesNames() - i = 0 - for s in sp: - self.f.write('%3d %s\n' % (i, s)) - i += 1 - self.sp[k] = s - k += 1 - self.f.write('\n\n') - - else: - self.f.write('No second bulk phase.\n\n') - - ns = self.surf.nSpecies() - self.f.write('Surface species: '+`ns`+' total.\n') - sp = self.surf.speciesNames() - i = 0 - for s in sp: - self.f.write('%3d %s\n' % (i, s)) - i += 1 - self.sp[k] = s - k += 1 - self.f.write('\n\n*/') - - self.f.write('\n\n') - - - def write_update_rate(self, rate): - i = self.nrxns - self.rate += ' kf['+`i`+'] = '+'%17.10e' % (rate[0],) - if rate[1] == 0.0 and rate[2] == 0.0: - self.rate += ';\n' - return - self.rate += ' * exp(' - if rate[1] <> 0.0: - self.rate += '%f * logT' % (rate[1],) - if rate[2] <> 0.0: - self.rate += '- %f * rt' % (rate[2],) - self.rate += ');\n' - - - def write_ROP(self, rindex, rstoich, rorder, - pindex, pstoich, rate): - f = '' - i = self.nrxns - f += ' ropf['+`i`+'] = kf['+`i`+']*' - nr = len(rindex) - for n in range(nr): - k = rindex[n] - if rorder[n] == rstoich[n]: - for j in range(rstoich[n]): - f +='c['+`k`+']*' - else: - f += 'pow(c['+`k`+'], '+`rorder[n]`+')*' - f = f[:-1]+';\n' - self.rop += f - - def write_sdot(self, rindex, rstoich, pindex, pstoich): - i = self.nrxns - nr = len(rindex) - for n in range(nr): - k = rindex[n] - if rstoich[n] == 1: st = '' - else: st = `rstoich[n]`+'*' - if not self.sdot.has_key(k): - self.sdot[k] = ' -'+st+'r['+`i`+']' - else: - self.sdot[k] += ' - '+st+'r['+`i`+']' - - np = len(pindex) - for n in range(np): - k = pindex[n] - if pstoich[n] == 1: st = '' - else: st = `pstoich[n]`+'*' - if not self.sdot.has_key(k): - self.sdot[k] = st+'r['+`i`+']' - else: - self.sdot[k] += ' + '+st+'r['+`i`+']' - diff --git a/Cantera/python/Cantera/ThermoPhase.py b/Cantera/python/Cantera/ThermoPhase.py index 5224ae88b..4d7dd79b6 100644 --- a/Cantera/python/Cantera/ThermoPhase.py +++ b/Cantera/python/Cantera/ThermoPhase.py @@ -1,11 +1,10 @@ -""" This module implements class ThermoPhase, a class representing -thermodynamic phases. """ - +""" + This module implements class ThermoPhase, a class representing + thermodynamic phases. +""" from Cantera.num import zeros - from Cantera.Phase import Phase - import _cantera import types @@ -13,7 +12,8 @@ def thermoIndex(id): return _cantera.thermo_thermoIndex(id) class ThermoPhase(Phase): - """ A phase with an equation of state. + """ + A phase with an equation of state. Class ThermoPhase may be used to represent the intensive thermodynamic state of a phase of matter, which might be a gas, @@ -23,10 +23,10 @@ class ThermoPhase(Phase): Class ThermoPhase is not usually instantiated directly. It is used as base class for classes Solution and Interface. - See: Solution, Interface + @see Solution, Interface """ - #used in the 'equilibrate' method + # used in the 'equilibrate' method _equilmap = {'TP':104,'TV':100,'HP':101,'SP':102,'SV':107,'UV':105, 'PT':104,'VT':100,'PH':101,'PS':102,'VS':107,'VU':105} @@ -46,8 +46,8 @@ class ThermoPhase(Phase): self.idtag = "" if index >= 0: - # create a Python wrapper for an existing kernel - # ThermoPhase instance + # create a Python wrapper for an existing kernel + # ThermoPhase instance self._phase_id = index elif xml_phase: @@ -67,9 +67,14 @@ class ThermoPhase(Phase): _cantera.thermo_delete(self._phase_id) def name(self): + """The name assigned to the phase. The default value is the name + attribute from the CTI file. But method setName can be used to + set the name to anything desired, e.g. 'gas at inlet' or 'exhaust' + """ return self.idtag def setName(self, name): + """ Set the name attribute. This can be any string""" self.idtag = name def refPressure(self): @@ -157,14 +162,14 @@ class ThermoPhase(Phase): return self.selectElements(lamb, elements) def enthalpies_RT(self, species = []): - """Pure species non-dimensional enthalpies. + """Pure species non-dimensional reference state enthalpies. This method returns an array containing the pure-species standard-state enthalpies divided by RT. For gaseous species, these values are ideal gas enthalpies.""" hrt = _cantera.thermo_getarray(self._phase_id,23) return self.selectSpecies(hrt, species) - + def entropies_R(self, species = []): """Pure species non-dimensional entropies. @@ -278,40 +283,39 @@ class ThermoPhase(Phase): def equilibrate(self, XY, solver = -1, rtol = 1.0e-9, maxsteps = 1000, maxiter = 100, loglevel = 0): - """Set to a state of chemical equilibrium holding property pair - 'XY' constant. - - XY -- A two-letter string, which must be one of the set - ['TP','TV','HP','SP','SV','UV','PT','VT','PH','PS','VS','VU']. - If H, U, S, or V is specified, the value must be the specific - value (per unit mass). - - solver -- specifies the equilibrium solver to use. If solver = - 0, a fast solver using the element potential method will be - used. If solver > 0, a slower but more robust Gibbs - minimization solver will be used. If solver < 0 or - unspecified, the fast solver will be tried first, then if it - fails the other will be tried. - - rtol -- the relative error tolerance. - - maxsteps -- maximum number of steps in composition to take to - find a converged solution. - - maxiter -- for the Gibbs minimization solver only, this - specifies the number of 'outer' iterations on T or P when some - property pair other than TP is specified. - - loglevel -- set to a value > 0 to write diagnostic output to a - file in HTML format. Larger values generate more detailed - information. The file will be named 'equilibrate_log.html.' - Subsequent files will be named 'equillibrate_log1.html', etc., - so that log files are not overwritten. - - """ + """ Set to a state of chemical equilibrium holding property pair + 'XY' constant. + + XY --- A two-letter string, which must be one of the set + ['TP','TV','HP','SP','SV','UV','PT','VT','PH','PS','VS','VU']. + If H, U, S, or V is specified, the value must be the specific + value (per unit mass) + + solver --- Specifies the equilibrium solver to use. If solver = + 0, a fast solver using the element potential method will be + used. If solver > 0, a slower but more robust Gibbs + minimization solver will be used. If solver < 0 or + unspecified, the fast solver will be tried first, then if it + fails the other will be tried. + + rtol -- the relative error tolerance. + + maxsteps -- maximum number of steps in composition to take to + find a converged solution. + + maxiter -- for the Gibbs minimization solver only, this + specifies the number of 'outer' iterations on T or P when some + property pair other than TP is specified. + + loglevel -- set to a value > 0 to write diagnostic output to a + file in HTML format. Larger values generate more detailed + information. The file will be named 'equilibrate_log.html.' + Subsequent files will be named 'equillibrate_log1.html', etc., + so that log files are not overwritten. + + """ _cantera.thermo_equil(self._phase_id, XY, solver, rtol, maxsteps, maxiter, loglevel) - def saveState(self): """Return an array with state information that can later be diff --git a/Cantera/python/Cantera/Transport.py b/Cantera/python/Cantera/Transport.py index 1fc70ee8c..6c74f2564 100755 --- a/Cantera/python/Cantera/Transport.py +++ b/Cantera/python/Cantera/Transport.py @@ -139,6 +139,11 @@ class Transport: return _cantera.tran_binaryDiffCoeffs(self.__tr_id, self.trnsp) + def diffusionCoeffs(self): + """Species diffusion coefficients. (m^2/s).""" + return self.mixDiffCoeffs() + + def mixDiffCoeffs(self): """Mixture-averaged diffusion coefficients.""" return _cantera.tran_mixDiffCoeffs(self.__tr_id, diff --git a/Cantera/python/Cantera/__init__.py b/Cantera/python/Cantera/__init__.py index 055b03a3e..1f05f195a 100755 --- a/Cantera/python/Cantera/__init__.py +++ b/Cantera/python/Cantera/__init__.py @@ -5,6 +5,7 @@ import types import _cantera +from num import * from constants import * from exceptions import * from gases import * diff --git a/Cantera/python/examples/equilibrium/simple.py b/Cantera/python/examples/equilibrium/simple.py index 930322db5..ea188e11f 100644 --- a/Cantera/python/examples/equilibrium/simple.py +++ b/Cantera/python/examples/equilibrium/simple.py @@ -1,4 +1,4 @@ -# homogeneous equilibrium of a gas +# homogeneous equilibrium of a gas. from Cantera import * diff --git a/Cantera/src/CMakeLists.txt b/Cantera/src/CMakeLists.txt index 001d48299..445f3283a 100644 --- a/Cantera/src/CMakeLists.txt +++ b/Cantera/src/CMakeLists.txt @@ -1,4 +1,10 @@ add_subdirectory(base) add_subdirectory(thermo) +add_subdirectory(numerics) +add_subdirectory(kinetics) +add_subdirectory(transport) +add_subdirectory(equil) +add_subdirectory(spectra) +add_subdirectory(oneD) diff --git a/Cantera/src/kinetics/ReactionPath.cpp b/Cantera/src/kinetics/ReactionPath.cpp index 28fcc9eda..af42f38a2 100755 --- a/Cantera/src/kinetics/ReactionPath.cpp +++ b/Cantera/src/kinetics/ReactionPath.cpp @@ -101,7 +101,7 @@ namespace Cantera { normal_color = "steelblue"; dashed_color = "gray"; dot_options = "center=1;"; - m_font = RXNPATH_FONT; + m_font = "Helvetica"; // RXNPATH_FONT; bold_min = 0.2; dashed_max = 0.0; label_min = 0.0; diff --git a/Cantera/src/numerics/DenseMatrix.h b/Cantera/src/numerics/DenseMatrix.h index bb335ab9e..613bb948b 100755 --- a/Cantera/src/numerics/DenseMatrix.h +++ b/Cantera/src/numerics/DenseMatrix.h @@ -17,10 +17,6 @@ #ifndef CT_DENSEMATRIX_H #define CT_DENSEMATRIX_H -//#include -//#include -//using namespace std; - #include "ct_defs.h" #include "Array.h" diff --git a/Cantera/src/numerics/ctlapack.h b/Cantera/src/numerics/ctlapack.h index 436fdb9c0..0b5a6da3a 100755 --- a/Cantera/src/numerics/ctlapack.h +++ b/Cantera/src/numerics/ctlapack.h @@ -63,9 +63,6 @@ const CBLAS_ORDER cblasOrder[2] = { CblasRowMajor, CblasColMajor }; const CBLAS_TRANSPOSE cblasTrans[2] = { CblasNoTrans, CblasTrans }; #endif -//#ifdef DARWIN -//#include -//#else // C interfaces for Fortran Lapack routines extern "C" { diff --git a/Cantera/src/thermo/CMakeLists.txt b/Cantera/src/thermo/CMakeLists.txt index f5e967b08..94806e5af 100644 --- a/Cantera/src/thermo/CMakeLists.txt +++ b/Cantera/src/thermo/CMakeLists.txt @@ -6,7 +6,8 @@ SET (THERMO_SRCS State.cpp Elements.cpp Constituents.cpp Phase.cpp ThermoFactory.cpp phasereport.cpp SemiconductorPhase.cpp StoichSubstance.cpp PureFluidPhase.cpp LatticeSolidPhase.cpp LatticePhase.cpp) -SET(CMAKE_CXX_FLAGS -I/${PROJECT_SOURCE_DIR}/Cantera/src/base) + +INCLUDE_DIRECTORIES (${PROJECT_SOURCE_DIR}/Cantera/src/base) SET (LIBRARY_OUTPUT_PATH ${PROJECT_BINARY_DIR}/build/lib/${CMAKE_SYSTEM_PROCESSOR}-${CMAKE_SYSTEM_VERSION} CACHE PATH "Single directory for all libraries" diff --git a/Cantera/src/thermo/State.h b/Cantera/src/thermo/State.h index bed14057c..4b8e100a8 100755 --- a/Cantera/src/thermo/State.h +++ b/Cantera/src/thermo/State.h @@ -1,8 +1,8 @@ /** - * @file State.h - * Header for the class State, that manages the independent variables of temperature, mass density, - * and species mass/mole fraction that define the thermodynamic state (see \ref phases and - * class \link Cantera::State State\endlink). + * @file State.h Header for the class State, that manages the + * independent variables of temperature, mass density, and species + * mass/mole fraction that define the thermodynamic state (see \ref + * phases and class \link Cantera::State State\endlink). */ /* diff --git a/Cantera/src/transport/SolidTransport.cpp b/Cantera/src/transport/SolidTransport.cpp index 73ccb1f9e..b4b6982c6 100644 --- a/Cantera/src/transport/SolidTransport.cpp +++ b/Cantera/src/transport/SolidTransport.cpp @@ -8,7 +8,7 @@ * $Date$ */ -// copyright 2003 California Institute of Technology +// copyright 2008 California Institute of Technology // turn off warnings under Windows @@ -27,16 +27,14 @@ using namespace std; namespace Cantera { - //////////////////// class SolidTransport methods ////////////// - SolidTransport::SolidTransport() {} void SolidTransport::setParameters(int n, int k, double* p) { switch (n) { - + + case 0: // set the Arrhenius parameters for the diffusion coefficient // of species k. - case 0: m_sp.push_back(k); m_Adiff.push_back(p[0]); m_Ndiff.push_back(p[1]); @@ -44,23 +42,19 @@ namespace Cantera { m_nmobile = m_sp.size(); break; - // set the thermal conductivity. case 1: - m_lam = p[0]; + // set the thermal conductivity Arrhenius parameters. + m_Alam = p[0]; + m_Nlam = p[2]; + m_Elam = p[2]; break; + default: ; } } - /********************************************************* - * - * Public methods - * - *********************************************************/ - - /** * Compute the mobilities of the species from the diffusion coefficients, * using the Einstein relation. @@ -76,9 +70,14 @@ namespace Cantera { } } - + /** + * Thermal Conductivity. + * \f[ + * \lambda = A T^n \exp(-E/RT) + */ doublereal SolidTransport::thermalConductivity() { - return m_lam; + doublereal t = m_thermo->temperature(); + return m_Alam *pow(t, m_Nlam) * exp(-m_Elam/t); } diff --git a/Cantera/src/transport/SolidTransport.h b/Cantera/src/transport/SolidTransport.h index c793c4e70..9d913d06d 100644 --- a/Cantera/src/transport/SolidTransport.h +++ b/Cantera/src/transport/SolidTransport.h @@ -68,7 +68,9 @@ namespace Cantera { vector_fp m_Ndiff; vector_fp m_Ediff; vector_int m_sp; - doublereal m_lam; + doublereal m_Alam; + doublereal m_Nlam; + doublereal m_Elam; }; } #endif diff --git a/config.cmake b/config.cmake index 0cecccae2..3059dd970 100755 --- a/config.cmake +++ b/config.cmake @@ -1,77 +1,12 @@ - -# WORK IN PROGRESS -# This configuration file is not yet functional; use the "preconfig" -# script instead. - - -####################################################################### -# -# Cantera Configuration File -# -# Edit this file to control how Cantera is built. Parameters can be set -# here, or alternatively environment variables may be set before calling -# this script. -# -# The default configuration uses GNU compilers (gcc/g++/g77) and -# builds as much of Cantera and its language interfaces as it can -# (e.g. if MATLAB is installed on your system, the MATLAB toolbox -# will be built automatically, otherwise it will be skipped. On linux -# or Mac OS X, this default configuration should work, and most -# likely you don't need to edit this file at all - just run it. -# -# NOTE: if you DO make changes to this file, save it with another name -# so that it will not be overwritten if you update the source -# distribution. - -####################################################################### - -#---------------------------------------------------------------------- -# Language Interfaces -#---------------------------------------------------------------------- -# -# Cantera has several programming language interfaces. Select the ones -# you want to build. The default is to try to build all language -# interfaces. -# -# -#----------------- Python -------------------------------------------- -# -# In addition to being one of the supported language interfaces, -# Python is used internally by Cantera, both in the build process and -# at run time (to process .cti input files). Therefore, you generally -# need to have Python on your system; if you don't, first install it -# from http://www.python.org before proceeding with the installation -# of Cantera. -# -# If you plan to work in Python, or you want to use the graphical -# MixMaster application, then you need the full Cantera Python -# Package. If, on the other hand, you will only use Cantera from some -# other language (e.g. MATLAB or Fortran 90/95) and only need Python -# to process .cti files, then you only need a minimal subset of the -# package (actually, only one file). - OPTION(CANTERA_BUILD_FULL_PYTHON "Include support for using Cantera from Python?" ON) -OPTION(CANTERA_BUILD_MIN_PYTHON "Include support for using CTI input files?" ON) -MARK_AS_ADVANCED ( - CANTERA_BUILD_FULL_PYTHON - CANTERA_BUILD_MIN_PYTHON - ) +OPTION(CANTERA_BUILD_WITH_F2C "Use f2c versions of 3rd party numerical routines" ON) -# Cantera needs to know where to find the Python interpreter. If -# PYTHON_CMD is set to "default", then cmake will look for the Python -# interpreter -SET( PYTHON_CMD "default") +OPTION (CANTERA_BUILD_LAPACK 0) +OPTION (CANTERA_HAVE_SUNDIALS 1) -# The Cantera Python interface can be built with either the numarray -# or Numeric packages. Set this to "y" to use Numeric, or anything -# else to use numarray. Using numarray is preferred. -SET( USE_NUMERIC "default") - -# If numarray was installed using the --home option, set this to the -# home directory for numarray. -# SET( NUMARRAY_HOME "$HOME/python_packages") +SET( PYTHON_CMD ${PYTHON_EXE}) SET( CANTERA_VERSION "1.7.1") diff --git a/ext/CMakeLists.txt b/ext/CMakeLists.txt new file mode 100644 index 000000000..9947073bd --- /dev/null +++ b/ext/CMakeLists.txt @@ -0,0 +1,7 @@ +SET (CMAKE_C_FLAGS -DSkip_f2c_Undefs) +add_subdirectory( f2c_libs) +add_subdirectory( f2c_blas) +add_subdirectory (f2c_lapack) +add_subdirectory ( tpx ) + + diff --git a/ext/Makefile.in b/ext/Makefile.in index 411907d55..86829e112 100755 --- a/ext/Makefile.in +++ b/ext/Makefile.in @@ -1,4 +1,4 @@ -#/bin/sh +)))))))#/bin/sh # # $Source$ # $Author$ diff --git a/ext/f2c_blas/CMakeLists.txt b/ext/f2c_blas/CMakeLists.txt new file mode 100644 index 000000000..dca4e569e --- /dev/null +++ b/ext/f2c_blas/CMakeLists.txt @@ -0,0 +1,10 @@ +SET (F2C_BLAS_SRCS dasum.c daxpy.c dcabs1.c dcopy.c ddot.c +dgbmv.c dgemm.c dgemv.c dger.c dnrm2.c drot.c drotg.c +drotm.c drotmg.c dsbmv.c dscal.c dsdot.c dspmv.c dspr.c dspr2.c +dswap.c dsymm.c dsymv.c dsyr.c dsyr2.c dsyr2k.c dsyrk.c dtbmv.c +dtbsv.c dtpmv.c dtpsv.c dtrmm.c dtrmv.c dtrsm.c dtrsv.c +dzasum.c dznrm2.c idamax.c lsame.c xerbla.c ) + +ADD_LIBRARY(ctblas ${F2C_BLAS_SRCS}) + + diff --git a/ext/f2c_lapack/CMakeLists.txt b/ext/f2c_lapack/CMakeLists.txt new file mode 100644 index 000000000..d6febc9c4 --- /dev/null +++ b/ext/f2c_lapack/CMakeLists.txt @@ -0,0 +1,14 @@ + +SET (F2C_LAPACK_SRCS dgbtrf.c dgbtrs.c dgbsv.c + dgebd2.c dgebrd.c dgelq2.c dgelqf.c dgelss.c dgeqr2.c dgeqrf.c dgetf2.c + dgetrf.c dgetri.c dgetrs.c dlabad.c dlabrd.c dlacpy.c dlamch.c dlange.c + dlapy2.c dlarf.c dlarfb.c dlarfg.c dlarft.c dlartg.c dlas2.c dlascl.c dlaset.c + dlasq1.c dlasq2.c dlasq3.c dlasq4.c dlasq5.c dlasq6.c dlasr.c dlasrt.c + dlassq.c dlasv2.c dlaswp.c dorg2r.c dorgbr.c dorgl2.c dorglq.c dorgqr.c + dorm2r.c dormbr.c dorml2.c dormlq.c dormqr.c drscl.c dtrtri.c + dtrti2.c ieeeck.c ilaenv.c ) + +ADD_LIBRARY(ctlapack ${F2C_LAPACK_SRCS}) + + + diff --git a/ext/f2c_libs/CMakeLists.txt b/ext/f2c_libs/CMakeLists.txt new file mode 100644 index 000000000..1a481d2f8 --- /dev/null +++ b/ext/f2c_libs/CMakeLists.txt @@ -0,0 +1,39 @@ +SET (F2C_LIB_SRCS f77vers.c i77vers.c main.c s_rnge.c abort_.c + exit_.c getarg_.c iargc_.c + getenv_.c signal_.c s_stop.c s_paus.c + system_.c cabs.c + derf_.c derfc_.c erf_.c erfc_.c sig_die.c uninit.c + pow_ci.c pow_dd.c pow_di.c pow_hh.c + pow_ii.c pow_ri.c pow_zi.c pow_zz.c + c_abs.c c_cos.c c_div.c c_exp.c c_log.c c_sin.c + c_sqrt.c + z_abs.c z_cos.c z_div.c z_exp.c z_log.c z_sin.c + z_sqrt.c + r_abs.c r_acos.c r_asin.c r_atan.c r_atn2.c + r_cnjg.c r_cos.c + r_cosh.c r_dim.c r_exp.c r_imag.c r_int.c + r_lg10.c r_log.c r_mod.c r_nint.c r_sign.c + r_sin.c r_sinh.c r_sqrt.c r_tan.c r_tanh.c + d_abs.c d_acos.c d_asin.c d_atan.c d_atn2.c + d_cnjg.c d_cos.c d_cosh.c d_dim.c d_exp.c + d_imag.c d_int.c d_lg10.c d_log.c d_mod.c + d_nint.c d_prod.c d_sign.c d_sin.c d_sinh.c + d_sqrt.c d_tan.c d_tanh.c i_abs.c i_dim.c + i_dnnt.c i_indx.c i_len.c i_mod.c i_nint.c i_sign.c + lbitbits.c lbitshft.c h_abs.c h_dim.c h_dnnt.c + h_indx.c h_len.c h_mod.c h_nint.c h_sign.c + l_ge.c l_gt.c l_le.c l_lt.c hl_ge.c hl_gt.c + hl_le.c hl_lt.c ef1asc_.c ef1cmc_.c + f77_aloc.c s_cat.c s_cmp.c s_copy.c + backspac.c close.c dfe.c dolio.c due.c + endfile.c err.c + fmt.c fmtlib.c ftell_.c iio.c ilnw.c + inquire.c lread.c lwrite.c + open.c rdfmt.c rewind.c rsfe.c rsli.c + rsne.c sfe.c sue.c + typesize.c uio.c util.c wref.c wrtfmt.c + wsfe.c wsle.c wsne.c xwsne.c + dtime_.c etime_.c) + +ADD_LIBRARY(ctf2c ${F2C_LIB_SRCS}) + diff --git a/ext/f2c_libs/Makefile.in b/ext/f2c_libs/Makefile.in index 4ae747a1e..bf8b6999a 100755 --- a/ext/f2c_libs/Makefile.in +++ b/ext/f2c_libs/Makefile.in @@ -180,7 +180,7 @@ util.o: fio.h wref.o: fio.h wref.o: fmt.h wref.o: fp.h -wrtfmt.o: fio.h + wrtfmt.o: fio.h wrtfmt.o: fmt.h wsfe.o: fio.h wsfe.o: fmt.h diff --git a/ext/f2c_libs/f2c.h0 b/ext/f2c_libs/f2c.h0 index 02751d051..dbfb57e4a 100644 --- a/ext/f2c_libs/f2c.h0 +++ b/ext/f2c_libs/f2c.h0 @@ -7,6 +7,7 @@ #ifndef F2C_INCLUDE #define F2C_INCLUDE +#define #ifdef _WIN32 #include /* for real isatty() */ /* diff --git a/ext/f2c_libs/pow_qq.c b/ext/f2c_libs/pow_qq.c index 09fe18ec8..ede60dbeb 100644 --- a/ext/f2c_libs/pow_qq.c +++ b/ext/f2c_libs/pow_qq.c @@ -1,13 +1,13 @@ #include "f2c.h" -#ifdef __cplusplus -extern "C" { -#endif +//#ifdef __cplusplus +//extern "C" { + //#endif -#ifdef KR_headers -longint pow_qq(ap, bp) longint *ap, *bp; -#else + //#ifdef KR_headers + //longint pow_qq(ap, bp) longint *ap, *bp; + //#else longint pow_qq(longint *ap, longint *bp) -#endif + //#endif { longint pow, x, n; unsigned long long u; /* system-dependent */ @@ -34,6 +34,6 @@ longint pow_qq(longint *ap, longint *bp) } return(pow); } -#ifdef __cplusplus -} -#endif + //#ifdef __cplusplus +//} +//#endif diff --git a/ext/f2c_math/CMakeLists.txt b/ext/f2c_math/CMakeLists.txt new file mode 100644 index 000000000..d2ad3d333 --- /dev/null +++ b/ext/f2c_math/CMakeLists.txt @@ -0,0 +1,10 @@ +SET ( CTMATH_SRCS mach.cpp ddaspk.c dgbefa.c dgbsl.c dgefa.c dgesl.c + dp1vlu.c dpcoef.c dpolft.c fdump.c j4save.c pcoef.c polfit.c pvalue.c + xercnt.c xerhlt.c xermsg.c xerprn.c xersve.c xgetua.c printstring.c) + +INCLUDE_DIRECTORIES ( ${PROJECT_BINARY_DIR} ) +INCLUDE_DIRECTORIES ( ${PROJECT_BINARY_DIR}/ext/f2c_libs ) +INCLUDE_DIRECTORIES ( ${PROJECT_BINARY_DIR}/build/include/cantera ) + +ADD_LIBRARY( ctmath ${CTMATH_SRCS} ) + diff --git a/ext/tpx/CMakeLists.txt b/ext/tpx/CMakeLists.txt new file mode 100644 index 000000000..ed9f405d9 --- /dev/null +++ b/ext/tpx/CMakeLists.txt @@ -0,0 +1,9 @@ +SET ( TPX_SRCS HFC134a.cpp Heptane.cpp Hydrogen.cpp Methane.cpp + Nitrogen.cpp Oxygen.cpp RedlichKwong.cpp CarbonDioxide.cpp + Sub.cpp Water.cpp utils.cpp lk.cpp ) + +INCLUDE_DIRECTORIES ( ${PROJECT_BINARY_DIR} ) +#IINCLUDE_DIRECTORIES ( ${PROJECT_BINARY_DIR}/build/include/cantera ) + +ADD_LIBRARY( tpx ${TPX_SRCS} ) + diff --git a/preconfig b/preconfig index ee32936c6..3d72ca115 100755 --- a/preconfig +++ b/preconfig @@ -75,7 +75,7 @@ PYTHON_CMD=${PYTHON_CMD:="default"} # The Cantera Python interface can be built with either the numarray # or Numeric packages. Set this to "y" to use Numeric, or anything # else to use numarray. Using numarray is preferred. -USE_NUMERIC=${USE_NUMERIC:="default"} +USE_NUMERIC=${USE_NUMERIC:="n"} # If numarray was installed using the --home option, set this to the # home directory for numarray.