*** empty log message ***
This commit is contained in:
parent
6feaf20b82
commit
88da08f3bb
15 changed files with 225 additions and 54 deletions
|
|
@ -32,7 +32,7 @@ os_is_win=@OS_IS_WIN@
|
|||
|
||||
all: cantera/ctmethods.@mex_ext@
|
||||
|
||||
cantera/ctmethods.@mex_ext@: $(SRCS)
|
||||
cantera/ctmethods.@mex_ext@: $(SRCS) $(LIBDEPS) Makefile
|
||||
ifeq ($(os_is_win),0)
|
||||
@PYTHON_CMD@ setup_matlab.py @prefix@/bin @buildlib@ @CT_SHARED_LIB@ '$(LIBS)'
|
||||
else
|
||||
|
|
|
|||
|
|
@ -49,7 +49,7 @@ t = 0;
|
|||
dt = 0.1;
|
||||
t0 = cputime;
|
||||
names = {'CH4','O2','CO','CO2','H2O'};
|
||||
x = zeros([100 5])
|
||||
x = zeros([100 5]);
|
||||
for n = 1:100
|
||||
t = t + dt;
|
||||
advance(r, t);
|
||||
|
|
|
|||
|
|
@ -123,12 +123,13 @@ class CounterFlame(Stack):
|
|||
y[j,k] = yeq[k] + (zmix - zst)*(yin_f[k]
|
||||
- yeq[k])/(1.0 - zst)
|
||||
t[j] = teq + (t0f - teq)*(zmix - zst)/(1.0 - zst)
|
||||
print teq, t[j], t0f, zmix, zst
|
||||
else:
|
||||
for k in range(nsp):
|
||||
y[j,k] = yin_o[k] + zmix*(yeq[k] - yin_o[k])/zst
|
||||
t[j] = t0o + (teq - t0o)*zmix/zst
|
||||
|
||||
|
||||
t[0] = t0f
|
||||
t[-1] = t0o
|
||||
zrel = zz/dz
|
||||
self.setProfile('u', [0.0, 1.0], [u0f, -u0o])
|
||||
self.setProfile('V', [0.0, x0/dz, 1.0], [0.0, a, 0.0])
|
||||
|
|
|
|||
|
|
@ -219,11 +219,13 @@ py_domain_setupGrid(PyObject *self, PyObject *args)
|
|||
return NULL;
|
||||
|
||||
|
||||
PyArrayObject* grid_array = (PyArrayObject*)grid;
|
||||
PyArrayObject* grid_array = (PyArrayObject*)
|
||||
PyArray_ContiguousFromObject(grid, PyArray_DOUBLE, 1, 1);
|
||||
double* grid_data = (double*)grid_array->data;
|
||||
int grid_len = grid_array->dimensions[0];
|
||||
|
||||
_val = domain_setupGrid(i,grid_len,grid_data);
|
||||
Py_DECREF(grid_array);
|
||||
if (int(_val) == -1) return reportCanteraError();
|
||||
return Py_BuildValue("i",_val);
|
||||
}
|
||||
|
|
@ -484,16 +486,20 @@ py_stflow_setFixedTempProfile(PyObject *self, PyObject *args)
|
|||
return NULL;
|
||||
|
||||
|
||||
PyArrayObject* pos_array = (PyArrayObject*)pos;
|
||||
PyArrayObject* pos_array = (PyArrayObject*)
|
||||
PyArray_ContiguousFromObject(pos, PyArray_DOUBLE, 1, 1);
|
||||
double* pos_data = (double*)pos_array->data;
|
||||
int pos_len = pos_array->dimensions[0];
|
||||
|
||||
|
||||
PyArrayObject* temp_array = (PyArrayObject*)temp;
|
||||
PyArrayObject* temp_array = (PyArrayObject*)
|
||||
PyArray_ContiguousFromObject(temp, PyArray_DOUBLE, 1, 1);
|
||||
double* temp_data = (double*)temp_array->data;
|
||||
int temp_len = temp_array->dimensions[0];
|
||||
|
||||
_val = stflow_setFixedTempProfile(i,pos_len,pos_data,temp_len,temp_data);
|
||||
Py_DECREF(pos_array);
|
||||
Py_DECREF(temp_array);
|
||||
if (int(_val) == -1) return reportCanteraError();
|
||||
return Py_BuildValue("i",_val);
|
||||
}
|
||||
|
|
@ -548,11 +554,13 @@ py_sim1D_new(PyObject *self, PyObject *args)
|
|||
return NULL;
|
||||
|
||||
|
||||
PyArrayObject* domains_array = (PyArrayObject*)domains;
|
||||
PyArrayObject* domains_array = (PyArrayObject*)
|
||||
PyArray_ContiguousFromObject(domains, PyArray_INT, 1, 1);
|
||||
int* domains_data = (int*)domains_array->data;
|
||||
int domains_len = domains_array->dimensions[0];
|
||||
|
||||
_val = sim1D_new(domains_len,domains_data);
|
||||
_val = sim1D_new(domains_len,domains_data);
|
||||
Py_DECREF(domains_array);
|
||||
if (int(_val) == -1) return reportCanteraError();
|
||||
return Py_BuildValue("i",_val);
|
||||
}
|
||||
|
|
@ -603,16 +611,20 @@ py_sim1D_setProfile(PyObject *self, PyObject *args)
|
|||
return NULL;
|
||||
|
||||
|
||||
PyArrayObject* pos_array = (PyArrayObject*)pos;
|
||||
PyArrayObject* pos_array = (PyArrayObject*)
|
||||
PyArray_ContiguousFromObject(pos, PyArray_DOUBLE, 1, 1);
|
||||
double* pos_data = (double*)pos_array->data;
|
||||
int pos_len = pos_array->dimensions[0];
|
||||
|
||||
|
||||
PyArrayObject* v_array = (PyArrayObject*)v;
|
||||
PyArrayObject* v_array = (PyArrayObject*)
|
||||
PyArray_ContiguousFromObject(v, PyArray_DOUBLE, 1, 1);
|
||||
double* v_data = (double*)v_array->data;
|
||||
int v_len = v_array->dimensions[0];
|
||||
|
||||
_val = sim1D_setProfile(i,dom,comp,pos_len,pos_data,v_len,v_data);
|
||||
_val = sim1D_setProfile(i,dom,comp,pos_len,pos_data,v_len,v_data);
|
||||
Py_DECREF(pos_array);
|
||||
Py_DECREF(v_array);
|
||||
if (int(_val) == -1) return reportCanteraError();
|
||||
return Py_BuildValue("i",_val);
|
||||
}
|
||||
|
|
@ -661,11 +673,13 @@ py_sim1D_setTimeStep(PyObject *self, PyObject *args)
|
|||
return NULL;
|
||||
|
||||
|
||||
PyArrayObject* nsteps_array = (PyArrayObject*)nsteps;
|
||||
PyArrayObject* nsteps_array = (PyArrayObject*)
|
||||
PyArray_ContiguousFromObject(nsteps, PyArray_INT, 1, 1);
|
||||
int* nsteps_data = (int*)nsteps_array->data;
|
||||
int nsteps_len = nsteps_array->dimensions[0];
|
||||
|
||||
_val = sim1D_setTimeStep(i,stepsize,nsteps_len,nsteps_data);
|
||||
_val = sim1D_setTimeStep(i,stepsize,nsteps_len,nsteps_data);
|
||||
Py_DECREF(nsteps_array);
|
||||
if (int(_val) == -1) return reportCanteraError();
|
||||
return Py_BuildValue("i",_val);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -244,7 +244,8 @@ phase_setarray(PyObject *self, PyObject *args)
|
|||
PyObject* seq;
|
||||
if (!PyArg_ParseTuple(args, "iiiO:phase_setarray", &ph, &job, &norm, &seq))
|
||||
return NULL;
|
||||
PyArrayObject* a = (PyArrayObject*)seq;
|
||||
PyArrayObject* a = (PyArrayObject*)
|
||||
PyArray_ContiguousFromObject(seq, PyArray_DOUBLE, 1, 1);
|
||||
double* xd = (double*)a->data;
|
||||
int len = a->dimensions[0];
|
||||
switch (job) {
|
||||
|
|
@ -257,6 +258,7 @@ phase_setarray(PyObject *self, PyObject *args)
|
|||
default:
|
||||
iok = -10;
|
||||
}
|
||||
Py_DECREF(a);
|
||||
if (iok >= 0)
|
||||
return Py_BuildValue("i",iok);
|
||||
if (iok == -1)
|
||||
|
|
|
|||
|
|
@ -263,8 +263,11 @@ py_flowdev_setParameters(PyObject *self, PyObject *args)
|
|||
PyObject* c;
|
||||
if (!PyArg_ParseTuple(args, "iiO:flowdev_setParameters", &n, &sz, &c))
|
||||
return NULL;
|
||||
double* x = (double*)((PyArrayObject*)c)->data;
|
||||
PyArrayObject* ca = (PyArrayObject*)
|
||||
PyArray_ContiguousFromObject(c, PyArray_DOUBLE, 1, 1);
|
||||
double* x = (double*)ca->data;
|
||||
int iok = flowdev_setParameters(n, sz, x);
|
||||
Py_DECREF(ca);
|
||||
if (iok < 0) return reportError(iok);
|
||||
return Py_BuildValue("i",0);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -37,9 +37,11 @@ py_setParameters(PyObject *self, PyObject *args) {
|
|||
if (!PyArg_ParseTuple(args, "iiiO:py_setParameters",
|
||||
&n, &typ, &k, &parray)) return NULL;
|
||||
|
||||
PyArrayObject* a = (PyArrayObject*)parray;
|
||||
PyArrayObject* a = (PyArrayObject*)
|
||||
PyArray_ContiguousFromObject(parray, PyArray_DOUBLE, 1, 1);
|
||||
double* xd = (double*)a->data;
|
||||
int ok = trans_setParameters(n, typ, k, xd);
|
||||
Py_DECREF(a);
|
||||
if (ok < 0) return reportError(ok);
|
||||
return Py_BuildValue("i",ok);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -124,7 +124,7 @@ namespace Cantera {
|
|||
* Perform an LU decomposition. LAPACK routine DGBTRF is used.
|
||||
* The factorization is saved in ludata.
|
||||
*/
|
||||
void BandMatrix::factor() {
|
||||
int BandMatrix::factor() {
|
||||
int info=0;
|
||||
copy(data.begin(), data.end(), ludata.begin());
|
||||
ct_dgbtrf(rows(), columns(), nSubDiagonals(), nSuperDiagonals(),
|
||||
|
|
@ -135,13 +135,15 @@ namespace Cantera {
|
|||
m_factored = true;
|
||||
}
|
||||
else {
|
||||
ofstream fout("bandmatrix.csv");
|
||||
fout << *this << endl;
|
||||
fout.close();
|
||||
throw CanteraError("BandMatrix::factor",
|
||||
"DGBTRF returned info = "+int2str(info)+".\n"
|
||||
+"Matrix written to file bandmatrix.csv\n");
|
||||
m_factored = false;
|
||||
//ofstream fout("bandmatrix.csv");
|
||||
//fout << *this << endl;
|
||||
//fout.close();
|
||||
//throw CanteraError("BandMatrix::factor",
|
||||
// "DGBTRF returned info = "+int2str(info)+".\n"
|
||||
// +"Matrix written to file bandmatrix.csv\n");
|
||||
}
|
||||
return info;
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -170,29 +172,31 @@ namespace Cantera {
|
|||
// "DGBTRS returned info = "+int2str(info)+".\n"
|
||||
// +"Matrix written to file bandmatrix.csv\n");
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
void BandMatrix::solve(int n, const doublereal* b, doublereal* x) {
|
||||
int BandMatrix::solve(int n, const doublereal* b, doublereal* x) {
|
||||
copy(b, b+n, x);
|
||||
solve(n, x);
|
||||
return solve(n, x);
|
||||
}
|
||||
|
||||
void BandMatrix::solve(int n, doublereal* b) {
|
||||
int BandMatrix::solve(int n, doublereal* b) {
|
||||
int info = 0;
|
||||
if (!m_factored) factor();
|
||||
ct_dgbtrs(ctlapack::NoTranspose, columns(), nSubDiagonals(),
|
||||
nSuperDiagonals(), 1, ludata.begin(), ldim(), ipiv().begin(),
|
||||
b, columns(), info);
|
||||
if (!m_factored) info = factor();
|
||||
if (info == 0)
|
||||
ct_dgbtrs(ctlapack::NoTranspose, columns(), nSubDiagonals(),
|
||||
nSuperDiagonals(), 1, ludata.begin(), ldim(),
|
||||
ipiv().begin(), b, columns(), info);
|
||||
|
||||
// error handling
|
||||
if (info != 0) {
|
||||
ofstream fout("bandmatrix.csv");
|
||||
fout << *this << endl;
|
||||
fout.close();
|
||||
throw CanteraError("BandMatrix::solve",
|
||||
"DGBTRS returned info = "+int2str(info)+".\n"
|
||||
+"Matrix written to file bandmatrix.csv\n");
|
||||
}
|
||||
//if (info != 0) {
|
||||
// ofstream fout("bandmatrix.csv");
|
||||
// fout << *this << endl;
|
||||
// fout.close();
|
||||
// throw CanteraError("BandMatrix::solve",
|
||||
// "DGBTRS returned info = "+int2str(info)+".\n"
|
||||
// +"Matrix written to file bandmatrix.csv\n");
|
||||
//}
|
||||
return info;
|
||||
}
|
||||
|
||||
ostream& operator<<(ostream& s, const BandMatrix& m) {
|
||||
|
|
|
|||
|
|
@ -105,12 +105,12 @@ namespace Cantera {
|
|||
/// Multiply b*A and write result to prod.
|
||||
void leftMult(const double* b, double* prod) const;
|
||||
|
||||
void factor();
|
||||
int factor();
|
||||
|
||||
//void solve(const vector_fp& b, vector_fp& x);
|
||||
|
||||
void solve(int n, const doublereal* b, doublereal* x);
|
||||
void solve(int n, doublereal* b);
|
||||
int solve(int n, const doublereal* b, doublereal* x);
|
||||
int solve(int n, doublereal* b);
|
||||
|
||||
vector_fp::iterator begin() {
|
||||
m_factored = false;
|
||||
|
|
|
|||
|
|
@ -173,7 +173,7 @@ namespace Cantera {
|
|||
}
|
||||
parseCompString(cov, cc);
|
||||
doublereal c;
|
||||
vector_fp cv(kk);
|
||||
vector_fp cv(kk, 0.0);
|
||||
for (k = 0; k < kk; k++) {
|
||||
c = cc[speciesName(k)];
|
||||
if (c > 0.0) cv[k] = c;
|
||||
|
|
|
|||
|
|
@ -99,11 +99,11 @@ DEPENDS = $(EVERYTHING:.o=.d)
|
|||
@CXX@ -c $< $(CXX_FLAGS)
|
||||
#$(CXX_INCLUDES)
|
||||
|
||||
misc.o: misc.cpp
|
||||
misc.o: misc.cpp ../../Makefile
|
||||
echo '#define CANTERA_ROOT "@prefix@/cantera"' > ctdir.h
|
||||
@CXX@ -c misc.cpp $(CXX_FLAGS)
|
||||
|
||||
ct2ctml.o: ct2ctml.cpp
|
||||
ct2ctml.o: ct2ctml.cpp ../../Makefile
|
||||
echo '#define PYTHON_EXE "@PYTHON_CMD@"' > pypath.h
|
||||
@CXX@ -c ct2ctml.cpp $(CXX_FLAGS)
|
||||
|
||||
|
|
|
|||
|
|
@ -114,16 +114,36 @@ namespace Cantera {
|
|||
*/
|
||||
void MultiNewton::step(doublereal* x, doublereal* step,
|
||||
OneDim& r, MultiJac& jac, int loglevel) {
|
||||
int n;
|
||||
int n, iok;
|
||||
int sz = r.size();
|
||||
r.eval(-1, x, step);
|
||||
for (n = 0; n < sz; n++) {
|
||||
step[n] = -step[n];
|
||||
}
|
||||
//try {
|
||||
jac.solve(sz, step, step);
|
||||
//}
|
||||
//catch (CanteraError) {
|
||||
try {
|
||||
iok = jac.solve(sz, step, step);
|
||||
if (iok > 0) {
|
||||
iok--;
|
||||
int nd = r.nDomains();
|
||||
for (n = nd-1; n >= 0; n--)
|
||||
if (iok >= r.start(n)) { break; }
|
||||
Domain1D& dom = r.domain(n);
|
||||
int offset = iok - r.start(n);
|
||||
int pt = offset/dom.nComponents();
|
||||
int comp = offset - pt*dom.nComponents();
|
||||
throw CanteraError("MultiNewton::step",
|
||||
"Jacobian is singular for domain "+
|
||||
dom.id() + ", component "
|
||||
+dom.componentName(comp)+" at point "
|
||||
+int2str(pt));
|
||||
}
|
||||
else if (iok < 0)
|
||||
throw CanteraError("MultiNewton::step",
|
||||
"iok = "+int2str(iok));
|
||||
}
|
||||
catch (CanteraError) {
|
||||
showErrors(cout);
|
||||
}
|
||||
#undef DEBUG_STEP
|
||||
#ifdef DEBUG_STEP
|
||||
bool ok = false;
|
||||
|
|
|
|||
|
|
@ -133,7 +133,7 @@ finish-install:
|
|||
@INSTALL@ -d @prefix@/bin
|
||||
@INSTALL@ bin/ck2cti* @prefix@/bin
|
||||
@INSTALL@ -d @prefix@/doc
|
||||
@INSTALL@ doc/*.pdf @prefix@/doc
|
||||
#@INSTALL@ doc/*.pdf @prefix@/doc
|
||||
@INSTALL@ -d @prefix@/cantera/demos/c++
|
||||
@INSTALL@ examples/cxx/*.cpp @prefix@/cantera/demos/c++
|
||||
@INSTALL@ examples/cxx/*.h @prefix@/cantera/demos/c++
|
||||
|
|
|
|||
4
README
4
README
|
|
@ -1,9 +1,9 @@
|
|||
|
||||
C A N T E R A
|
||||
|
||||
release 1.4
|
||||
release 1.5
|
||||
|
||||
4/12/2003
|
||||
9/12/2003
|
||||
|
||||
Copyright (c) 2001-2003 California Institute of Technology
|
||||
|
||||
|
|
|
|||
125
README.txt
Normal file
125
README.txt
Normal file
|
|
@ -0,0 +1,125 @@
|
|||
|
||||
C A N T E R A
|
||||
|
||||
release 1.5
|
||||
|
||||
9/12/2003
|
||||
|
||||
Copyright (c) 2001-2003 California Institute of Technology
|
||||
|
||||
|
||||
|
||||
License information
|
||||
===================
|
||||
|
||||
See the file "License.txt" for information on the terms & conditions
|
||||
for usage, and a DISCLAIMER OF ALL WARRANTIES.
|
||||
|
||||
All trademarks referenced herein are property of their respective
|
||||
holders.
|
||||
|
||||
|
||||
|
||||
Building Cantera from the source code
|
||||
=====================================
|
||||
|
||||
|
||||
1) Unix/linux/cygwin 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:
|
||||
|
||||
configure --prefix=$HOME/my_cantera_dir
|
||||
|
||||
If necessary, edit 'configure' to set options appropriate for your
|
||||
system.
|
||||
|
||||
After running 'configure', type:
|
||||
|
||||
make
|
||||
make install
|
||||
|
||||
The last one may need to be run as super-user.
|
||||
|
||||
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.
|
||||
|
||||
The build process requires a 'make' utility compatible with GNU
|
||||
'make'. If this has a different name on your system, define
|
||||
environment variable MAKE to the name (e..g. 'gmake') before running
|
||||
'configure'.
|
||||
|
||||
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
|
||||
If either is missing or an error occurs, the interface is not installed.
|
||||
|
||||
|
||||
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.
|
||||
|
||||
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.
|
||||
|
||||
|
||||
|
||||
Configuring Matlab
|
||||
---------------------
|
||||
|
||||
The Matlab toolbox uses one compiled MEX program written in C++.
|
||||
Before you can build it, Matlab needs to be configured
|
||||
for your compiler. In Matlab type:
|
||||
|
||||
mex -setup
|
||||
|
||||
and enter the number for the compiler you wish to use.
|
||||
|
||||
The Matlab toolbox is built automatically by the Cantera build
|
||||
process, but can also be built manually. 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
|
||||
---------------------
|
||||
|
||||
Before you can build the Python interface from the source, you need to
|
||||
have Python 2.0 or greater, and the 'Numeric' package must be
|
||||
installed. Python is available at www.python.org, and Numeric is
|
||||
available through SourceForge.
|
||||
|
||||
|
||||
Customizing
|
||||
-----------
|
||||
|
||||
Before running configure, the following environment variables may be set:
|
||||
|
||||
MAKE set to 'make' utility compatible with GNU make
|
||||
|
||||
CXX C++ compiler
|
||||
|
||||
F77 Fortran 77 compiler
|
||||
|
||||
PYTHON_CMD Python interpreter to use with Cantera
|
||||
(default: 'python')
|
||||
|
||||
MATLAB_CMD Matlab command (default: 'matlab')
|
||||
|
||||
Additional customization can be done by editing the configure script.
|
||||
|
||||
Loading…
Add table
Reference in a new issue