*** empty log message ***

This commit is contained in:
Dave Goodwin 2003-04-17 08:59:07 +00:00
parent 603d216de4
commit fdbf250119
9 changed files with 363 additions and 247 deletions

View file

@ -177,7 +177,7 @@ namespace Cantera {
inline void equilibrate(thermo_t& s, int XY) {
ChemEquil e;
//try {
int istatus = e.equilibrate(s,XY);
e.equilibrate(s,XY);
//}
//catch (CanteraError) {
//throw CanteraError("equilibrate",

View file

@ -498,7 +498,7 @@ namespace ctml {
const char* tr_file, const char* out_file, const char* id_tag) {
ckr::CKReader r;
r.validate = true;
int i=1;
//int i=1;
string infile = string(in_file);
string dbfile = string(db_file);

View file

@ -14,23 +14,44 @@ namespace Cantera {
const int LeftInlet = 1;
const int RightInlet = -1;
// A class for surface domains in one-dimensional simulations, The
// surface is zero-dimensional, and defined by a set of surface
// species coverages.
/**
* The base class for boundaries between one-dimensional spatial
* domains. The boundary may have its own internal variables, such
* as surface species coverages.
*
* The boundary types are an inlet, an outlet, a symmetry plane,
* and a surface.
*
* The public methods are all virtual, and the base class
* implementations throw exceptions.
*/
class Bdry1D : public Resid1D {
public:
Bdry1D() : Resid1D(1, 1, 0.0) {}
virtual ~Bdry1D() {}
/// Initialize.
virtual void init(){err("init");}
/// Set the temperature.
virtual void setTemperature(doublereal t){err("setTemperature");}
/// Temperature [K].
virtual doublereal temperature() {err("temperature"); return 0.0;}
/// Set the mole fractions by specifying a string.
virtual void setMoleFractions(string xin){err("setMoleFractions");}
/// Set the mole fractions by specifying an array.
virtual void setMoleFractions(doublereal* xin){err("setMoleFractions");}
/// Mass fraction of species k.
virtual doublereal massFraction(int k) {err("massFraction"); return 0.0;}
/// Set the total mass flow rate.
virtual void setMdot(doublereal mdot){err("setMdot");}
/// The total mass flow rate [kg/m2/s].
virtual doublereal mdot() {err("mdot"); return 0.0;}
protected:
private:
void err(string method) {
@ -56,6 +77,12 @@ namespace Cantera {
needJacUpdate();
}
/// set spreading rate
virtual void setSpreadRate(doublereal V0) {
m_V0 = V0;
needJacUpdate();
}
/// Temperature [K].
doublereal temperature() {return m_temp;}
@ -105,6 +132,8 @@ namespace Cantera {
vector_fp atol(2, 1.e-5);
setTolerances(2, rtol.begin(), 2, atol.begin());
// if a flow domain is present on the left, then this must
// be a right inlet
if (m_index > 0) {
Resid1D& r = container().domain(m_index-1);
if (r.domainType() == cFlowType) {
@ -130,6 +159,7 @@ namespace Cantera {
throw CanteraError("Inlet1D::init",
"An inlet domain must be connected to a flow domain.");
}
// components = u, V, T, lambda, + mass fractions
m_nsp = m_flow->nComponents() - 4;
m_yin.resize(m_nsp, 0.0);
if (m_xstr != "")
@ -149,31 +179,44 @@ namespace Cantera {
doublereal* r = rg + loc();
integer* diag = diagg + loc();
doublereal *xb, *rb;
//integer *db = diag + loc();
// residual equations for the two local variables
r[0] = m_mdot - x[0];
r[1] = m_temp - x[1];
// both are algebraic constraints
diag[0] = 0;
diag[1] = 0;
// if it is a left inlet, then the flow solution vector
// starts 2 to the right in the global solution vector
if (m_ilr == LeftInlet) {
xb = x + 2;
rb = r + 2;
// If the energy equation is being solved, then
// the flow domain set this residual to T(0).
// Subtract the inlet temperature.
if (m_flow->doEnergy(0)) {
rb[2] -= x[1]; // T
//db[2] = 1;
}
rb[3] += x[0]; // lambda
// spreading rate. Flow domain sets this to V(0),
// so for finite spreading rate subtract m_V0.
rb[1] -= m_V0;
rb[3] += x[0]; // lambda
for (k = 0; k < m_nsp; k++) {
rb[4+k] += x[0]*m_yin[k];
//db[4+k] = 1;
}
//cout << x[1] << " " << xb[2] << " " << rb[2] << endl;
}
// right inlet.
else {
int boffset = m_flow->nComponents();
xb = x - boffset;
rb = r - boffset;
rb[1] -= m_V0;
rb[2] -= x[1]; // T
xb[0] += x[0]; // u
for (k = 0; k < m_nsp; k++)
@ -192,7 +235,7 @@ namespace Cantera {
protected:
int m_ilr;
doublereal m_mdot, m_temp;
doublereal m_mdot, m_temp, m_V0;
StFlow *m_flow;
int m_nsp;
vector_fp m_yin;

43
README
View file

@ -1,10 +1,12 @@
C A N T E R A
release 1.3.5
2/03
release 1.4
4/12/2003
Copyright (c) 2001-2003 California Institute of Technology
Copyright (c) 2001, 2002 California Institute of Technology
License information
@ -18,18 +20,6 @@ holders.
Installing Cantera
==================
To download and install Cantera, run Python script 'ctupdate.py.'
It will perform a binary install on Windows, and build everything from
the source on any other platform.
Alternatively, to manually build Cantera, follow the procedure below.
Building Cantera from the source code
=====================================
@ -68,34 +58,35 @@ export LD_LIBRARY_PATH=$HOME/my_cantera_dir/lib
2) Windows Build Procedure
--------------------------
Cantera can be built under Windows using Visual C++ and Compaq Visual
Fortran. In the 'win32' directory, open workspace 'cantera.dsw'. Set
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.
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 C:\WINDOWS\SYSTEM32. Edit the project settings if you want
is placed in the Windows system directory. Edit the project settings if you want
to put it somewhere else.
Finally, build project 'ctsetup'. This creates a simple utility that
writes a Visual Studio project file or a unix Makefile and a prototype
C++ main program that you can use as the starting point to develop
your own C++ application.
Configuring Matlab
---------------------
Before you can build the Matlab toolbox from the source, Matlab needs
to be configured for your compiler. In Matlab type:
The Matlab toolbox uses one compiled MEX program written in C++.
Before you can build it from the source, Matlab needs to be configured
for your compiler. In Matlab type:
mex -setup
and enter the number for the compiler you wish to use.
To build the MEX file needed for the Matlab toolbox, within Matlab
go to to the 'cantera' directory containing the toolbox and type
'buildux' on unix/linux/Mac OS X, or 'buildwin' on Windows.
Configuring Python
---------------------
@ -105,4 +96,4 @@ have Python 2.0 or greater, you need to be able to write into its
'Lib/site-packages' directory, and the 'Numeric' package must be
installed. If any of these are not the case, run the Python script
'ctupdate.py' found in the 'tools/bin' directory to download and
install Python and Numeric.
install Python and Numeric, or install them yourself.

386
config/configure vendored

File diff suppressed because it is too large Load diff

View file

@ -20,6 +20,9 @@ CANTERA_LIBDIR=$prefix/lib/cantera
CANTERA_INCDIR=$prefix/include/cantera
ctroot=`(cd ..;pwd)`
if test -z "$username"; then username=$USER; fi
AC_SUBST(username)
AC_SUBST(ctroot)

View file

@ -5,6 +5,8 @@
#
all: kernel
install: templates-install
kernel:
cd src; @MAKE@
cd testtools; @MAKE@
@ -20,3 +22,11 @@ docs:
depends:
cd src; @MAKE@ depends
cd testtools; @MAKE@ depends
templates-install:
@INSTALL@ -d @prefix@/cantera/templates
@INSTALL@ -d @prefix@/cantera/templates/f77
@INSTALL@ -m 644 templates/f77/*.cpp @prefix@/cantera/templates/f77
@INSTALL@ -m 644 templates/f77/*.f @prefix@/cantera/templates/f77
@INSTALL@ -m 644 templates/f77/*.mak @prefix@/cantera/templates/f77
chown -R @username@ @prefix@/cantera/templates

View file

@ -6,18 +6,42 @@ c
program demo
implicit double precision (a-h,o-z)
parameter (MAXSP = 20, MAXRXNS = 100)
double precision x(MAXSP), y(MAXSP), wdot(MAXRXNS)
double precision q(MAXRXNS), qf(MAXRXNS), qr(MAXRXNS)
double precision x(MAXSP), y(MAXSP), wdot(MAXSP)
character*80 eq
c
call readmechanism('h2o2.xml','')
call newIdealGasMix('h2o2.xml','')
t = 1200.0
p = 101325.0
call setState_TPX_String(t, p, 'H2:2, O2:1')
write(*,*) ' **** Test Program ****'
call setState_TPX_String(t, p,
$ 'H2:2, O2:1, OH:0.01, H:0.01, O:0.01')
call equilibrate('HP')
write(*,*) '**** Fortran 77 Test Program ****'
write(*,10) temperature(), pressure(), density(),
$ enthalpy_mole(), entropy_mole(), cp_mole()
10 format(//'Temperature:',g14.5,' K'/'Pressure:',g14.5,' Pa'
$ /'Density:',g14.5,' kg/m**3'//)
10 format(//'Temperature: ',g14.5,' K'/
$ 'Pressure: ',g14.5,' Pa'/
$ 'Density: ',g14.5,' kg/m3'/
$ 'Molar Enthalpy:',g14.5,' J/kmol'/
$ 'Molar Entropy: ',g14.5,' J/kmol-K'/
$ 'Molar cp: ',g14.5,' J/kmol-K'//)
c
c Reaction information
c
irxns = nReactions()
call getFwdRatesOfProgress(qf)
call getRevRatesOfProgress(qr)
call getNetRatesOfProgress(q)
do i = 1,irxns
call getReactionEqn(i,eq)
write(*,20) eq,qf(i),qr(i),q(i)
20 format(a20,3g14.5,' kmol/m3/s')
end do
stop
end

View file

@ -10,6 +10,8 @@
properties and kinetic rates for reacting ideal gas mixtures. Only a
single pointer to an IdealGasMix object is stored, so only one
reaction mechanism may be used at any one time in the application.
Of course, it is a simple modification to store multiple objects if
it is desired to use multiple reaction mechanisms.
The functions defined here are ones commonly needed in application
programs that simulate gas-phase combustion or similar processes.
@ -19,25 +21,41 @@
examples in the demos/f77 subdirectory within the directory where
Cantera is installed.
Note that this library is not an "official" Cantera Fortran 77
interface, only an example. If you use it with your Fortran 77
application and want your application to be portable to other
machines running Cantera, include this file along with your source
code.
*/
// add any other Cantera header files you need here
#include "IdealGasMix.h"
#include "equilibrium.h"
// store a pointer to an IdealGasMix object. The object itself will
// be created by the call to init_.
static IdealGasMix* _gas = 0;
map<string, int> _equil_opt;
static void _init() {
_equil_opt["TP"] = TP;
_equil_opt["TV"] = TV;
_equil_opt["HP"] = HP;
_equil_opt["UV"] = UV;
_equil_opt["SP"] = SP;
_equil_opt["SV"] = SV;
}
// extern "C" turns off C++ name-mangling, so that the procedure names
// in the object file are exactly as shown here.
extern "C" {
/// This is the Fortran main program
extern int MAIN__();
/**
* Read in a reaction mechanism file and create an IdealGasMix
* object. The file may be in Chemkin-compatible format or in
@ -45,12 +63,13 @@ extern "C" {
* second argument. If none is required, enter an empty string as
* the second argument.
*/
void readmechanism_(char* file, char* thermo,
void newidealgasmix_(char* file, char* thermo,
ftnlen lenfile, ftnlen lenthermo) {
string fin = string(file, lenfile);
string fth = string(thermo, lenthermo);
if (_gas) delete _gas;
_gas = new IdealGasMix(fin, fth);
_init();
}
/// integer function nElements()
@ -70,12 +89,15 @@ extern "C" {
_gas->setState_TPX(*T, *P, X);
}
/// subroutine setState_TPX_AsString(T, P, X)
void setstate_tpx_asstring_(doublereal* T, doublereal* P,
/// subroutine setState_TPX_String(T, P, X)
void setstate_tpx_string_(doublereal* T, doublereal* P,
char* X, ftnlen lenx) {
_gas->setState_TPX(*T, *P, string(X, lenx));
}
void setstate_try_(doublereal* T, doublereal* rho, doublereal* Y) {
_gas->setState_TRY(*T, *rho, Y);
}
//-------------- thermodynamic properties ----------------------
@ -143,11 +165,14 @@ extern "C" {
doublereal gibbs_mass_() {
return _gas->gibbs_mole();
}
void equilibrate_(integer* opt) {
int option = *opt;
equilibrate(*_gas, option);
void equilibrate_(char* opt, ftnlen lenopt) {
if (lenopt != 2) {
throw CanteraError("equilibrate",
"two-character string required.");
}
string optstr = string(opt, 2);
equilibrate(*_gas, _equil_opt[optstr]);
}
@ -157,7 +182,8 @@ extern "C" {
int irxn = *i - 1;
fill(eqn, eqn + n, ' ');
string e = _gas->reactionString(irxn);
unsigned int nmx = (e.size() > n ? n : e.size());
int ns = e.size();
unsigned int nmx = (ns > n ? n : ns);
copy(e.begin(), e.begin()+nmx, eqn);
}
@ -165,9 +191,26 @@ extern "C" {
_gas->getNetProductionRates(wdot);
}
void getcreationrates_(doublereal* cdot) {
_gas->getCreationRates(cdot);
}
void getdestructionrates_(doublereal* ddot) {
_gas->getDestructionRates(ddot);
}
void getnetratesofprogress_(doublereal* q) {
_gas->getNetRatesOfProgress(q);
}
void getfwdratesofprogress_(doublereal* q) {
_gas->getFwdRatesOfProgress(q);
}
void getrevratesofprogress_(doublereal* q) {
_gas->getRevRatesOfProgress(q);
}
}